The Python script
##LOAD ENVIRONMENT
import hou,os,string,sys
##CREATE VARIABLE OUT OF PRIMITVE GROUPS
number_groups1 = hou.node("obj/fractured_object/nogroups").parm("nogroups").evalAsInt()
##CREATE LIGHT FOR EVERY GROUP AND SET PARAMETERS
for i in range(0, number_groups1):
tempvar = hou.node("/obj").createNode("hlight")
tempvar.parm("l_tx").setExpression("chop(\"../chopnet1/Out_Position/group_"+str(i)+":positionx\")")
tempvar.parm("l_ty").setExpression("chop(\"../chopnet1/Out_Position/group_"+str(i)+":positiony\")+0.5")
tempvar.parm("l_tz").setExpression("chop(\"../chopnet1/Out_Position/group_"+str(i)+":positionz\")")
tempvar.parm("light_intensity").setExpression("chop(\"../chopnet1/Out_Intens/group_"+str(i)+":impulse\")")
tempvar.moveToGoodPosition()
##CREATE POPNETWORK
geo = hou.node("/obj").createNode('geo')
popnet = geo.createNode('popnet')
emitter = popnet.createNode('location')
gravity = popnet.createNode('force')
collision = popnet.createNode('collision')
attribute = geo.createNode('attribcreate')
point = geo.createNode('point')
copy = geo.createNode('copy')
trail = geo.createNode('trail')
transform = geo.createNode('xform')
sphere = geo.createNode('sphere')
gravity.setFirstInput(emitter)
collision.setFirstInput(gravity)
attribute.setFirstInput(popnet)
point.setFirstInput(attribute)
transform.setFirstInput(sphere)
copy.setFirstInput(transform)
copy.setNextInput(point)
trail.setFirstInput(copy)
##SET POPNETWORK
trail.setDisplayFlag(True)
trail.setRenderFlag(True)
collision.setDisplayFlag(True)
collision.setRenderFlag(True)
collision.setTemplateFlag(False)
##DESTROY FILE NODE
hou.node('/obj/geo1/file1').destroy()
#SET PARAMETERS
gravity.parm('forcey').set('-5')
collision.parm('soppath').set('/obj/Grid/grid1')
attribute.parm('name').set('pscale')
attribute.parm('varname').set('pscale')
attribute.parm('value1').setExpression('fit(abs($VZ),0,1,0,0.5)')
transform.parm('scale').set('0.07')
emitter.parm('life').set('5')
emitter.parm('lifevar').set('2')
##DUPLICATE POPNETWORK FOR EVERY GROUP
for i in range(1, number_groups1):
hou.hscript('opcp /obj/geo1 /obj/geo+i')
LarsAwsomeVars = "geo"+str(i+1)
hou.node("obj/"+LarsAwsomeVars+"/popnet1/location1").parm("locx").setExpression("chop(\"../../../chopnet1/Out_Position/group_"+str(i+1)+":positionx\")")
hou.node("obj/"+LarsAwsomeVars+"/popnet1/location1").parm("locy").setExpression("chop(\"../../../chopnet1/Out_Position/group_"+str(i+1)+":positiony\")+0.5")
hou.node("obj/"+LarsAwsomeVars+"/popnet1/location1").parm("locz").setExpression("chop(\"../../../chopnet1/Out_Position/group_"+str(i+1)+":positionz\")")
hou.node("obj/"+LarsAwsomeVars+"/popnet1/location1").parm("constantactivate").setExpression("chop(\"../../../chopnet1/Out_Part/group_"+str(i+1)+":impulse\")")
##DELETE ORIGINAL POPNETWORK
hou.node('/obj/geo1').destroy()
No comments:
Post a Comment