Tuesday, August 11, 2009

columbarium_growth_by_grisha

this is my studio project "a multireligious columbarium"




and this is the script for it

import maya.cmds as cmds
import maya.cmds as cmds
import maya.mel as mm
import math
import sys
from random import*
from setColor import*

# increasing recursion limit to 8000 loops
sys.setrecursionlimit(8000)

#######################
### HELPING SCRIPTS ###
#######################

# getting center of the Face
def centerOfFace(facet):
#find the vertices that define that face.
vertex = cmds.polyListComponentConversion(facet, ff=1, tv=1)
cmds.select(vertex, r=1)
vertexFlat = cmds.ls(sl=1, fl=1)

#find out how many vertices define that face
vertCount = len(vertexFlat)
#print vertexFlat

#for each vertex go through and find it's world space position.
vertPositionSumX = 0.
vertPositionSumY = 0.
vertPositionSumZ = 0.
for a in range(0, vertCount, 1):
coordinate = cmds.pointPosition(vertexFlat[a], w=1)
vertPositionSumX += coordinate[0]
vertPositionSumY += coordinate[1]
vertPositionSumZ += coordinate[2]

centroidX = vertPositionSumX/float(vertCount)
centroidY = vertPositionSumY/float(vertCount)
centroidZ = vertPositionSumZ/float(vertCount)

return [centroidX, centroidY, centroidZ]

# distance between two points
def getDistance(start, end):
#start and end must be lists xyz
v = [start[0]-end[0], start[1]-end[1], start[2]-end[2]] #list format x,y,z
vector = "<<" + str(v[0]) + "," + str(v[1]) + "," + str(v[2]) + ">>"
mag = mm.eval("mag " + vector + ";")

return mag

