Contact Information

Email - Duylinh.Nguyen@gmail.com
Google Voice - 415-613-2177

Tuesday, October 11, 2011

Solar System Generator using Python

This is a script I created after learning Python for Maya. It
actually proved to be fairly easy especially knowing MEL prior
to it. I decided to learn the language due to students struggling
with their 3d Scripting class. Sadly, the white spacing at the
left doesn't want to copy over, so if you plan on using the script,
make sure to add the proper white spacing to the script.

################################################################
##Script: SolarSytemGenerator.py
##Scripted By: Duylinh Nguyen
##Description: Generates a Solar System with user inputs
##Instructions: Select Entire Script and press Ctrl+Enter
##Type SolarSysGen() in command bar to execute script.
################################################################

#imporint maya commands and mel
import maya.cmds as cmds
import maya.mel as mel




#Declaring the global variables
sel = 'sel[]'
#star global variables
starName = 'star'
starRad = 1.0
starPosX = 0.0
starPosY = 0.0
starPosZ = 0.0
#sat global variables
sat = 'sat[]'
satName = 'sat'
satRad = 1.0
satRotX = 0.0
satRotY = 0.0
satRotZ = 0.0
satRotSpeed = 0.0
satOrbitScaleX = 1.0
satOrbitScaleZ = 1.0
satOrbitRotX = 0.0
satOrbitRotY = 0.0
satOrbitRotZ = 0.0
satOrbitSpeed = 0.0
#background stars variables
BGSphereName = 'starrySky'
BGSphereRad = 1.0
BGStarsAmount = 100.0
#asteroid belt variables
astBeltName = 'asteroidBelt'
astBeltScaleX = 1.0
astBeltScaleZ = 1.0
astBeltSecRad = 0.5
astBeltRotX = 0.0
astBeltRotY = 0.0
astBeltRotZ = 0.0

#defs (aka functions) are used to have a set of actions stored within a section. This
#allows you to do repetative tasks easier.

#The main interface window was placed into a def so the user simply needs to call it
#instead of always having to run the full script over and over.

#Main interface window to create solar system
def SolarSysGen():
#Checks to see if the window exists. If it does, close it and create a new one.
if cmds.window ( "SSGWindow", exists = True ):
cmds.deleteUI ( "SSGWindow", window = True )

#Creates the window
SSGWindow = cmds.window( "SSGWindow", title = "Solar System Generator", wh = ( 380, 200 ) )
#The layout used for the window
cmds.rowColumnLayout ( numberOfColumns = 1, columnWidth = ( 1, 370 ) )
#Create star button that calls the CreateStarWindow def
cmds.button ( label = "Create Star", command = "CreateStarWindow()" )
#Separators are used to either fill in gaps or give you extra space between your layout controls
cmds.separator ( height = 20, style = "none" )
#Descriptive text to tell the user what they need to do
cmds.text ( align = "center", font = "boldLabelFont", label = "Select One Star" )
#Create satellite button that calls the CreateSatelliteWindow def
cmds.button ( label = "Create Satellite", command = "CreateSatelliteWindow()" )
cmds.separator ( height = 20, style = "none" )
cmds.text ( align = "center", font = "boldLabelFont" , label = "Select One Star or Satellite" )
#Create asteroid belt button that calls the createAsterBeltWindow def
cmds.button ( label = "Create Asteroid Belt", command = "createAsterBeltWindow ()" )
cmds.separator ( height = 20, style = "none" )
#Create star background button that calls the createBGSStarWindow
cmds.button ( label = "Create Star Background", command = "createBGStarsWindow ()" )
#displays the window
cmds.showWindow ( SSGWindow )


#this def is used to display the CreateStarWindow
def CreateStarWindow () :

#adding global in front of the variable allows you to call the global variables declared in the
#start of the script. If global is not added to the front of these variables, they will be
#considered local instead. Global variables allow you to use these variables across multiple
#defs and not just within the function. Only declare global if you know you need to use it
#in multiple defs.

