rotating connected pieces

   1815   6   2
User Avatar
Member
17 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

Attachments:
FracturedBox2.jpg (93.5 KB)

User Avatar
Member
359 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:

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]
User Avatar
Member
17 posts
Joined: 11月 2019
Offline
Thanks for the reply! I think there are too many holes in my Houdini knowledge, I pasted the vex into an attribute wrangle set to run over points and adjusted the maxdist channel slider. I dont have any errors but nothing is happening.

The motion operators look great, I will try that approach too.
User Avatar
Member
4486 posts
Joined: 2月 2012
Online
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]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
17 posts
Joined: 11月 2019
Offline
Thanks for the reply!
Ok, so I hadnt ticked 'Create Packed Primitives' on the assemble node. Now I can see that they are indeed packed... but Im clearly still missing something as nothing has changed, my pieces still dont rotate. I will continue to experiment with it.
User Avatar
Member
4486 posts
Joined: 2月 2012
Online
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]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
17 posts
Joined: 11月 2019
Offline
Thanks to you both! I finally got it working by starting with a fresh scene. I'll need to dig into the old scene to see what has going wrong. Thanks for you help!
  • Quick Links