Jump to content
catchyid

Build full transform from t,pivot,r,s? OR how to apply point transform attributes to primitives?

Recommended Posts

Hi,

I am doing a RBD simulation, export only points with transforms (p,pivot,r,s) and then I want to apply these transform on the original simulation primitives. My goal is to get the final translation and orientation and adjust them, however I can successfully apply the orient attribute to the primitives (using vex), however I am not sure how to apply translation? I think my problem has to do with the fact that I am ignoring the "pivot", but I don't see any documentation or examples on how to use it correctly?

Note: node "Transform Pieces" does a similar effect, but it has a black-box that constructs the full transformation?

Attached is the example file that contains the question.

Thanks,

match_transform_v1.hip

Share this post


Link to post
Share on other sites
Posted (edited)
2 hours ago, catchyid said:

Note: node "Transform Pieces" does a similar effect, but it has a black-box that constructs the full transformation?

nothing blackbox about Transform Pieces, just dive inside, unless you mean Make Instance Transform VOP, which is just wrapper around instance() vEX funcion that you can use to build your transform

Edited by anim

Share this post


Link to post
Share on other sites
Posted (edited)

Hi Tomas,

Yes, I was talking about VOP "Make Instance Transform" (which uses point attributes t,p,r,s and builds a transformation and apply it on primitives). I was able to get the right translation and orientation when I am copying from Bullet simulated Primitives to Packed Primitives as (below is point wrangle, 1st input is packed primitives, 2nd is bullet simulated primitives):

//NOTE: code below is not mine, just batching pieces from this forum!

matrix pft = primintrinsic(1,'packedfulltransform',@ptnum);
//set translation----------------
@P*=pft;

//set rotation-------------------
vector t,r,s;
vector pivot = point(1,"pivot",@ptnum);
cracktransform(0,0,pivot,pft,t,r,s);

vector  e=set(radians(r.x),radians(r.y),radians(r.z));
vector4 q=eulertoquaternion(e,0);
matrix3 m3= qconvert(q);
setprimintrinsic(0,'transform',@ptnum,m3); 

//OR another method
//matrix3 xform = primintrinsic(1, "transform", @ptnum);
//setprimintrinsic(0,'transform',@ptnum,xform); 

HOWEVER, If I am copying from points which have t,p,r,s to packed primitives, I don't get the translation right (99% bc I am not using the pivot). The code below is for the rotation which runs on a point wrangler and works "correctly".

vector4 q=point(1,"orient",@primnum);
matrix mat=qconvert(q);
matrix3 rot = matrix3(mat);
setprimintrinsic(geoself(), "transform", @primnum,rot);

But the translation code is buggy:

vector _p=point(1,"P",@ptnum);
@P=_p; //somehow need to take care of the pivot?

I need to use the pivot for the translation but I have not figured it out yet, I would assume the full transformation matrix is :

final_transform =  s * inverse_pivot * rot * pivot * t 

Anyways, will test it and see :)

Thanks
 

question_transformation_annotated.png

Edited by catchyid

Share this post


Link to post
Share on other sites

just if someone is interested, I got an answer from SideFX support:

matrix xform = qconvert(orient);
pretranslate(xform, -pivot);
translate(xform, P);

If you're applying that to a piece that already has a transform, its new transform would be
`piece_xform * xform`;
cleardot.gif
 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×