global starName
global starRad
global starPosX
global starPosY
global starPosZ

#checks if any of the sub windows are opened. If so, it closes them and spawns a new one
if cmds.window( "satWindow", exists = True):
cmds.deleteUI ("satWindow",window = True)
if cmds.window ("ErPlWindow", exists = True):
cmds.deleteUI ("ErPlWindow", window = True)
if cmds.window( "StarWindow", exists = True ):
cmds.deleteUI( "StarWindow", window = True )
if cmds.window( "bgStarsWin", exists = True ):
cmds.deleteUI( "bgStarsWin", window = True )
if cmds.window( "astBeltWin", exists = True ):
cmds.deleteUI( "astBeltWin", window = True )

#creates the window
StarWindow = cmds.window( "StarWindow", title = "Create Star", wh = (300,200))
cmds.columnLayout ()
#control that prompts the user for the name and the button calls the CreateStar def
cmds.textFieldButtonGrp ( starName, label = 'Star Name', text = starName, buttonLabel = 'Create Star', buttonCommand = 'CreateStar()')
#sliders that control attributes on the object
starPosX = cmds.floatSliderGrp ( label = 'Position X', field=True, minValue=-100.0, maxValue=100.0, fieldMinValue=-100.0, fieldMaxValue=100.0, value=0.0 )
starPosY = cmds.floatSliderGrp ( label = 'Position Y', field=True, minValue=-100.0, maxValue=100.0, fieldMinValue=-100.0, fieldMaxValue=100.0, value=0.0 )
starPosZ = cmds.floatSliderGrp ( label = 'Position Z', field=True, minValue=-100.0, maxValue=100.0, fieldMinValue=-100.0, fieldMaxValue=100.0, value=0.0 )
starRad = cmds.floatSliderGrp ( label = 'Radius' , field = True, minValue=-100.0, maxValue=100.0, fieldMinValue=-100.0, fieldMaxValue=100.0, value=1.0 )
cmds.showWindow (StarWindow)

def CreateStar () :
#these variables were used in both the CreateStarWindow and CreateStar defs, hence being global
global starName
global starRad
global starPosX
global starPosY
global starPosZ

#this finds what the user typed and stores it into the starNameQuery
starNameQuery = cmds.textFieldButtonGrp ( starName, query = True, text = True)
#Creates a polygon sphere, gives it the name the user inputted and assigns it to the variable Star. Star is an array
Star = cmds.polySphere ( r = 1, sx = 20, sy = 20, ax = (0, 1, 0), cuv = 2, ch = 1, name = starNameQuery)
#connects the slider with the attribute
#Star[0] = grabbing the first name out of the list. Every object by default has 2.
#ie. Star[0] = Sun , Star[1] = SunShape
#The + sign is used to attach text after the variable
#ie. Star[0] + "translateX" = Sun.translateX
cmds.connectControl ( starPosX, Star[0] + ".translateX")
cmds.connectControl ( starPosY, Star[0] + ".translateY")
cmds.connectControl ( starPosZ, Star[0] + ".translateZ")
#connectControl can control multiple attributes at the same time. Just make sure to place a comma afterwords.
cmds.connectControl ( starRad, Star[0] + ".scaleX", Star[0] + ".scaleY", Star[0] + ".scaleZ")



#Creates the sat and Orbit
def CreateSatelliteWindow () :
#declaring global variables that will be used in the CreateSatelliteWindow and CreateSat defs
global satName
global satRad
global satRotX
global satRotY
global satRotZ
global satRotSpeed
global satOrbitScaleX
global satOrbitScaleZ
global satOrbitRotX
global satOrbitRotY
global satOrbitRotZ
global sel
global satOrbitSpeed

