Fomal Posted April 17, 2008 Share Posted April 17, 2008 (edited) Hi, I'm currently working on some sort of lightrig based on Impact, getting the info from DOPS. I managed to let the number of shards (prim groups) create an x number of lights and position them according to the position of the shard. As the shards hit the ground the lights shift into the right position and light up. All works fine and i'm able to create as many shards I want without having to link anything. A small test can be found here: CLICK This is done with a small python script that grabs the no. of primitive groups in a node and create a number of lights based on that integer. Since the lightnumber and groupnumber are the same i'm able to redirect the chop data directly onto the right light. All in one go. The code I created for this: import hou,os,string,sys number_groups1 = hou.node("obj/fractured_object/nogroups").parm("nogroups").evalAsInt() 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\")") Now i'm trying to do the same with particles. I've already created a small dop network that emits particles based on the DOP's processed data (through chops). I still link them manually but would like to have that the same as with the lights. So that the chop data automatically finds it's way to the right parameter. (in this case the location coordinates and activation parameter) Problem is that this asks for the creation of an 'X' number of pop networks with a bunch of nodes within them. So i'm trying to figure out how to do this in python. Is it better to first create the entire tree and copy this over based on the no. of primitive groups (with the same processed number in the end for linking everything up) or would it be better to create every node independent from each other based on the no. of primitve groups and link them up later? Problem i ran into was that I can't figure out how to duplicate a network (obj/geo/popnet/bla) of nodes based on the no of primitive groups. I tried the hou.copyNodesTo function and hou.Node.copyNetworkBox method, both gave me no results: File "/opt/houdini/houdini/scripts/python/hou.py", line 8689, in copyNetworkBox return _hou.Node_copyNetworkBox(*args) TypeError: in method 'Node_copyNetworkBox', argument 2 of type 'HOM_NetworkBox &' I'm failry new to Python and hope someone can help or point me in the right direction. Cheers Coen Edited April 17, 2008 by Fomal Quote Link to comment Share on other sites More sharing options...
symek Posted April 17, 2008 Share Posted April 17, 2008 (edited) Hi,I'm currently working on some sort of lightrig based on Impact, getting the info from DOPS. I managed to let the number of shards (prim groups) create an x number of lights and position them according to the position of the shard. As the shards hit the ground the lights shift into the right position and light up. All works fine and i'm able to create as many shards I want without having to link anything. A small test can be found here: CLICK This is done with a small python script that grabs the no. of primitive groups in a node and create a number of lights based on that integer. Since the lightnumber and groupnumber are the same i'm able to redirect the chop data directly onto the right light. All in one go. The code I created for this: import hou,os,string,sys number_groups1 = hou.node("obj/fractured_object/nogroups").parm("nogroups").evalAsInt() 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\")") Now i'm trying to do the same with particles. I've already created a small dop network that emits particles based on the DOP's processed data (through chops). I still link them manually but would like to have that the same as with the lights. So that the chop data automatically finds it's way to the right parameter. (in this case the location coordinates and activation parameter) Problem is that this asks for the creation of an 'X' number of pop networks with a bunch of nodes within them. So i'm trying to figure out how to do this in python. Is it better to first create the entire tree and copy this over based on the no. of primitive groups (with the same processed number in the end for linking everything up) or would it be better to create every node independent from each other based on the no. of primitve groups and link them up later? Problem i ran into was that I can't figure out how to duplicate a network (obj/geo/popnet/bla) of nodes based on the no of primitive groups. I tried the hou.copyNodesTo function and hou.Node.copyNetworkBox method, both gave me no results: File "/opt/houdini/houdini/scripts/python/hou.py", line 8689, in copyNetworkBox return _hou.Node_copyNetworkBox(*args) TypeError: in method 'Node_copyNetworkBox', argument 2 of type 'HOM_NetworkBox &' I'm failry new to Python and hope someone can help or point me in the right direction. Cheers Coen I don't remember why but I think you can't copy POP network as a whole. I can't look closer on your problem, not even sure if I understand correctly your goal (sorry for that) but generally your route appears to be little crazy (I like crazy guys!) since most such a tasks can be accomplished with some kind of instancing. You can easily: - instance lights onto a points/particles taken from DOPs or POP simulations with varying every single light parameter - instance HDA which can consists with lights besides of geometry, shaders what so ever. In the tutorial section of SESI site there is a whole Siggraph presentation about new features of Houdini 9: http://www.sidefx.com/index.php?option=com...&Itemid=264 One of them shows (with examples) how to achieve similar effect. Hope this helps, Simon. Edited April 17, 2008 by SYmek Quote Link to comment Share on other sites More sharing options...
Fomal Posted April 17, 2008 Author Share Posted April 17, 2008 (edited) I don't remember why but I think you can't copy POP network as a whole. I can't look closer on your problem, not even sure if I understand correctly your goal (sorry for that) but generally your route appears to be little crazy (I like crazy guys!) since most such a tasks can be accomplished with some kind of instancing. You can easily:- instance lights onto a points/particles taken from DOPs or POP simulations with varying every single light parameter - instance HDA which can consists with lights besides of geometry, shaders what so ever. In the tutorial section of SESI site there is a whole Siggraph presentation about new features of Houdini 9: http://www.sidefx.com/index.php?option=com...&Itemid=264 One of them shows (with examples) how to achieve similar effect. Hope this helps, Simon. Hi Simon, Thanks for the help. I'll take a look at what you recommended, I also realize my story might be a bit crazy but the main goal is to get a number of particle emitters (+ network,pop networks) onto a DOP simulation, using that data for triggering and transformations. (that's why I pumped it through a chop network, so i have something to play around with) And make sure that everything updates when something changes (for example the number of primitive groups), i.c.w. the chop data. I found out that python was really convenient to create a bunch of lights based on primitive groups and parent these automatically using python as well. To get chop data to the right light (for triggering) was done by a simple for loop. I thought pulling the same trick for pop networks would be the same but it is different. I'll let you know how it turns out.. Cheers Coen Edited April 17, 2008 by Fomal Quote Link to comment Share on other sites More sharing options...
symek Posted April 17, 2008 Share Posted April 17, 2008 (edited) Hi Simon,Thanks for the help. I'll take a look at what you recommended, I also realize my story might be a bit crazy but the main goal is to get a number of particle emitters (+ network,pop networks) onto a DOP simulation, using that data for triggering and transformations. (that's why I pumped it through a chop network, so i have something to play around with) And make sure that everything updates when something changes (for example the number of primitive groups), i.c.w. the chop data. I found out that python was really convenient to create a bunch of lights based on primitive groups and parent these automatically using python as well. To get chop data to the right light (for triggering) was done by a simple for loop. I thought pulling the same trick for pop networks would be the same but it is different. I'll let you know how it turns out.. Cheers Coen Well, if it works it works I was once so much pissed off by the slowness of a TimeFilterCOP that I made similar setup to yours and instead of iterate through some frame range in VEX I was creating on the fly a composition with a number of layers and delayed input. It worked much faster then VEX one As a side note I don't see why you can't trigger lights with CHOPS using instancing, it's perfectly doable but just do what you feel is good Good luck! Edited April 17, 2008 by SYmek Quote Link to comment Share on other sites More sharing options...
Fomal Posted April 17, 2008 Author Share Posted April 17, 2008 (edited) I'll look into the instancing with CHOPS. Didn't know that was doable! But off course i should have know better, everything's possible in houdini. Just as you said. I also found a way of copying entire network trees in houdini using python with: hou.hscript('opcp /*/* /*/*_copy'), but it's a bit messy. Cheers Coen Edited April 18, 2008 by Fomal Quote Link to comment Share on other sites More sharing options...
Fomal Posted April 18, 2008 Author Share Posted April 18, 2008 (edited) For anyone who's interested, found out how to copy popnetworks and set the parameters based on chop channels and the no of shards. Thanks to the help of a friend of mine. I know it could have been done with something like the forloop sop, copy sop or instancing but the goal was to get some Python experience as well. So here we go. A wayyy too long script but it does the job. ##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() #LINK TO MASTER CONTROL popscale = hou.node('/obj/fractured_object/mcontrol').parm('scale').eval() popgravity = hou.node('/obj/fractured_object/mcontrol').parm('gravity').eval() poplife = hou.node('/obj/fractured_object/mcontrol').parm('poplife').eval() popvar = hou.node('/obj/fractured_object/mcontrol').parm('popvar').eval() popcol = hou.node('/obj/fractured_object/mcontrol').parm('colgeo').eval() birth = hou.node('/obj/fractured_object/mcontrol').parm('birthrate').eval() traillength = hou.node('/obj/fractured_object/mcontrol').parm('trail').eval() #SET PARAMETERS gravity.parm('forcey').set(popgravity) collision.parm('soppath').set(popcol) 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(popscale) emitter.parm('life').set(poplife) emitter.parm('lifevar').set(popvar) emitter.parm('constantrate').set(birth) trail.parm('length').set(traillength) ##DUPLICATE POPNETWORK FOR EVERY GROUP for i in range(1, number_groups1): hou.hscript('opcp /obj/geo1 /obj/geo+i') Varsss = "geo"+str(i+1) hou.node("obj/"+Varsss+"/popnet1/location1").parm("locx").setExpression("chop(\"../../../chopnet1/Out_Position/group_"+str(i+1)+":positionx\")") hou.node("obj/"+Varsss+"/popnet1/location1").parm("locy").setExpression("chop(\"../../../chopnet1/Out_Position/group_"+str(i+1)+":positiony\")+0.5") hou.node("obj/"+Varsss+"/popnet1/location1").parm("locz").setExpression("chop(\"../../../chopnet1/Out_Position/group_"+str(i+1)+":positionz\")") hou.node("obj/"+Varsss+"/popnet1/location1").parm("constantactivate").setExpression("chop(\"../../../chopnet1/Out_Part/group_"+str(i+1)+":impulse\")") ##DELETE ORIGINAL POPNETWORK hou.node('/obj/geo1').destroy() Had a lot of trouble finding the right python function for copying the networks. So used the hou.hscript function instead. With a dirty hack I was able to get the right group number and copy the chop data on it. Does anyone have any idea when Python is going to be fully integrated? I noticed that a lot of chop functionality is missing.. As well as good help with some functions. Sometimes I had no clue how to interpret them. If anyone's interested i can upload the .hip file as well. Edited April 20, 2008 by Fomal Quote Link to comment Share on other sites More sharing options...
com48 Posted April 18, 2008 Share Posted April 18, 2008 (edited) yea it's a really dirty little way to get around it. the problem is that the old Hscript functions don't seem to be implemented in python for certain areas of houdini. (Chops, takes, ect ect). that's why you need to use the hscript function which is far from ideal. greetz Lars Edited April 19, 2008 by com48 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.