# looking for closest locator through the list with locators to the LOCATOR
def closestLocator (locator, netOfLocs):
locatorPos = cmds.pointPosition(locator)
distance = 1000000000
closLocData = []
closestLocator = ""
for i in netOfLocs:
locPos = cmds.pointPosition(i)
currDist = getDistance(locatorPos, locPos)
if currDist < distance =" currDist" closlocator =" i" closlocpos =" locPos" closlocdist =" currDist" locatorpos =" Point" distance =" 1000000000" closlocdata =" []" closestlocator = "" locpos =" i[1]" currdist =" getDistance(locatorPos," distance =" currDist" closlocator =" i[0]" closlocpos =" locPos" closlocdist =" currDist" locatorpos =" Point" distance =" 1000000000" closlocdata =" []" closestlocator = "" locpos =" i" currdist =" getDistance(locatorPos," distance =" currDist" closlocator =" i[0]" closlocpos =" locPos" closlocdist =" currDist" locatorpos =" Point" distance =" 1000000000" closlocdata =" []" closestlocator = "" locpos =" i[2]" currdist =" getDistance(locatorPos," distance =" currDist" closlocator =" i[0]" grow =" i[1]" closlocpos =" locPos" closlocdist =" currDist" locatorpos =" Point" distance =" 1000000000" closlocdata =" []" closestlocator = "" locpos =" i[1]" currdist =" getDistance(locatorPos," distance =" currDist" closlocator =" i[0]" closlocpos =" locPos" closlocdist =" currDist" locatorpos =" center" distance =" 1000000000" closlocdata =" []" closestlocator = "" locpos =" i" currdist =" getDistance(locatorPos," distance =" currDist" closlocator =" i" closlocpos =" i" closlocdist =" currDist" x="0" y="0" z="0" n="0" ptpos =" cmds.pointPosition(i)" x="x+ptPos[0]" y="y+ptPos[1]" z="z+ptPos[2]" n="n+1" ptpos =" cmds.pointPosition(i)" x="x+ptPos[0]" y="y+ptPos[1]" z="z+ptPos[2]" n="n+1" midx =" x/n" midy =" y/n" midz =" z/n" midpt="[]" x="0" y="0" z="0" n="0" ptpos =" cmds.pointPosition(listLoc1[i])" x="x+ptPos[0]" y="y+ptPos[1]" z="z+ptPos[2]" n="n+1" ptpos =" listPt2" x="x+(ptPos[0]*len(listLoc1))" y="y+(ptPos[1]*len(listLoc1))" z="z+(ptPos[2]*len(listLoc1))" n="n+len(listLoc1)" midx =" x/n" midy =" y/n" midz =" z/n" midpt="[]" dire =" [" center =" center" loc2 =" loc2[0]" loc3 =" loc3[0]" loc4 =" loc4[0]" clpt1 =" closestPointToPoints" clpt2 =" closestPointToPoints" clpt1 =" clPt1[0]" clpt2 =" clPt2[0]" centerclosrelig =" centerClosRelig[0]" x =" (3*loc2[0]" y =" (3*loc2[1]" point =" [x,y,0]" x =" center[0]" y =" center[1]" new =" [x,y,0]" va =" (locPos[0]" vb =" (0,1,0)" angle =" cmds.angleBetween(v1=" v2="vb)" angle =" angle[3]" graves =" []" mitrary =" []" buddhism =" []" catholic=" []" orthodox =" []" hindu =" []" judaism =" []" protest =" []" islam =" []" allrelig =" []" otherr =" []" amitrary =" []" abuddhism =" []" acatholic=" []" aorthodox =" []" ahindu =" []" ajudaism =" []" aprotest =" []" aislam =" []" aallrelig =" []" ceremony =" []" entrance =" []" otherw =" []" otherm =" []" allrepuls =" []" trees =" []" treessrf=" []" cubes =" []" ff =" []" mitrary =" ff" ff =" []" buddhism =" ff" ff =" []" catholic =" ff" ff =" []" orthodox =" ff" ff =" []" hindu =" ff" ff =" []" judaism =" ff" ff =" []" protest =" ff" ff =" []" islam =" ff" ff =" []" amitrary =" ff" ff =" []" abuddhism =" ff" ff =" []" acatholic =" ff" ff =" []" aorthodox =" ff" ff =" []" ahindu =" ff" ff =" []" ajudaism =" ff" ff =" []" aprotest =" ff" ff =" []" aislam =" ff" otherrr =" []" otherr =" otherRR" allrelig =" self.mitrary" mmm="[]" mmmm="[]" ceremony =" mmm" entrance =" mmmm" otherw =" [centerOfFace('polySurface7766.f[0]'),centerOfFace('polySurface7770.f[0]'),centerOfFace('polySurface7767.f[0]'),centerOfFace('polySurface7769.f[0]'),centerOfFace('polySurface7771.f[0]')]" otherm =" [centerOfFace('polySurface7762.f[0]'),centerOfFace('polySurface7763.f[0]'),centerOfFace('polySurface7764.f[0]'),centerOfFace('polySurface7765.f[0]')]" allrepuls =" self.entrance" mm=" []" mmm =" []" m =" 'polySurface%d.f[0]'" n =" 'polySurface%d'" treessrf =" mmm" trees =" mm" r="True)" faces =" cmds.filterExpand(sm=" faces =" []" all="True)" cface =" centerOfFace(i)" loc =" cmds.spaceLocator(" p="(Cface[0],Cface[1],Cface[2])" graves =" FACES" all =" True)" locs =" cmds.filterExpand(sm=" pp =" []" loc =" i" lpos =" cmds.pointPosition(i)" oo =" []" graves =" PP" cubes =" []" position =" cmds.pointPosition(i)" cube =" cmds.polyCube" w ="size" h="size" d="size" repsize="10," pointsamount =" 4," n="0):" repulsivelocs =" self.allRepuls" locs =" self.graves" l="(repSize/5)*(i+1)" kpos =" k" closloc =" closestLocatorToPoint(Kpos," locpos =" closLoc[1]" clloc =" closLoc[0]" direc =" direction(LOCpos," newx =" ((direc[0]*6)/((i+1)*(i+1)))" newy =" ((direc[1]*6)/((i+1)*(i+1)))" newz =" ((direc[2]*6)/((i+1)*(i+1)))" cll =" [clLoc,LOCpos]" n="0," mn="0," bn="0," cn="0," on="0," hn="0," jn="0," pn="0," in="0," cubes =" []," max =" 150.0," cofcenmove="10" m =" [1]" b =" [2]" c =" [3]" o =" [4]" h =" [5]" j =" [6]" p =" [7]" i =" [8]" way ="=" way ="=" xxx =" randint" way ="=" xxx =" randint" n ="=" n ="=" n ="=" n="=" allrelig =" [M]+[B]+[C]+[O]+[H]+[J]+[P]+[I]" n="N+1" trees =" self.trees" closreligion =" closestPointToPoints1">= closReligion[1]:
M.append (midPtWater (self.otherW, self.otherM, M[2], self.ceremony, self.entrance, self.Amitrary, closReligion[2])) # midPt [3]
else:
closPT = closReligion[2]
g = M[2]
xx = g[0] - (closPT[0] - g[0])
yy = g[1] - (closPT[1] - g[1])
ptt = [xx, yy, 0]
M.append (midPtWater (self.otherW, self.otherM, M[2], self.ceremony, self.entrance, self.Amitrary, ptt)) # midPt [3]
#setting the center of growing
newCen = newCenter (M[2], M[3], cofCenMove)
M[2] = newCen
prevousPt = newCen

