ron2812 Posted December 6, 2020 Share Posted December 6, 2020 Hey! I work on a kitbash tool where you can combine multiple meshes and export a point cloud, ready for instancing assets in e.g. Unreal Engine. So far this works fine. I use a Transform node to place/rotate/scale the mesh and transfer the attributes required for instancing to a point. (like scale, P etc.) I exposed the Transform handle to my HDA. My problem is to get the rotation right. I calculated yaw, roll and pitch using the following code, using the Transform's rx, ry and rz: matrix3 m = maketransform(@N,@up); @orient = quaternion(m); vector4 pitch = quaternion({1,0,0}*radians(ch("../transform/rx"))); vector4 yaw = quaternion({0,1,0}*radians(ch("../transform/ry"))); vector4 roll = quaternion({0,0,1}*radians(ch("../transform/rz"))); @orient = qmultiply(@orient, pitch); @orient = qmultiply(@orient, yaw); @orient = qmultiply(@orient, roll); This works fine as long as you only rotate along a single axis. When I rotate along multiple axis simultaneously things get weird and the handly doesn't match the point's orientation at all. Is there a better way to simply convert a Transform's rx, ry and rz to a Point orient attribute? Thanks for your help in advance! Best, Ron Quote Link to comment Share on other sites More sharing options...
Alain2131 Posted December 6, 2020 Share Posted December 6, 2020 (edited) Hey Ronald ! The easiest way I found to handle rotation like you want is to create an initial orient attribute on your points before any transformation. And that's it ! The awesome thing with this is that the transform node has an awesome feature that not only transforms the P, but also any other attributes it can, based on their type. So if there is, for instance, an existing orient attribute, the transform node will modify it accordingly, without you having to do any matrix math ! And you can daisy-chain multiple transforms without having to bother re-computing the orient each time In this gif, I show exactly this. The extract_smth_smth wrangle is superfluous, only to have the x y z attributes extracted from the orient, to be able to visualize them with the visualize node. (also - I just found out that I could have used orient directly in the visualize node instead of the x y z like I did. So that wrangle really is superfluous) Edited December 6, 2020 by Alain2131 2 Quote Link to comment Share on other sites More sharing options...
ron2812 Posted December 7, 2020 Author Share Posted December 7, 2020 Ha! Awesome! You just saved me a lot of headache fiddling with quaterions! Thank you so much! Works like a charm! Best, Ron 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.