#checks to see what objects are selected
sel = cmds.ls ( sl = True )
selObj = cmds.listRelatives ( cmds.listRelatives( parent = True ), parent = True )
#checks to see if the type of object that is selected is a mesh
if cmds.objectType ( cmds.listRelatives ( sel[0] ) ) == 'mesh':
selSize = len(sel)
#checks to see if only one object is selected
if selSize == 1:
if cmds.window( "satWindow", exists = True):
cmds.deleteUI ("satWindow",window = True)
if cmds.window ("ErPlWindow", exists = True):
cmds.deleteUI ("ErPlWindow", window = True)
if cmds.window( "StarWindow", exists = True ):
cmds.deleteUI( "StarWindow", window = True )
if cmds.window( "bgStarsWin", exists = True ):
cmds.deleteUI( "bgStarsWin", window = True )
if cmds.window( "astBeltWin", exists = True ):
cmds.deleteUI( "astBeltWin", window = True )

satWindow = cmds.window ("sattWindow",title = "Create Satellite")
cmds.columnLayout ()
cmds.textFieldButtonGrp ( satName, label = 'Satellite Name', text = satName, buttonLabel = 'Create Satellite', buttonCommand = 'CreateSat()')
satOrbitScaleX = cmds.floatSliderGrp ( label = 'Orbit Scale X', field = True, minValue = -100.0, maxValue = 100.0, fieldMinValue = -100.0, fieldMaxValue = 100.0, value = 0.0 )
satOrbitScaleZ = cmds.floatSliderGrp ( label = 'Orbit Scale Z', field = True, minValue = -100.0, maxValue = 100.0, fieldMinValue = -100.0, fieldMaxValue = 100.0, value = 0.0 )
satOrbitRotX = cmds.floatSliderGrp ( label = 'Orbit Rotate X', field = True, minValue = -100.0, maxValue = 100.0, fieldMinValue = -100.0, fieldMaxValue = 100.0, value = 0.0 )
satOrbitRotY = cmds.floatSliderGrp ( label = 'Orbit Rotate Y', field = True, minValue = -100.0, maxValue = 100.0, fieldMinValue = -100.0, fieldMaxValue = 100.0, value = 0.0 )
satOrbitRotZ = cmds.floatSliderGrp ( label = 'Orbit Rotate Z', field = True, minValue = -100.0, maxValue = 100.0, fieldMinValue = -100.0, fieldMaxValue = 100.0, value = 0.0 )
satRad = cmds.floatSliderGrp ( label = 'Satellite Radius' , field = True, minValue = -100.0, maxValue=100.0, fieldMinValue = -100.0, fieldMaxValue = 100.0, value = 1.0 )
satRotX = cmds.floatSliderGrp ( label = 'Satellite Rotate X' , field = True, minValue = -100.0, maxValue=100.0, fieldMinValue = -100.0, fieldMaxValue = 100.0, value = 1.0 )
satRotZ = cmds.floatSliderGrp ( label = 'Satellite Rotate Z' , field = True, minValue = -100.0, maxValue=100.0, fieldMinValue = -100.0, fieldMaxValue = 100.0, value = 1.0 )
satRotSpeed = cmds.floatSliderGrp ( label = 'Satellite Rotate Speed' , field = True, minValue = -10000.0, maxValue=10000.0, fieldMinValue = -10000.0, fieldMaxValue = 10000.0, value = 0.0 )
satOrbitSpeed = cmds.floatSliderGrp ( label = 'Orbit Speed' , field = True, minValue = 0, maxValue=100, fieldMinValue = 0, fieldMaxValue = 100, value = 0.0 )
cmds.showWindow ( satWindow )

#if there are more than one object selected, an error window will pop up notifying the user of their error
else:
if cmds.window( "satWindow", exists = True):
cmds.deleteUI ("satWindow",window = True)
if cmds.window ("ErPlWindow", exists = True):
cmds.deleteUI ("ErPlWindow", window = True)
if cmds.window( "StarWindow", exists = True ):
cmds.deleteUI( "StarWindow", window = True )
if cmds.window( "bgStarsWin", exists = True ):
cmds.deleteUI( "bgStarsWin", window = True )
if cmds.window( "astBeltWin", exists = True ):
cmds.deleteUI( "astBeltWin", window = True )
ErPlWindow = cmds.window ( "ErPlWindow",title = "Error" )
cmds.rowColumnLayout (numberOfColumns = 1, columnWidth = ( 1, 370 ) )
cmds.text ( label="Error: Too many objects selected" )
cmds.showWindow ( ErPlWindow)