if M[1]/10 == 0:
GG = randint (0,1)
else:
GG = M[1]/10
#trees growth
for i in range (GG):
#looking for closest tree
closTree = closestTreeToPoint (M[2], Trees)
closTree = closTree[0]
#making a circle in new tree position
cmds.circle (c=(closTree[0], closTree[1], closTree[2]), r=1.5)
cmds.planarSrf (d=1)
#1 tree == 2 graves... so... looking for closest two graves to the tree and removing the from the list
for i in range (2):
closGrave = closestPointToPoints2 (closTree, allGraves)
closGraveName = [closGrave[0],closGrave[1]]
allGraves.remove (closGraveName)
# stop recursion because allGraves list is empty
if len(allGraves)==1:
return "Done."
# stop the loop if Trees list is empty
if len(Trees) < closgrave =" closestPointToPoints2" closgravepos =" closGrave[1]" closgravename =" [closGrave[0],closGrave[1]]">= MAX:
MN = 0
M2 = closGrave[1]
allGraves.remove (closGraveName)
break
else:
M2 = M[2]
#looking for angle rotate the box according it to face the center
angle = angleBetweenVectors (M[2], closGravePos)
#making the cube with size which is changing depends on counter
cube = cmds.polyCube (w =size*(MN/MAX) ,h=size*(MN/MAX) ,d=size*(MN/MAX))
CUBES.append (cube[0])
#move the cube to the locator position
cmds.move (closGravePos[0], closGravePos[1], closGravePos[2], cube)
#rotate the cube to face the center of the religion
cmds.rotate ( angle[0], angle[1], angle[2], cube, pivot=closGravePos )
#remove the locator from the list with locators according to not to loop through it next time
allGraves.remove (closGraveName)
# draw a curve between center of the religion and the locator
cmds.curve( p=[(M2[0],M2[1], M2[2]), (closGravePos[0], closGravePos[1], closGravePos[2])] )
prevousPt = closGravePos
# stop recursion because allGraves list is empty
if len(allGraves)==1:
return "Done."


#return "Done."
cmds.refresh()

####### ALL THE RELIGIONS HAVE SIMILAR LOGIC BUT DIFFERENT NUMBERS

