Mozzarino Posted September 27, 2019 Share Posted September 27, 2019 After packing geometry, if I use this VEX snippet to edit the pivots I get predictable results: vector pivotOffset = chv("manual_pivot_offset"); vector pivotCentroid = primintrinsic(0, "pivot", @ptnum); vector newPivot = pivotCentroid + pivotOffset; setprimintrinsic(0, "pivot", @ptnum, newPivot); @P += pivotOffset; If I check "transform using point orientations" in the copy to points SOP and pack the copied geometry, the pivot will move according to the custom offset, but the object moves in a different direction. How can I solve this? Quote Link to comment Share on other sites More sharing options...
LucaScheller Posted September 27, 2019 Share Posted September 27, 2019 (edited) When changing the packed pivot, the packed transform is applied after applying the pivot translate. Here's an example to make it more clear: So let's say you have a sphere, which you parent to a locator. Translating the sphere corresponds to us changing the position of our geo that get's packed(Us changing the pivot is the inverse of this, which is what Houdini does under the hood when changing the pivot prim intrinsic). When you rotate the locator, the whole thing get's rotated. This means that if we translate the sphere, the rotation is still applied from the center of our locator. So if we were to unparent the sphere after rotating the locator in order to still keep the original transform we have to transform our sphere geometry to our locator space. In case of the packed prims this is done via pivotOffset * getpackedtransform(0,@ptnum); vector @P; vector pivotOffset = chv("manual_pivot_offset"); vector pivotCentroid = primintrinsic(0, "pivot", @ptnum); vector newPivot = pivotCentroid + pivotOffset; setprimintrinsic(0, "pivot", @ptnum, newPivot); @P = pivotOffset * getpackedtransform(0,@ptnum); I hope that kind of makes sense? Maybe I'm also completely wrong (The reason nothing happens when "transform using point orientations" is off is that the locator transform is "zero"/an identity matrix). Edited September 27, 2019 by LucaScheller Quote Link to comment Share on other sites More sharing options...
Mozzarino Posted September 27, 2019 Author Share Posted September 27, 2019 (edited) 4 hours ago, LucaScheller said: When changing the packed pivot, the packed transform is applied after applying the pivot translate. Here's an example to make it more clear: So let's say you have a sphere, which you parent to a locator. Translating the sphere corresponds to us changing the position of our geo that get's packed(Us changing the pivot is the inverse of this, which is what Houdini does under the hood when changing the pivot prim intrinsic). When you rotate the locator, the whole thing get's rotated. This means that if we translate the sphere, the rotation is still applied from the center of our locator. So if we were to unparent the sphere after rotating the locator in order to still keep the original transform we have to transform our sphere geometry to our locator space. In case of the packed prims this is done via pivotOffset * getpackedtransform(0,@ptnum); vector @P; vector pivotOffset = chv("manual_pivot_offset"); vector pivotCentroid = primintrinsic(0, "pivot", @ptnum); vector newPivot = pivotCentroid + pivotOffset; setprimintrinsic(0, "pivot", @ptnum, newPivot); @P = pivotOffset * getpackedtransform(0,@ptnum); I hope that kind of makes sense? Maybe I'm also completely wrong (The reason nothing happens when "transform using point orientations" is off is that the locator transform is "zero"/an identity matrix). I understood the first part of the explanation, but the example you presented left me scratching my head. I'm still walking on baby steps on all of this matrix transformation stuff, so I'm at fault here! Thanks alot, Diogo EDIT: There are still small translations after changing the pivot, so it is still not solved Edited September 27, 2019 by diogomgf Quote Link to comment Share on other sites More sharing options...
toadstorm Posted September 27, 2019 Share Posted September 27, 2019 Take a look inside MOPs Pivot, if you can download MOPs where you are. There's a bunch of VEX in there that shows how to modify pivots in a number of ways without affecting the visible appearance of the packed primitives. Pivot adjustments are affected by scale and orientation, so there's some tricky bits in there that are easy to miss... 3 Quote Link to comment Share on other sites More sharing options...
Mozzarino Posted September 30, 2019 Author Share Posted September 30, 2019 On 27/09/2019 at 6:27 PM, toadstorm said: Take a look inside MOPs Pivot, if you can download MOPs where you are. There's a bunch of VEX in there that shows how to modify pivots in a number of ways without affecting the visible appearance of the packed primitives. Pivot adjustments are affected by scale and orientation, so there's some tricky bits in there that are easy to miss... Thanks, will have a look into it! Quote Link to comment Share on other sites More sharing options...
Mozzarino Posted September 30, 2019 Author Share Posted September 30, 2019 @toadstorm I tried copying the pivot wrangle, and it works just fine. I'll be dissecting it to see what I can learn Cheers, Diogo 1 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.