Jump to content
kiryha

Move to origin and restore original position

Recommended Posts

I know how to move an object to origin with transform node (with CEX CEY CEZ) but can't get how to restore original position after...

 

moveToOrigin_001.hipnc

Share this post


Link to post
Share on other sites

just wright position to attribute and after moving to origin apply stored position attribute to @P;

  • Like 1

Share this post


Link to post
Share on other sites

Here is move an object to origin with VEX:

// Get center of the oject bounding box (centroid)
vector min = {0, 0, 0};
vector max = {0, 0, 0};
getpointbbox(0, min, max);
vector centroid = (max + min)/2.0;

// Build and apply transformation matrix
vector translate = centroid;
vector rotate = {0,0,0};
vector scale = {1,1,1};
matrix xform = invert(maketransform(0, 0, translate, rotate, scale));
@P *= xform;

// Store transformation matrix in attribute
4@xform_matrix = xform;

Return to original position:

@P *= invert(4@xform_matrix);

 

move_to_origin_001.hipnc

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

×