######BUDDISM######
closReligion = closestPointToPoints1 (B[2], ALLRELIG) #dist - [3]
if B[1] >= closReligion[1]:
B.append (midPtWater (self.otherW, self.otherM, B[2], self.ceremony, self.entrance, self.Abuddhism, closReligion[2])) # midPt [3]
else:
closPT = closReligion[2]
g = B[2]
xx = g[0] - (closPT[0] - g[0])
yy = g[1] - (closPT[1] - g[1])
ptt = [xx, yy, 0]
B.append (midPtWater (self.otherW, self.otherM, B[2], self.ceremony, self.entrance, self.Abuddhism, ptt)) # midPt [3]
newCen = newCenter (B[2], B[3], cofCenMove)
B[2] = newCen
prevousPt = newCen

if B[1]/10 == 0:
GG = randint (0,1)
else:
GG = B[1]/10
for i in range (GG):
closTree = closestTreeToPoint (B[2], Trees)
closTree = closTree[0]
cmds.circle (c=(closTree[0], closTree[1], closTree[2]), r=1.5)
cmds.planarSrf (d=1)
#print "closTree"
#print closTree
for i in range (2):
closGrave = closestPointToPoints2 (closTree, allGraves)
closGraveName = [closGrave[0],closGrave[1]]
allGraves.remove (closGraveName)
if len(allGraves)==1:
return "Done."
if len(Trees) < closgrave =" closestPointToPoints2" closgravepos =" closGrave[1]" closgravename =" [closGrave[0],closGrave[1]]">= MAX:
BN = 0
B2 = closGrave[1]
allGraves.remove (closGraveName)
break
else:
B2 = B[2]
cube = cmds.polyCube (w =size*(BN/MAX) ,h=size*(BN/MAX) ,d=size*(BN/MAX))
CUBES.append (cube[0])
cmds.move (closGravePos[0], closGravePos[1], closGravePos[2], cube)
allGraves.remove (closGraveName)
cmds.curve( p=[(B2[0],B2[1], B2[2]), (closGravePos[0], closGravePos[1], closGravePos[2])] )
prevousPt = closGravePos
if len(allGraves)==1:
return "Done."

cmds.refresh()

######Catholics######
closReligion = closestPointToPoints1 (C[2], ALLRELIG) #dist - [3]
if C[1] >= closReligion[1]:
C.append (midPtWater (self.otherW, self.otherM, C[2], self.ceremony, self.entrance, self.Acatholic, closReligion[2])) # midPt [3]
else:
closPT = closReligion[2]
g = C[2]
xx = g[0] - (closPT[0] - g[0])
yy = g[1] - (closPT[1] - g[1])
ptt = [xx, yy, 0]
C.append (midPtWater (self.otherW, self.otherM, C[2], self.ceremony, self.entrance, self.Acatholic, ptt)) # midPt [3]
newCen = newCenter (C[2], C[3], cofCenMove)
C[2] = newCen
prevousPt = newCen

if C[1]/10 == 0:
GG = randint (0,1)
else:
GG = C[1]/10
for i in range (GG):
closTree = closestTreeToPoint (C[2], Trees)
closTree = closTree[0]
cmds.circle (c=(closTree[0], closTree[1], closTree[2]), r=1.5)
cmds.planarSrf (d=1)
#print "closTree"
#print closTree
for i in range (2):
closGrave = closestPointToPoints2 (closTree, allGraves)
closGraveName = [closGrave[0],closGrave[1]]
allGraves.remove (closGraveName)
if len(allGraves)==1:
return "Done."
if len(Trees) < closgrave =" closestPointToPoints2" closgravepos =" closGrave[1]" closgravename =" [closGrave[0],closGrave[1]]">= MAX:
CN = 0
C2 = closGrave[1]
allGraves.remove (closGraveName)
break
else:
C2 = C[2]
cube = cmds.polyCube (w =size*(CN/MAX) ,h=size*(CN/MAX) ,d=size*(CN/MAX))
CUBES.append (cube[0])
cmds.move (closGravePos[0], closGravePos[1], closGravePos[2], cube)
allGraves.remove (closGraveName)
cmds.curve( p=[(C2[0],C2[1], C2[2]), (closGravePos[0], closGravePos[1], closGravePos[2])] )
prevousPt = closGravePos
if len(allGraves)==1:
return "Done."