#if nothing is selected, it will error and nothing will pop up
else:
#print command only pops up in the script editor
print "error: nothing is selected"

def CreateSat () :

global sel
global satName
global satRad
global satRotX
global satRotY
global satRotZ
global satRotSpeed
global satOrbitScaleX
global satOrbitScaleZ
global satOrbitRotX
global satOrbitRotY
global satOrbitRotZ
global satOrbitSpeed

#finds the name the user input
satNameQuery = cmds.textFieldButtonGrp ( satName, query = True, text = True)
sat = cmds.polySphere ( r = 1, sx = 20, sy = 20, ax = (0, 1, 0), cuv = 2, ch = 1, name = satNameQuery)
#make note how single quotes ' and double quotes " can be interchanged.
#creates a new variable to name the orbit based on the satellite name
satOrbitName = sat[0] + 'Orbit'
#creates the orbit ring for the satellite
satOrbit = cmds.circle ( c = (0, 0, 0), nr = ( 0, 1, 0), sw = 360, r = 1, d = 3, ut = 0, tol = 0.00155, s = 8, ch = 1, name = satOrbitName)
#locator is used to allow the satellite (child) to rotate and move freely if need be
#this also allows the satellite to rotate around its own local axis.
satLoc = cmds.spaceLocator ( p = (0,0,0))
#parents the satellite to the locator
cmds.parent ( sat [0], satLoc [0])
#attaches the satellite to the motionpath. stu = start time U, etu = end time U, turnning off follow allows for the object to rotate freely
orbitPath = cmds.pathAnimation(satLoc[0], curve=satOrbitName, fractionMode = True, stu = 0, etu = 100, follow = False )
#flattens the tangent so there are no ease in and ease outs on the motionpath
cmds.keyTangent ( orbitPath + "_uValue", itt = "linear", ott = "linear")
#adds an attribute to allow the user to input the rotation speed of the satellite
cmds.addAttr ( sat[0], shortName = "rs", longName = "rotateSpeed", defaultValue = 0.0, minValue = -10000, maxValue = 10000, k = True)
#adds a point constraint to the object that the satellite was created for
cmds.pointConstraint ( sel [0], satOrbit [0])
#renames the motion path
cmds.rename ('motionPath1', "" + sat[0] + "moPath")
#mel.eval allows you to call MEL scripts that are not available in Python such as the CBDeleteConnection. This allows you to break
#connections for any attribute listed.
#the .u attribute controls the location on the motion path the object is on.
mel.eval ("source channelBoxCommand; CBdeleteConnection " + sat[0] + "moPath.u;")
#this gives an attribute to the object that controls the speed of which the planet orbits the object
#setting k or key = True allows you to see the attribute on the object.
#dv = default value, sets what value you want it to start with
cmds.addAttr (sat[0], ln = "speed", at = "float", k = True, min = 0, dv =1.0)
cmds.connectControl ( satOrbitSpeed, sat[0] + ".speed")
cmds.connectControl ( satOrbitScaleX, satOrbitName + ".scaleX")
cmds.connectControl ( satOrbitScaleZ, satOrbitName + ".scaleZ")
cmds.connectControl ( satOrbitRotX, satOrbitName + ".rotateX")
cmds.connectControl ( satOrbitRotY, satOrbitName + ".rotateY")
cmds.connectControl ( satOrbitRotZ, satOrbitName + ".rotateZ")
cmds.connectControl ( satRotX, satLoc[0] + ".rotateX")
cmds.connectControl ( satRotZ, satLoc[0] + ".rotateZ")
cmds.connectControl ( satRad, sat[0] + ".scaleX", sat[0] + ".scaleY", sat[0] + ".scaleZ")
cmds.connectControl ( satRotSpeed, sat[0] + ".rotateSpeed")
cmds.expression ( s = "" + sat[0] + ".rotateY = " + sat[0] + ".rotateY - " + sat[0] + ".rotateSpeed")
cmds.expression ( s = "" + sat[0] + "moPath.u = ( frame % (" + sat[0] + ".speed +1)) /" + sat[0] + ".speed;")


