Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymel.core as pm
- import random
- win_width = 150
- length = 4
- width = 4
- def random_size():
- ranList = []
- while len(ranList) < 3:
- x = random.randint(6,15)
- y = abs(random.gauss(30,50))
- z = random.randint(1,30)
- if len(ranList) == 0:
- ranList.append(x)
- if 2 < y / ranList[0] and y / ranList[0] < 20:
- if len(ranList) == 1:
- ranList.append(y)
- if 0.5 < z / ranList[0] and z / ranList[0] < 2:
- if len(ranList) == 2:
- ranList.append(z)
- # if len(ranList) == 3:
- # break
- print ranList
- return ranList
- def create_plane():
- plane = pm.nurbsPlane(ch=1, d=3, patchesV=length, p=(0, 0, 0), patchesU=width, w=120, ax=(0, 1, 0), lr=1)
- return plane
- def create_hair():
- pm.mel.createHair(length, width, 10, 0, 0, 0, 0, 5, 0, 2, 1, 1);
- for i in range(1, length * width * 2, 2):
- pm.delete('curve' + str(i))
- pm.delete('nucleus1', 'hairSystem1', 'hairSystem1OutputCurves');
- hairs = pm.ls('hairSystem1Follicles', dag = True)[1::2]
- return hairs
- def create_one_building(ranList, i, buildingGrp):
- building = pm.polyCube(d= ranList[0], h= ranList[1], w= ranList[2])
- pm.move(0,ranList[1]/2,0)
- #snap building to hair with pointConstraint
- michael = pm.pointConstraint(i, building[0], skip='y')
- pm.delete(michael)
- pm.parent(building[0], buildingGrp)
- def create():
- buildingGrp = pm.group(name = 'buildingGrp')
- plane = create_plane()
- hairs = create_hair()
- for current_hair in hairs:
- ranList = random_size()
- print ranList
- create_one_building(ranList, current_hair, buildingGrp)
- pm.parent(plane[0], buildingGrp)
- pm.delete('hairSystem1Follicles')
- pm.select(cl = True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement