Jump to content

Extract transform


Recommended Posts

i have a library of packed primitives with a unique name attribute that i import, copy and transform, and mirror.

I need to extract these final transforms to export a json. Is there a way to do that?

Usually i have the orient attribute that helps me to generate a 3x3 transform but in this case i don't have any other attributes other than the position.

extract_transform.hip

Edited by papsphilip
Link to comment
Share on other sites

i think there is no out of the box solution for this as it is a very specific request. however, if you have packed prims, it should have it's transform matrix stored as intrinsic primitive (pos, rot, scale). you can then use a python script i suppose, to read individual packed transforms and write it into a text file with json syntax.

If packed prim transform is not there in packed intrinsics (i.e. it's zero), it's been either discarded somehow in the prior processes, or haven't been generated at all. In that case you have to find a workflow that generates and retains this attribute for you. (not 100% sure if this is generated by "copy and transform SOP", but it's definitely generated by "copy to points SOP")

this is of course just a rough workflow on how would I try to approach it. Detailed steps will vary depending on how you've built your scene, and how u wanna use the data next.   

cheers, D.

Link to comment
Share on other sites

yeah i am using the "packedfulltransform" intrinsic attribute right now. seems to still be there after the mirror sop or the copy and transform.

i want to copy my named primitives to the points with the transform just to verify that it is working but i haven't managed to do that yet. is there a way to use copy to points but instead of pscale and orient use a transform?

Link to comment
Share on other sites

again, depends on your specific setup. But for example, "transform by attribute SOP", "transform pieces SOP", and "getpackedtransform" and "setpackedtransform" VEX functions are the good candidates to look at.

also this article might come in handy:

https://vfxbrain.wordpress.com/2020/07/09/how-to-re-apply-packed-transform/

Link to comment
Share on other sites

1 hour ago, papsphilip said:

yeah i am using the "packedfulltransform" intrinsic attribute right now. seems to still be there after the mirror sop or the copy and transform.

i want to copy my named primitives to the points with the transform just to verify that it is working but i haven't managed to do that yet. is there a way to use copy to points but instead of pscale and orient use a transform?

Copy to Points will look for "transform" attribute on Points if it can't find "N" and "up" or "orient".

Link to comment
Share on other sites

packinject SOP seems to be applying the transformation correctly

first input is a my packed primitive library with name attribute, the second input is for my already placed and named packed primitives. Injection method set to collate packed sources using the name attribute.

So at least i know that the intrinsic transform is correct after copy and transform or mirror operations and can be applied to other geo.

i haven't figured out how to apply that transform myself yet

 

1 hour ago, dleonhardt said:

Copy to Points will look for "transform" attribute on Points if it can't find "N" and "up" or "orient"

copy to points output for some reason is not correct

4@transform = primintrinsic(0,"packedfulltransform",@primnum);

This is what i used to extract the transform

extract_transform.hip

Link to comment
Share on other sites

1 minute ago, papsphilip said:

thank you! didn't think to use a 3x3..

4x4 contains the position as well but i guess copy to points uses directly the position of the incoming geo points.

 

You can use a 4x4 matrix too, if all your points are at the origin.

  • Like 1
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...