Jump to content

Custom pivot after packing geometry


Mozzarino

Recommended Posts

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?

Link to comment
Share on other sites

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 :D (The reason nothing happens when "transform using point orientations" is off is that the locator transform is "zero"/an identity matrix).

Edited by LucaScheller
Link to comment
Share on other sites

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 :D (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 by diogomgf
Link to comment
Share on other sites

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...

  • Like 3
Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...