VEX fetch various timeshift values of packed alembic

   1244   0   0
User Avatar
Member
79 posts
Joined: Feb. 2008
Offline
I have this situation where I have 2 sets of packed alembics, one is static and I want to copy the transform of the second animated set using primintrinsic to extract packedfulltransform. This allows me to extract transform animation from a lower res mesh and copy it onto a higher res mesh.

As long as I have a way to find the matching id of the primitive to extract the transform from low-res to high-res, I can use this piece VEX code to copy the transform from the animated prim to the static prim :

// set position
int anim_ptnum = primpoint(1, id, 0);
vector P = point(1, 'P', anim_ptnum);
setpointattrib(0, 'P', @ptnum, P );

// set scale & rotation
matrix T = primintrinsic(0, "packedfulltransform", @primnum);
matrix anim_T = primintrinsic(1, "packedfulltransform", id);
T = T * anim_T;
setprimintrinsic(0, 'transform', @primnum, (matrix3)T);

This works well, but now I have this situation where I have multiple copies of the static mesh, each containing a time attribute value, and I want to extract and copy the transform at that time value.

If I was working on the animated packed alembic, I could simply set the abcframe primintrinsic like this:

setprimintrinsic(0, 'abcframe', @primnum, @time);

…but since the transform has been copied onto the static packed alembic, changing the abcframe value does nothing.

The only solution I see is to first pre-process the animated alembic to set the abcframe values before the static alembic calls to copy them over, but since multiple static primitive might pull transform from the same animated prim but at different time stamps, that means I would need to duplicate each animated prim before offsetting them so the static prim can find the right time offset transform to copy over.

All this is very doable, but I can't help but wonder if there exist a simpler more elegant solution out there to do something like this? Maybe some of the crowd tools already have similar features that I could use? What do you guys think? Is my approach the right one or is there more elegant and efficient solutions I should explore?

Cheers!
  • Quick Links