So basically this is my base script for the circles
import maya.cmds as mc
import math
import random
def cubeSphere():
myCubeList =[]
for each in range(2000):
myCube = mc.polyCube(name="myCube")
mc.move (10 , 0 , 0 , myCube[0])
---------------------------------------#
as shown, mc.move helps me to get a radius of 10 after I apply the rotation command below since it will allow the cubes to move away from the world pivot
rot= random.uniform (0,360)
---------------------------------------#
the random unifrom from 0, 360 allows the cubes to appear between 0 to 360, since I have about 3000 cubes, the cubes would overlay and form a basic circle. Well since I want a sphere instead of a circle, I would go for the 3D instead thus a base which is my Y is needed and Z axis is needed to form a sphere around the base in a range of 3000 cubes. And since the pivot is world axis, I needed another dimension to make it a sphere, thus I had to use Z axis or else using X axis would just form a circle on a plane
mc.rotate ((0),(each*rot) ,(each) , myCube[0], pivot =(0,0,0))
------------------------------------------#
then the commands below basically helps me in randoming the size and height of the cubes
ranSize = random.uniform (0.01,1)
ranHeight = random.uniform (1,3 )
mc.scale ( ranHeight, ranSize , ranSize)
myCubeList.append(myCube[0])
return myCubeList
myCubeList = cubeSphere()
print myCubeList
No comments:
Post a Comment