Tony's Tank Treads Tutorial Page

This is the first tutorial I'm assembling for this section of my web page. As an animation project, tank treads and tracked vehicles have intrigued me for quite a while now. I've thought of a number of ways to pull off that effect, but this latest one seems to be the most robust, predictable, and flexible. The following is my write-up on my createTreadsOnCurve MEL script. I've included a section on "the writing of" this script for the interest of script writers out there.

The Script:

createTreadsOnCurve.mel 08 May 2006

The writing of... -- an in-depth examination of the script part by part. This is for MEL script writers, and less interesting for animators.

Ingredients:

What you'll need in the scene to proceed

  • A looped NURBS curve

  • Geometry for the treads

    Details for the Ingredients:

    NURBS curve: Create a planar loop of a NURBS curve aligned with the X-axis. This is easiest to do by switching to the "side" orthogonal camera, then drawing withe the CV, EP, or pencil curve drawing tool. Take some care to get the end of the curve close to the beginning. Use "Edit Curves -> Open/Close Curves" to form the curve into a loop. I usually use "Rebuild Curves" to let Maya smooth out the curve, and regularize the cv placements. This doesn't affect the performance, but I like the curve shapes it gives.

    Geometry: Create geometry for the treads. This takes some care, since the pieces have to overlap in order to preserve the idea that they are connected. Probably the best way to do this is to run the script, determine the size of element you want (or massage the number of tread segments until you get about the right size), model your geometry to fit, then re-run the script to drop in your new geometry. (This will make sense later.) For simplicity, I'm using a primitive pyramid. The script preserves the geometry's local transformation, so its placement relative to its parent (usually the origin) is important.

    Using the script

    For my example, my curve is called 'curve1', and my pyramid is called 'pPyramid1'.

    My createTreadsOnCurve(...) script is called using this format:

    createTreadsOnCurve 'curve name' 'geometry name' 'number of segments' '# of frames per rotation'  

    In this example, calling:

    createTreadsOnCurve curve1 pPyramid1 100 400

    Results in 100 copies of pPyramid1 being attached to the curve, and each of those copies takes 400 frames to traverse the entire loop one time. (see image below) Each segment is aim constrained to the next segment, so that they follow each other neatly around the curve.

    It also creates a non-rendering 'control wheel' that drives the animation through Maya's driven keys (highlighted in green). The tread segments complete one cycle around the curve for each 360 degrees of x-axis rotation that the control wheel completes. This is a tool just to make animating the treads easier and more flexible. The wheel is initialized to complete one turn in the number of frames passed into the script, but this can easily be adjusted using the curve editor, or any other animation tool.

    This is the step where you will finalize your tread segment geometry. Whether complex or simple, your geometry should have two pivot points; one to connect it to each of its neighboring segments. You need to line these pivots up with the locators on the curve in order for the tread to be generated properly.

    Set the actual pivot point of your geometry (the 'insert' key) to one part of the geometry that you want to be a pivot point. (I was sneaky and did this prior to the very first pyramid image at the beginning).

    Use "snap to point" (the 'v' key, or the "magnet and dot" button on the toolbar) to align the geometry with one of the locators.

    Scale the geometry up until the other intended pivot point aligns with the next locator on the curve. Only size is important here.

    The dark blue pyramids are the original size that I ran the script with the first time. I've scaled the green pyramid to the right size.

    Make sure to return the segment geometry to the origin before re-running the script.

    Re-run the script using the same number of segments as before.

    This time the tread segments line up perfectly in a continual loop.

    Typically you will want to decorate your new treads with pulleys and wheels to make it fit into your scene.

    An important note about scene constuction

    This script is meant for maximum flexibility, so there are some options for working with the resulting treads.

    In the image above, you will notice that only the locator is attached to the curve, everything else is just parented to it. You can drop anything else into the locator's child space, and it will move right along with the transform.

    Notice that only the 'geomGroup' transform is aim constrained to the next locator, not the geometry itself. This allows you to replace the geometry, if you wish, without having to re-build all of the aim constraints. This also allows you to put objects underneath the locator, but not under the 'geomGroup'. Such objects will be pointed in the direction of the normal to the curve at the locator's position along the curve.

  •  
    tony@kaap.us | WebSite by KaapFamily.net  |  Valid CSS  |  Valid HTML