Move animation cache to origin (VEX)
Example: Move animated point caches centroid to the origin for each frame.
Logic around the script:
Run over points
gather and set the transform
Create identity 4x4 matrix variable “xform”
find the vector pointing to the center of all the points in the stream with getbbox_center() vex function
invert the vector pointing to the center
translate the matrix “xform” by the previously inverted vector
multiply the first streams point position by the translated matrix “xform”
store the translation matrix to a detail attribute.
matrix xform = ident(); vector center = getbbox_center(geoself()); center *= -1; translate(xform,center); v@P *= xform; setdetailattrib(geoself(),"xform",xform);
To bring back the original animation
Read the transform matrix from detail attribute “xform” and store it in a variable
invert the transform matrix
multiply point position by the matrix.
matrix xform = detail(geoself(),"xform"); xform = invert(xform); v@P *= xform;