View Full Version : Free LScript: CG_CENTER (centers by volume)

Mike Pauza
01-18-2005, 08:39 AM
Hey everybody! Here's an LScript from me and Kurv Studios that centers objects in modeler based on their center of gravity (center of volume). All objects naturally pivot about their "CG", so positiong the pivot point corrently is essential for believable animation.

Here are some examples of CG_CENTER versus LightWave's CENTER command:

And here's the link to the free LScript (requires registration):

If you enjoy this LScript please consider buying one of Kurv's many fine LightWave training DVD's like:
http://www.kurvstudios.com/lightwave/dynamics.php (by me)
http://www.kurvstudios.com/lightwav...le_modeling.php (by Gerald Abraham)
http://www.kurvstudios.com/lightwave/ikbooster.php (by Larry Schultz)
http://www.kurvstudios.com/lightwave/bone_tools.php (by Larry Schultz)
http://www.kurvstudios.com/lightwave/product_vol_1.php (by Larry Schultz)
http://www.kurvstudios.com/bodypaint2/index.php (by Robin Konieczny)
http://www.kurvstudios.com/lightwave/sasquatch_lite.php (by Nick Boughen)

Below is the faq sheet on CG_Center. Again, this LScript is free, so if you like it please let people know about it.
Enjoy. -Mike Pauza

CG_CENTER faqs: ( by Mike Pauza )

Q1: What's the main difference between CG_CENTER and LightWave's CENTER tool?

A1: CG_CENTER correctly places an object's pivot at it's center of gravity (CG) (based on it's center of volume), while LightWave usually doesn't. All objects naturally pivot about their CG, so positioning the pivot point correctly is essential for believable animation.

Q2: What type's of objects are centered poorly with LightWave's Center tool?

A2: LW does a great job centering symmetrical objects like spheres, boxes, cylinders, etc., but most objects are centered MUCH more realistically with CG_CENTER.

Q3: What type's of objects are prime candidates for CG_CENTER?

A3: Aircraft, spaceships, asteroids, throwing weapons (i.e. objects with only some or no symmetry whose rotation is a large part of thier motion), all normally look much better animated when centered by CG_CENTER.

Q4: How fast is CG_CENTER?

A4: That depends on the object, but at a 50% accuracy setting (on a 2GHz PC) most objects take about 1 second to center for every 500 polygons in the object...a 30,000 polygon object for example, might center (at 50% accuracy setting) in about a minute. Compared to 50% accuracy, objects center about 30X faster with the 0% accuracy setting, and about 30X slower at the 100% setting.

Q5: How accurate is CG_CENTER?

A5: Run CG_CENTER twice with the same settings and note the "Geometry moved by _______ meters" message after the second run. Since this second value should ideally be "<0,0,0> meters", the value gives you a very good idea how accurate the center was. Normally at 50% accuracy CG_CENTER works as well as you need, but it really depends on the object.

Q6: Does CG_CENTER ever fail completely or produce a faulty center?

A6: Unfortunately yes. CG_CENTER uses LightWave's Boolean Intersect tool, which doesn't always work correctly. Most of the time it works flawlessly though.

Q7: Besides the boolean engine, are there any known problems with CG_CENTER?

A7: CG_Center, uses layers 998 and 999 as scratch layers. Placing geometry in those layers will sabotage both CG_CENTER and the geometry in the scratch layers. Other than the scratch layer issue, I have not seen CG_CENTER to delete or corrupt object data at all, but I or Kurv Studios can not be held responsible for any such occurance should it happen.

Q8: Can CG_CENTER handle "flat geometry" like a plane?

A8: No, CG_CENTER requires geometry with volume.

Q9: Does CG_CENTER work with multiple selection layers?

A9: Yes, but manual geometry selection is not supported.

Q10: Can CG_CENTER mimick LightWave's CENTER tool?

A10: Yes...just select the three "X/Y/Z LightWave Center buttons". Using those buttons, CG_CENTER can also give you LightWave style centering on any axis. If an object's geometry is mirrored on an axis, select it's LightWave Center button for perfect centering on that axis.

Q11: Can I use CG_CENTER on character's?

A11: Yes, just realize that deforming a character with bones will change it's actual CG.

Q12: Can CG_CENTER handle SubPatches?

A12: Yes, CG_CENTER can center both polygons and SubPatches alike.

01-18-2005, 09:44 AM
Great! :cool:

01-18-2005, 04:02 PM
Wow, what a great idea! Thanks for this one!

Mike Pauza
01-19-2005, 08:20 AM
Thanks Guys. It was just sitting on my computer not doing anyone any good.