Uncategorized

VEX: Matrix


Move to origin

// 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;

Move back again
@P *= invert(4@xform_matrix);

taken from https://github.com/kiryha/Houdini/wiki/vex-snippets

Leave a Reply

Your email address will not be published. Required fields are marked *

nineteen − 9 =