def createBGStarsWindow ():
global BGSphereName
global BGSphereRad
global BGStarsAmount

if cmds.window( "satWindow", exists = True):
cmds.deleteUI ("satWindow",window = True)
if cmds.window ("ErPlWindow", exists = True):
cmds.deleteUI ("ErPlWindow", window = True)
if cmds.window( "StarWindow", exists = True ):
cmds.deleteUI( "StarWindow", window = True )
if cmds.window( "bgStarsWin", exists = True ):
cmds.deleteUI( "bgStarsWin", window = True )
if cmds.window( "astBeltWin", exists = True ):
cmds.deleteUI( "astBeltWin", window = True )

bgStarsWin = cmds.window ("bgStarsWin",title = "Create Star Background")
cmds.columnLayout ()
cmds.textFieldButtonGrp ( BGSphereName, label = 'Background Stars Name', text = BGSphereName, buttonLabel = 'Create Stars Background', buttonCommand = 'createBGStars ()')
BGSphereRad = cmds.floatSliderGrp ( label = 'BG Stars Sphere Radius', field = True, minValue = 0, maxValue = 1000.0, fieldMinValue = 0, fieldMaxValue = 1000.0, value = 1 )
BGStarsAmount = cmds.floatSliderGrp ( label = 'Amount of Stars', field = True, minValue = 1, maxValue = 1000.0, fieldMinValue = 1, fieldMaxValue = 1000.0, value = 100.0 )
cmds.showWindow ( "bgStarsWin")

def createBGStars ():
global BGSphereName
global BGSphereRad
global BGStarsAmount

BGSphere = cmds.polySphere ( r = 1, sx = 20, sy = 20, ax = (0,1,0), cuv = 2, ch = 1, name = BGSphereName)
BGSEmit = cmds.emitter ( BGSphere [0], type = "surface", r = 100, sro = 0, nuv = 0, cye = "none", cyi = 1, spd = 1, srn = 0, nsp = 1, tsp = 0, mxd = 0, mnd = 0, dx = 0, dy = 0, dz = 0, sp = 0, name = BGSphere[0] + "Emit")
BGSPart = cmds.particle (name = BGSphere[0] + "Part")
cmds.connectDynamic ( BGSPart[0], em = BGSEmit)
cmds.connectControl ( BGSphereRad, BGSphere[0] + ".scaleX", BGSphere[0] + ".scaleY", BGSphere[0] + ".scaleZ")
cmds.connectControl ( BGStarsAmount, BGSEmit[1] + ".rate")
print BGSEmit
print BGSPart
cmds.setAttr ( BGSphere[0] + ".template", 1)
cmds.setAttr ( BGSphere[0] + "Shape.primaryVisibility", 0)
cmds.setAttr ( BGSphere[0] + "Shape.motionBlur", 0)
cmds.setAttr ( BGSphere[0] + "Shape.receiveShadows", 0)
cmds.setAttr ( BGSphere[0] + "Shape.castsShadows", 0)
cmds.setAttr ( BGSphere[0] + "Shape.smoothShading", 0)
cmds.setAttr ( BGSphere[0] + "Shape.visibleInReflections", 0)
cmds.setAttr ( BGSphere[0] + "Shape.visibleInRefractions", 0)
cmds.setAttr ( BGSphere[0] + "Shape.doubleSided", 0)
cmds.setAttr ( BGSPart[1] + ".particleRenderType", 7)
cmds.setAttr ( BGSPart[1] + ".lifespanMode", 2)
cmds.setAttr ( BGSPart[1] + ".lifespan", 2)
cmds.addAttr ( BGSPart[1], internalSet = True, ln = "radius", at = "float", min = 0, max = 10, dv = 0.1)
cmds.addAttr ( BGSPart[1], ln = "radiusPP", dt = "doubleArray")
cmds.addAttr ( BGSPart[1], ln = "radiusPP0", dt = "doubleArray")
cmds.setAttr ( BGSPart[1] + ".radius", .05)
cmds.dynExpression ( BGSPart[1], s = "" + BGSPart[1] + ".radiusPP = rand (.03, .1)", c = True)


