Showing posts with label center. Show all posts
Showing posts with label center. Show all posts

Thursday 12 September 2024

bringing object to origin

Not entirely sure how this deals with objects that move around A LOT, but for something mostly static that isn't near the origin it's good. Useful for simming stuff at zero then shoving back to where it came from.


In a point wrangle, move object to 0.0.0..

 // 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 + {0,-0.2,0};

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;




Then in a later point wrangle, to revert back to original position


@P *= invert(4@xform_matrix);

Saturday 19 October 2019

group centroids

group centre/centroid - intstead of blasting out groups and using $CEX etc, you can just use $GCX, $GCY, $GCZ in your transform pivots.