Re-rotating scattered objects to match updated orient attr

   1169   2   2
User Avatar
Member
25 posts
Joined: June 2020
Offline
Hi!

I'm working on some scattering tools and I've hit a snag. I'm scattering points and copying packed geo to them. Naturally, the points are getting their normal (and orientation) from the landscape objects they are scattered to. After copying to points, I'm relaxing the position with my landscape in the second input so that the objects remain on the surface. Then I'm getting the normal from it's new position. I believe I've figured out how to calculate a new orient attribute for these objects but my question is, how can I rotate these objects to match their new orientation? I know I could try to do this relax before my copy to points but it's a complex set up and I'd rather not have to rework it!

The first pic is with no relax - objects are oriented properly. The second pic is post relax - the normal and orient are updated but the rotation is obv still the same.

Thanks for reading!

Attachments:
Orient_Proper.JPG (259.9 KB)
Orient_Relaxed.JPG (287.2 KB)

User Avatar
Member
385 posts
Joined: April 2017
Offline
Assuming your copied geometry is packed, you can update the packed transform intrinsic attribute with the new matrix defined by your updated orientation.

Let's say you've created a new `p@orient` attribute on your packed points and you want the transform matrices to match that new orientation. Run this in a point wrangle:

// cast the new orientation as a matrix3
matrix3 new_m = qconvert(p@orient);
// get the scale of the original matrix 
matrix3 orig_m = primintrinsic(0, "transform", @ptnum);
vector scale = cracktransform(0, 0, 2, 0, orig_m);
// scale the new matrix to match
prescale(new_m, scale);
// overwrite the transform intrinsic with the new one
setprimintrinsic(0, "transform", @ptnum, new_m);

MOPs Apply Attributes [github.com] will do this for you automatically... just feed it a matching set of points with the updated orient attribute and it'll apply that to the transform intrinsics.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
25 posts
Joined: June 2020
Offline
Thank you for taking the time, toadstorm. I very much appreciate it!
  • Quick Links