Jump to content

Move to origin and restore original position


kiryha

Recommended Posts

I think its better to use centroid rather than CEX. If you use centroid you will actually see values and not just "0". 

centroid(0,D_X)

then you can duplicate the transform node and use the invert transformation button.

http://www.sidefx.com/docs/houdini/expressions/centroid.html

Edited by ejr32123
  • Like 1
Link to comment
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

  • Like 5
  • Thanks 1
Link to comment
Share on other sites

  • 7 months later...
On 1/16/2019 at 9:38 PM, kiryha said:

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

Hi, thanks for this and it's wonderful and works for particles.

However, it doesn't seem to centroid the rotation as well?

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