def createAsterBeltWindow ():
global sel
global astBeltName
global astBeltScaleX
global astBeltScaleZ
global astBeltSecRad
global astBeltRotX
global astBeltRotY
global astBeltRotZ
#checks to see if the object is selected
sel = cmds.ls ( sl = True )
selObj = cmds.listRelatives ( cmds.listRelatives( parent = True ), parent = True )
if cmds.objectType ( cmds.listRelatives ( sel[0] ) ) == 'mesh':
selSize = len(sel)
if selSize == 1:
if cmds.window( "satWindow", exists = True):
cmds.deleteUI ("satWindow",window = True)
if cmds.window ("ErPlWindow", exists = True):
cmds.deleteUI ("ErPlWindow", window = True)
if cmds.window( "StarWindow", exists = True ):
cmds.deleteUI( "StarWindow", window = True )
if cmds.window( "bgStarsWin", exists = True ):
cmds.deleteUI( "bgStarsWin", window = True )
if cmds.window( "astBeltWin", exists = True ):
cmds.deleteUI( "astBeltWin", window = True )

astBeltWin = cmds.window ("astBeltWin",title = "Create Asteroid Belt")
cmds.columnLayout ()
cmds.textFieldButtonGrp ( astBeltName, label = 'Asteroid Belt Name', text = astBeltName, buttonLabel = 'Create Asteroid Belt', buttonCommand = 'createAsterBelt()')
astBeltScaleX = cmds.floatSliderGrp ( label = 'Asteroid Belt Scale X', field = True, minValue = 1, maxValue = 100.0, fieldMinValue = 1, fieldMaxValue = 100.0, value = 1.0 )
astBeltScaleZ = cmds.floatSliderGrp ( label = 'Asteroid Belt Scale Z', field = True, minValue = 1, maxValue = 100.0, fieldMinValue = 1, fieldMaxValue = 100.0, value = 1.0 )
astBeltRotX = cmds.floatSliderGrp ( label = 'Asteroid Belt Rotate X', field = True, minValue = -100, maxValue = 100.0, fieldMinValue = -100, fieldMaxValue = 100.0, value = 1.0 )
astBeltRotY = cmds.floatSliderGrp ( label = 'Asteroid Belt Rotate Y', field = True, minValue = -100, maxValue = 100.0, fieldMinValue = -100, fieldMaxValue = 100.0, value = 1.0 )
astBeltRotZ = cmds.floatSliderGrp ( label = 'Asteroid Belt Rotate Z', field = True, minValue = -100, maxValue = 100.0, fieldMinValue = -100, fieldMaxValue = 100.0, value = 1.0 )
astBeltSecRad = cmds.floatSliderGrp ( label = 'Asteroid Belt Section Radius', field = True, minValue = 0, maxValue = 10, fieldMinValue = 1, fieldMaxValue = 10, value = 1.0 )
cmds.showWindow ( "astBeltWin")
else:
if cmds.window( "satWindow", exists = True):
cmds.deleteUI ("satWindow",window = True)
if cmds.window ("ErPlWindow", exists = True):
cmds.deleteUI ("ErPlWindow", window = True)
if cmds.window( "StarWindow", exists = True ):
cmds.deleteUI( "StarWindow", window = True )
if cmds.window( "bgStarsWin", exists = True ):
cmds.deleteUI( "bgStarsWin", window = True )
if cmds.window( "astBeltWin", exists = True ):
cmds.deleteUI( "astBeltWin", window = True )
ErPlWindow = cmds.window ( "ErPlWindow",title = "Error" )
cmds.rowColumnLayout (numberOfColumns = 1, columnWidth = ( 1, 370 ) )
cmds.text ( label="Error: Too many objects selected" )
cmds.showWindow ( ErPlWindow)