cmds.refresh()

######Orthodox######
closReligion = closestPointToPoints1 (O[2], ALLRELIG) #dist - [3]
if O[1] >= closReligion[1]:
O.append (midPtWater (self.otherW, self.otherM, O[2], self.ceremony, self.entrance, self.Aorthodox, closReligion[2])) # midPt [3]
else:
closPT = closReligion[2]
g = O[2]
xx = g[0] - (closPT[0] - g[0])
yy = g[1] - (closPT[1] - g[1])
ptt = [xx, yy, 0]
O.append (midPtWater (self.otherW, self.otherM, O[2], self.ceremony, self.entrance, self.Aorthodox, ptt)) # midPt [3]
newCen = newCenter (O[2], O[3], cofCenMove)
O[2] = newCen
prevousPt = newCen

if O[1]/10 == 0:
GG = randint (0,1)
else:
GG = O[1]/10
for i in range (GG):
closTree = closestTreeToPoint (O[2], Trees)
closTree = closTree[0]
cmds.circle (c=(closTree[0], closTree[1], closTree[2]), r=1.5)
cmds.planarSrf (d=1)
#print "closTree"
#print closTree
for i in range (2):
closGrave = closestPointToPoints2 (closTree, allGraves)
closGraveName = [closGrave[0],closGrave[1]]
allGraves.remove (closGraveName)
if len(allGraves)==1:
return "Done."
if len(Trees) < closgrave =" closestPointToPoints2" closgravepos =" closGrave[1]" closgravename =" [closGrave[0],closGrave[1]]">= MAX:
ON = 0
O2 = closGrave[1]
allGraves.remove (closGraveName)
break
else:
O2 = O[2]
cube = cmds.polyCube (w =size*(ON/MAX) ,h=size*(ON/MAX) ,d=size*(ON/MAX))
CUBES.append (cube[0])
cmds.move (closGravePos[0], closGravePos[1], closGravePos[2], cube)
allGraves.remove (closGraveName)
cmds.curve( p=[(O2[0],O2[1], O2[2]), (closGravePos[0], closGravePos[1], closGravePos[2])] )
prevousPt = closGravePos
if len(allGraves)==1:
return "Done."

cmds.refresh()

######HINDU######
closReligion = closestPointToPoints1 (H[2], ALLRELIG) #dist - [3]
if H[1] >= closReligion[1]:
H.append (midPtWater (self.otherW, self.otherM, H[2], self.ceremony, self.entrance, self.Aprotest, closReligion[2])) # midPt [3]
else:
closPT = closReligion[2]
g = H[2]
xx = g[0] - (closPT[0] - g[0])
yy = g[1] - (closPT[1] - g[1])
ptt = [xx, yy, 0]
H.append (midPtWater (self.otherW, self.otherM, H[2], self.ceremony, self.entrance, self.Aprotest, ptt)) # midPt [3]
newCen = newCenter (H[2], H[3], cofCenMove)
H[2] = newCen
prevousPt = newCen

if H[1]/10 == 0:
GG = randint (0,1)
else:
GG = H[1]/10
for i in range (GG):
closTree = closestTreeToPoint (H[2], Trees)
closTree = closTree[0]
cmds.circle (c=(closTree[0], closTree[1], closTree[2]), r=1.5)
cmds.planarSrf (d=1)
#print "closTree"
#print closTree
for i in range (2):
closGrave = closestPointToPoints2 (closTree, allGraves)
closGraveName = [closGrave[0],closGrave[1]]
allGraves.remove (closGraveName)
if len(allGraves)==1:
return "Done."
if len(Trees) < closgrave =" closestPointToPoints2" closgravepos =" closGrave[1]" closgravename =" [closGrave[0],closGrave[1]]">= MAX:
HN = 0
H2 = closGrave[1]
allGraves.remove (closGraveName)
break
else:
H2 = H[2]
cube = cmds.polyCube (w =size*(HN/MAX) ,h=size*(HN/MAX) ,d=size*(HN/MAX))
CUBES.append (cube[0])
cmds.move (closGravePos[0], closGravePos[1], closGravePos[2], cube)
allGraves.remove (closGraveName)
cmds.curve( p=[(H2[0],H2[1], H2[2]), (closGravePos[0], closGravePos[1], closGravePos[2])] )
prevousPt = closGravePos
if len(allGraves)==1:
return "Done."

