Center Bounds
Todd's center.js has some limitations which I don't like, a bug (which can easily be fixed), and doesn't do what you might think, so I've heavily modified it. Todd -- you should probably add a line to your script to prevent it from messing with objects that have no vertices (like creators) ...
My script differs from Todd's in two key ways:
Known Problems
Don't use this script (or Todd's) on objects with arbitrary coordinate systems. In particular the mesh's coordinate system should not be rotated relative to the global coordinate system.
Thank you (again) Todd for writing center.js and providing such helpful and extensive comments.
Todd's center.js has some limitations which I don't like, a bug (which can easily be fixed), and doesn't do what you might think, so I've heavily modified it. Todd -- you should probably add a line to your script to prevent it from messing with objects that have no vertices (like creators) ...
Code:
var size = core.vertexCount();
// if the object has no points, we bail out
if( size == 0 )
return;
My script differs from Todd's in two key ways:
- My script calculates the new center based on the selected object's bounding box, rather than by averaging out all its vertices (as Todd's does). The two approaches will have the same effect on symmetrical objects, but markedly different effects on objects with more detail on one side, and subtly different effects on almost any typical mesh. Personally, I think centering to the bounding box is what most users would want and expect.
- It provides three parameters (X, Y, and Z) that control where in the bounding box the center ends up. 0 -> the minimum value, 1 -> the maximum value, and 0.5 (the default) the center value. So, for example, if you set Y to 0, and leave X and Z alone, it will move the pivot to the center of the object's base.
Known Problems
Don't use this script (or Todd's) on objects with arbitrary coordinate systems. In particular the mesh's coordinate system should not be rotated relative to the global coordinate system.
Thank you (again) Todd for writing center.js and providing such helpful and extensive comments.
Attachments
Last edited: