Randomizing
4646 11 1- souls7ealer
- Member
- 57 posts
- Joined: 7月 2009
- Offline
Hi all. I want to randomize the value of parameters in the DOP level such as intial velocity and mass. If you shatter a sphere and make it rigidbody it takes all groups ( usually piece0, piece1 and…) into autodopnetwork. If you set initial velocity, all of your pieces will take same value. how can I assign different initial velocity for each piece?
- graham
- Member
- 1913 posts
- Joined: 11月 2006
- Offline
- Dean_19
- Member
- 319 posts
- Joined:
- Offline
Randomising velocity is quite a common need in an RBD simulation so there is also a toggle on the ‘initial state’ tab of the RBD DOP's named “Inherit velocity from point velocity”. This will take the velocity attribute present on your geometry from SOPs and apply it in the first frame of your simulation. Meaning you can use all the inherent functionality of the SOP context to generate the V attribute you want (and visualize it before simulating) and have it apply to your DOP geometry with one click of said toggle..
- souls7ealer
- Member
- 57 posts
- Joined: 7月 2009
- Offline
thank you guys, but is there any python code which I can apply it in DOP level?
I tried to creating a loop through groups but I dont know how to use hou.PrimGroup class do you know how can I use it?
Also in SOP level I created attribute named Velocity and assign a value to it but when I turned inherent velocity on in initial section I saw no different
I tried to creating a loop through groups but I dont know how to use hou.PrimGroup class do you know how can I use it?
Also in SOP level I created attribute named Velocity and assign a value to it but when I turned inherent velocity on in initial section I saw no different
- graham
- Member
- 1913 posts
- Joined: 11月 2006
- Offline
Here's an example of doing it 3 different ways.
The first way inherits the velocity from the points on the geometry. Way two doesn't inherit but uses the same method of randomizing as when point velocities were assigned in SOPs, but slightly tweaked for DOPs. The third method uses a Python DOP to do it. Really though it is basically the same as the other methods but in Python.
Personally I'd stick with probably the first method, perhaps the second. The Python method is overkill unless you have need of lots of calculations to decide on what velocity each group needs. Also, Python DOP objects have caching issues and they can get annoying.
If you really wanted to do something with primitive groups, hou.PrimGroup is pretty straightforward.
for prim_group in geo.primGroups():
for prim in prim_group.prims():
# Do something to this primitive.
If you needed to process actual geometry per piece you could just call hou.DopObject.geometry() to get the geometry for that object (group). Also you could use doptoolutils.getSourceObjectNode to look back to the original geometry container and then search for the primitive group named for the current object, but that's more work.
The first way inherits the velocity from the points on the geometry. Way two doesn't inherit but uses the same method of randomizing as when point velocities were assigned in SOPs, but slightly tweaked for DOPs. The third method uses a Python DOP to do it. Really though it is basically the same as the other methods but in Python.
Personally I'd stick with probably the first method, perhaps the second. The Python method is overkill unless you have need of lots of calculations to decide on what velocity each group needs. Also, Python DOP objects have caching issues and they can get annoying.
If you really wanted to do something with primitive groups, hou.PrimGroup is pretty straightforward.
for prim_group in geo.primGroups():
for prim in prim_group.prims():
# Do something to this primitive.
If you needed to process actual geometry per piece you could just call hou.DopObject.geometry() to get the geometry for that object (group). Also you could use doptoolutils.getSourceObjectNode to look back to the original geometry container and then search for the primitive group named for the current object, but that's more work.
Graham Thompson, Technical Artist @ Rockstar Games
- souls7ealer
- Member
- 57 posts
- Joined: 7月 2009
- Offline
- souls7ealer
- Member
- 57 posts
- Joined: 7月 2009
- Offline
- graham
- Member
- 1913 posts
- Joined: 11月 2006
- Offline
Sorry about that. There was a bug recently that was causing files saved in newer builds to crash instantly in older builds that I thought was fixed. Updating to a recent build should solve the problem. However, I copied and pasted the network to a new session in an older build so the file attached in this post should work fine in older builds now.
Edited by - 2010年9月18日 14:32:55
Graham Thompson, Technical Artist @ Rockstar Games
- souls7ealer
- Member
- 57 posts
- Joined: 7月 2009
- Offline
Thank you very very much. I have another question please ops:
in velocity changer node (with python icon) I found no codes and it says “ # Couldn't find Python code. Please check that
# oplibDop/velocity_changer?Dop/velocity_changer.py is in the proper location.”
would you please send me the codes???? tnxxxxxxxxxxxxxxx
in velocity changer node (with python icon) I found no codes and it says “ # Couldn't find Python code. Please check that
# oplibDop/velocity_changer?Dop/velocity_changer.py is in the proper location.”
would you please send me the codes???? tnxxxxxxxxxxxxxxx
- graham
- Member
- 1913 posts
- Joined: 11月 2006
- Offline
- souls7ealer
- Member
- 57 posts
- Joined: 7月 2009
- Offline
- Dean_19
- Member
- 319 posts
- Joined:
- Offline
-
- Quick Links