Jump to content

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


catchyid

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 5 weeks later...

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