rotating connected pieces
757 6 2-
- daverosesumo
- Member
- 13 posts
- Joined: 11月 2019
- Offline
I am trying to randomly rotate connected pieces of a fractured box based on their distance to the center of the object. So in this example I would have more random rotation on the center pieces and NO rotation on the edge pieces. I cant quite get my head around what I need to do... All help appreciated!
Edited by daverosesumo - 2023年2月2日 15:53:03
-
- toadstorm
- Member
- 333 posts
- Joined: 4月 2017
- Offline
This would be simpler to do if you pack all the pieces first. You can easily do this with an Assemble SOP set to create packed fragments.
Once that's done, you need to create a random rotation for each of the chunks. There's a lot of different ways to go about this. The easiest would be an Attribute Randomize set to generate the `orient` attribute, set to four dimensions (because orient is a vector4), in "Direction or Orientation" distribution mode.
Once you have that attribute, you need to apply that randomization to the packed transforms of each piece, weighted based on the distance to the origin. You can do that with a bit of VEX:
This would also be very easily done with MOPs Randomize [github.com] if you don't want to dive so deep into VEX just yet.
Once that's done, you need to create a random rotation for each of the chunks. There's a lot of different ways to go about this. The easiest would be an Attribute Randomize set to generate the `orient` attribute, set to four dimensions (because orient is a vector4), in "Direction or Orientation" distribution mode.
Once you have that attribute, you need to apply that randomization to the packed transforms of each piece, weighted based on the distance to the origin. You can do that with a bit of VEX:
float dist = length(@P); float maxdist = ch("max_dist"); // map the distance from the origin to a 0-1 range float ndist = fit(dist, 0, maxdist, 1, 0); // get the random orientation and blend it with an identity (no-op) orientation // based on the mapped distance matrix3 rot = qconvert(p@orient); rot = slerp(ident(), rot, ndist); setprimintrinsic(0, "transform", @ptnum, rot);
This would also be very easily done with MOPs Randomize [github.com] if you don't want to dive so deep into VEX just yet.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
-
- daverosesumo
- Member
- 13 posts
- Joined: 11月 2019
- Offline
-
- animatrix_
- Member
- 3923 posts
- Joined: 2月 2012
- Offline
Are your fractured pieces packed? You can verify it by MMB clicking on the input geometry you pass to attribute wrangle node.
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

patreon.com/animatrix | vimeo.com/animatrix3d
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

patreon.com/animatrix | vimeo.com/animatrix3d
-
- daverosesumo
- Member
- 13 posts
- Joined: 11月 2019
- Offline
-
- animatrix_
- Member
- 3923 posts
- Joined: 2月 2012
- Offline
Try this code:
float n = fit ( length ( @P ), 0, ch("maxdist"), 1, 0 ); vector4 q0 = quaternion ( 0 ); vector4 q1 = sample_orientation_uniform ( rand ( @ptnum ) ); vector4 q2 = slerp ( q0, q1, n ); matrix3 xform = qconvert ( q2 ); setprimintrinsic ( 0, "transform", @ptnum, xform );
Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

patreon.com/animatrix | vimeo.com/animatrix3d
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

patreon.com/animatrix | vimeo.com/animatrix3d
-
- daverosesumo
- Member
- 13 posts
- Joined: 11月 2019
- Offline
-
- Quick Links