cmds.refresh()

######JUDAISM######
closReligion = closestPointToPoints1 (J[2], ALLRELIG) #dist - [3]
if J[1] >= closReligion[1]:
J.append (midPtWater (self.otherW, self.otherM, J[2], self.ceremony, self.entrance, self.Ajudaism, closReligion[2])) # midPt [3]
else:
closPT = closReligion[2]
g = J[2]
xx = g[0] - (closPT[0] - g[0])
yy = g[1] - (closPT[1] - g[1])
ptt = [xx, yy, 0]
J.append (midPtWater (self.otherW, self.otherM, J[2], self.ceremony, self.entrance, self.Ajudaism, ptt)) # midPt [3]
newCen = newCenter (J[2], J[3], cofCenMove)
J[2] = newCen
prevousPt = newCen

if J[1]/10 == 0:
GG = randint (0,1)
else:
GG = J[1]/10
for i in range (GG):
closTree = closestTreeToPoint (J[2], Trees)
closTree = closTree[0]
cmds.circle (c=(closTree[0], closTree[1], closTree[2]), r=1.5)
cmds.planarSrf (d=1)
#print "closTree"
#print closTree
for i in range (2):
closGrave = closestPointToPoints2 (closTree, allGraves)
closGraveName = [closGrave[0],closGrave[1]]
allGraves.remove (closGraveName)
if len(allGraves)==1:
return "Done."
if len(Trees) < closgrave =" closestPointToPoints2" closgravepos =" closGrave[1]" closgravename =" [closGrave[0],closGrave[1]]">= MAX:
JN = 0
J2 = closGrave[1]
allGraves.remove (closGraveName)
break
else:
J2 = J[2]
cube = cmds.polyCube (w =size*(JN/MAX) ,h=size*(JN/MAX) ,d=size*(JN/MAX))
CUBES.append (cube[0])
cmds.move (closGravePos[0], closGravePos[1], closGravePos[2], cube)
allGraves.remove (closGraveName)
cmds.curve( p=[(J2[0],J2[1], J2[2]), (closGravePos[0], closGravePos[1], closGravePos[2])] )
prevousPt = closGravePos
if len(allGraves)==1:
return "Done."

cmds.refresh()

######PROTESTANTISM######
closReligion = closestPointToPoints1 (P[2], ALLRELIG) #dist - [3]
if P[1] >= closReligion[1]:
P.append (midPtWater (self.otherW, self.otherM, P[2], self.ceremony, self.entrance, self.Ahindu, closReligion[2])) # midPt [3]
else:
closPT = closReligion[2]
g = P[2]
xx = g[0] - (closPT[0] - g[0])
yy = g[1] - (closPT[1] - g[1])
ptt = [xx, yy, 0]
P.append (midPtWater (self.otherW, self.otherM, P[2], self.ceremony, self.entrance, self.Ahindu, ptt)) # midPt [3]
newCen = newCenter (P[2], P[3], cofCenMove)
P[2] = newCen
prevousPt = newCen

