Streamlining Animation:

Is Your 3D Model Floating? 

When spawning new meshes the origin is often aligned at the object's center making it spawn half way through the floor, so I wrote this tool to quickly snap the bottom of the mesh to the ground.

It's particularly helpful in preventing things from clipping through a ground plane, and stops you from having to move or create a new pivot point for aligning the mesh which can break some animation data.

I started by breakdown down the problem into several key questions:

- How do I find the bottom of an object?
- How do I know how far to move the object?
- How do I know if I should move the object up or down?
- How do I actually move the mesh?

Then I dove into Maya's documentation looking for answers.

The most influential step was understanding how I would find the bottom on an object. I remembered Cinema4D had the ability to view meshes as their bounding box. If I could simplify a mesh down it it's bounding box, I could identify the lowest point more easily.

From there, it was really straightforward. Using `mc.exactWorldBoundingBox(object)`, you can get the position of the bounding box and with `mc.xform(object, q = True, t = True)`, you can get the position of the object. Next, all you need to do is subtract the Y-position of the bounding box from the Y-position of the object, and set the new Y-position with `mc.xform(object, t=(object_position))`. Wrapping all of this in a For loop, we can easily repeat this process of all of the selected objects.

It works perfectly and makes Maya feel a bit more like what I'm used to with Cinema4D.

Beyond just dropping objects to the floor, I would consider adding options to align objects to other objects or planes in the scene, providing even more versatility. This could include aligning to the nearest surface below the object or aligning multiple selected objects relative to their lowest points. Additionally, I would love to add the ability to continuously align one mesh to another. This way, we can maintain our contact with the ground while animating something like a car tire moving over bumpy terrain.

View on GitHub


 

 

 

Using Format