else:
print "error"

def createAsterBelt ():
global sel
global astBeltName
global astBeltScaleX
global astBeltScaleZ
global astBeltSecRad
global astBeltRotX
global astBeltRotY
global astBeltRotZ

astBeltNameQuery = cmds.textFieldButtonGrp ( astBeltName, query = True, text = True)

asterBelt = cmds.circle (c = (0, 0, 0), nr = (0, 1, 0), sw = 360, r = 1, d = 3, ut = 0, tol = 0.00155, s = 8, ch = 1, name = astBeltNameQuery)
asterEmit = cmds.emitter ( asterBelt [0], type = "curve", r = 100, sro = 0, nuv = 0, cye = "none", cyi = 1, spd = 1, srn = 0, nsp = 1, tsp = 0, mxd = 0, mnd = 0, dx = 0, dy = 0, dz = 0, sp = 0, name = asterBelt[0] + "Emit")
asterPart = cmds.particle (name = asterBelt[0] + "Part")
cmds.connectDynamic ( asterPart [0] , em = asterEmit [0])
print sel
cmds.pointConstraint ( sel [0], asterBelt [0])
cmds.connectControl ( astBeltScaleX, asterBelt[0] + ".scaleX")
cmds.connectControl ( astBeltScaleZ, asterBelt[0] + ".scaleZ")
cmds.connectControl ( astBeltRotX, asterBelt[0] + ".rotateX")
cmds.connectControl ( astBeltRotY, asterBelt[0] + ".rotateY")
cmds.connectControl ( astBeltRotZ, asterBelt[0] + ".rotateZ")

cmds.setAttr ( asterPart[0] + ".particleRenderType", 7)
cmds.addAttr ( asterPart[1], internalSet = True, ln = "radius", at = "float", min = 0, max = 10, dv = 0.1)
cmds.addAttr ( asterPart[1], ln = "radiusPP", dt = "doubleArray")
cmds.addAttr ( asterPart[1], ln = "radiusPP0", dt = "doubleArray")
cmds.dynExpression ( asterPart[1], s = "" + asterPart[1] + ".radiusPP = rand (.01, .1)", c = True)
cmds.setKeyframe ( asterEmit[1], attribute = "rate", v = 100, time = 100)
cmds.setKeyframe ( asterEmit[1], attribute = "rate", v = 0, time = 101)
cmds.setKeyframe ( asterPart[1], attribute = "conserve", v = 1, time = 200)
cmds.setKeyframe ( asterPart[1], attribute = "conserve", v = 0.9, time = 201)
cmds.select (asterBelt[0])
mel.eval ("createCurveField")
cmds.rename ("volumeAxisField1", "" + asterBelt[0] + "AsterField")
print asterBelt[0] + "AsterField"
cmds.connectDynamic ( asterPart[0], f = "" + asterBelt [0] + "AsterField")
cmds.setAttr ( asterBelt [0] + "AsterField.trapInside", 1)
cmds.setAttr ( asterBelt [0] + "AsterField.turbulence", .05)
cmds.connectControl ( astBeltSecRad, asterBelt[0] + "AsterField.sectionRadius")

New tutorials for Maya and 3ds Max

Here are 3 new videos I've recorded based on questions my students have asked me about in Maya and 3ds Max. I will soon be posting a video that covers Substance texturing in both Maya and 3ds Max.

Multi Subobject in 3ds Max


Smoothing Normals in 3ds Max


Raytraced Shadows in Maya

Monday, October 10, 2011

Painting for Sally

This is a painting I made for Sally from memory. I made it while I was in Denmark.