if P[1]/10 == 0:
GG = randint (0,1)
else:
GG = P[1]/10
for i in range (GG):
closTree = closestTreeToPoint (P[2], Trees)
closTree = closTree[0]
cmds.circle (c=(closTree[0], closTree[1], closTree[2]), r=1.5)
cmds.planarSrf (d=1)
#print "closTree"
#print closTree
for i in range (2):
closGrave = closestPointToPoints2 (closTree, allGraves)
closGraveName = [closGrave[0],closGrave[1]]
allGraves.remove (closGraveName)
if len(allGraves)==1:
return "Done."
if len(Trees) < closgrave =" closestPointToPoints2" closgravepos =" closGrave[1]" closgravename =" [closGrave[0],closGrave[1]]">= MAX:
PN = 0
P2 = closGrave[1]
allGraves.remove (closGraveName)
break
else:
P2 = P[2]
cube = cmds.polyCube (w =size*(PN/MAX) ,h=size*(PN/MAX) ,d=size*(PN/MAX))
CUBES.append (cube[0])
cmds.move (closGravePos[0], closGravePos[1], closGravePos[2], cube)
allGraves.remove (closGraveName)
cmds.curve( p=[(P2[0],P2[1], P2[2]), (closGravePos[0], closGravePos[1], closGravePos[2])] )
prevousPt = closGravePos
if len(allGraves)==1:
return "Done."

cmds.refresh()

######ISLAM######
closReligion = closestPointToPoints1 (I[2], ALLRELIG) #dist - [3]
if I[1] >= closReligion[1]:
I.append (midPtWater (self.otherW, self.otherM, I[2], self.ceremony, self.entrance, self.Aislam, closReligion[2])) # midPt [3]
else:
closPT = closReligion[2]
g = I[2]
xx = g[0] - (closPT[0] - g[0])
yy = g[1] - (closPT[1] - g[1])
ptt = [xx, yy, 0]
I.append (midPtWater (self.otherW, self.otherM, I[2], self.ceremony, self.entrance, self.Aislam, ptt)) # midPt [3]
newCen = newCenter (I[2], I[3], cofCenMove)
I[2] = newCen
prevousPt = newCen

if I[1]/10 == 0:
GG = randint (0,1)
else:
GG = I[1]/10
for i in range (GG):
closTree = closestTreeToPoint (I[2], Trees)
closTree = closTree[0]
cmds.circle (c=(closTree[0], closTree[1], closTree[2]), r=1.5)
cmds.planarSrf (d=1)
#print "closTree"
#print closTree
for i in range (2):
closGrave = closestPointToPoints2 (closTree, allGraves)
closGraveName = [closGrave[0],closGrave[1]]
allGraves.remove (closGraveName)
if len(allGraves)==1:
return "Done."
if len(Trees) < closgrave =" closestPointToPoints2" closgravepos =" closGrave[1]" closgravename =" [closGrave[0],closGrave[1]]">= MAX:
IN = 0
I2 = closGrave[1]
allGraves.remove (closGraveName)
break
else:
I2 = I[2]
cube = cmds.polyCube (w =size*(IN/MAX) ,h=size*(IN/MAX) ,d=size*(IN/MAX))
CUBES.append (cube[0])
cmds.move (closGravePos[0], closGravePos[1], closGravePos[2], cube)
allGraves.remove (closGraveName)
cmds.curve( p=[(I2[0],I2[1], I2[2]), (closGravePos[0], closGravePos[1], closGravePos[2])] )
prevousPt = closGravePos
if len(allGraves)==1:
return "Done."

cmds.refresh()

#duplicate and move all the cubes to see the growth progress after running the script
sss = cmds.duplicate( CUBES )
gr = cmds.group( sss )
cmds.select (gr, r=True)
cmds.move( 0, 300*N, 0 )

#run the recursion again if there are more elements in the locators list then 0
if len(allGraves)>0:
self.GROWTH (Way, minGrow, maxGrow, size, allGraves, M2, B2, C2, O2, H2, J2, P2, I2, N, MN, BN, CN, ON, HN, JN, PN, IN, CUBES, MAX = 150.0, cofCenMove=10)
else:
return "Done."

to run the script


g= graves()
allGraves=g.allLocs()
g.getAll()
g.changeNetBecauseRepulsive()
allGraves = g.allLocs1()
g.deleteTrees ()
#'Random'-1 'Normal'-2 'War'-3
g.GROWTH (1,3,80,1.5,allGraves,0,0,0,0,0,0,0,0)
maya file

No comments:

Post a Comment