3ds Max Model Rigging

When I started my current game, I didn’t have any idea about model animation. The only thing I knew was the pure concept of bones (which are essentially a matrix stack: when the upper arm bone moves, its children, namely the lower arm bone and hand bone, move with it).

There wasn’t much available in terms of tutorials or guides on the net, so after fighting my way through to a working bone-animated model, I decided to write down the steps I took and illustrate everything as good as I can.

In this article, I will explain how to rig a mesh with bones and skin weights in 3D Studio Max 2011 (there’s a free trial available from Autodesk). I will not explain how to create animations (eg. a walk cycle) and play these in your XNA game because I haven’t spent any time figuring that out yet 😛 (my current game controls all bones programmatically).

Creating Bones

For modelling, I tried SoftImage XSI (of which XNA premium members get the "Pro" edition for free) but in the end decided to do this with a trial of 3ds Max 2011 because I find it a much more intuitive and sane working environment. I doubt I’ll ever be able to afford it, though…

I began with this simple turret model from 3drt.com:

Screenshot of 3ds Max 2011 with a turret model consisting of multiple meshes

My first step is to add bones to the model. You can do this by selecting the bone primitive from the tools panel on the right or by opening the Bone Tools dialog from the menu which also lets you enter Bone Edit Mode, allowing bones to be moved without their child bones / meshes following.

Screenshot of 3ds Max 2011 highlighting the Bone Tools menu entry and Create Bone Primitive button

Bones do not need to touch each other to form a hierarchy: there’s a small chain in the toolbar to the upper left that lets you assign a parent to any mesh or bone by hand. Just select the chain, then drag a line from the object you want to become a child onto its new parent.

It’s generally a good idea to name your bones. For my turret, I created 7 bones:

  • BaseBone – This bone is placed at the coordinate system’s center and will later become the reference point for positioning the model.
  • RotorBone – A bone that will be rotated on the Y (vertical) axis to turn the turret.
  • ElevatorBone – A bone that will be rotated on the X (horizontal) axis relative to the turret’s orientation in order to raise and lower the gun barrels
  • LeftBarrelBone and RightBarrelBone – These will allow the barrels to be moved back to simulate kickback when the turret fires.
  • LeftMuzzleBone and RightMuzzleBone – Mark the openings of both barrels for the game so it knows where to draw muzzle flashes, smoke, etc.

After all bones were positioned and linked to each other, I ended up with the following hierarchy:

Screenshot of 3ds Max 2011 hierarchy view showing how I linked the bones

Notice that I linked the base mesh (labaled "Base") to the "BaseBone" – this means that wherever I move the BaseBone, the model will follow. It also seems to be important for the crappy FBX exporter in 3ds Max: if a model contains a mesh that’s not parented to a bone, it will arbitrarily be scaled by a factor of 100 or so. Do not worry about the hierarchy of any other meshes in the model for now as these will go away in the next step.

Merge the Mesh

My second step is to turn the model, still consisting of several independent meshes, into a single mesh. This will ensure the entire model can be rendered with a single DrawPrimitive() call in XNA, which is important because those calls are what defines the performance of an XNA game. If my turret had 6 meshes like in the above picture, building 25 turrets would already equal 150 DrawPrimitive() calls and begin to bog down an Xbox 360.

Select the mesh that is the base, or root of the model. Most likely, it already has the "Editable Mesh" modifier applied to it. If not, you can safely add it. In the Editable Mesh toolbox, you’ll find a button labeled Attach.

Screenshot of the Editable Mesh modifier toolbox with the Attach button highlighted

Remember to have the base mesh selected, then click on Attach and pick all of the other meshes in the model one by one. When you’re finished, you’ll have a single mesh like this:

Screenshot of the model turned into a single mesh

Skinning

To apply vertex skinning to the model, use the "Skin" modifier:

Screenshot showing the skin modifier and the location of the Add Bones button

The Skin modifier requires you to select the bones for which weights should be added to the vertices. For my turret, I select all bones except for the muzzle bones (these are only tag points where my game will draw muzzle flashes and such, but none of the model’s geometry will be deformed by these bones).

This also gives you a real reason to name your bones properly 😉

Screenshot of the Add Bones dialog for the Skin modifier with some bones selected

3ds Max will auto-generate bone weights for the vertices based on their distance to each bone. This would be a good starting point for an organic model, but in my case, the model consists of solid, not bendable metal parts that will all be assigned to one specific bone only (with a weight of 1.0).

To adjust the bone weights, I use the Weight Tools dialog that can be found in the Skin modifier’s toolbox. Also take note of the Weight Table button immediately to the right of it:

Screenshot of the Weight Tools button in the Skin modifier's toolbox

To select vertices, use the Edit Envelope button (which would let you alter the distances by which 3ds Max auto-assigns weights) and check the "Vertices" checkbox below it:

Screenshot of the Edit Envelope button and the Vertices checkbox

Also useful is the "Element" checkbox which will automatically select all vertices belonging to the same enclosed primitive set (Element) in the model.

As you can see, 3ds Max will highlight the bone weights on the mesh in red. Picking different bones in the Skin modifier’s bone list lets you select which bone’s weights you will alter. In my turret, the auto-assigned weights associate only half of the vertices in its base to the base bone. To change that, I selected all the vertices in the models base (with the help of the "Element" checkbox) and used the Set Weight button with a weight of 1.0 to fully assign the vertices to the base bone:

Screenshot of the model with its entire base highlighted in red

Now the entire base is red, indicating that it belongs to the root bone exlusively. I repeated these steps for the other bones in my model until each bone had the vertices in one part of the model assigned to it.

There’s one more step I perform at this point: remove all bone associations with zero weight from the vertices. I don’t know if this actually has any positive effect on rendering performance, but it only requires a few clicks and at least won’t do any harm, so here goes:

Remember the Weight Table button to the right of the Weight Tools button I mentioned before? Press it to open the Weight Table and click on "Remove Zero Weights" in its "Edit" menu:

Screenshot of the Remove Zero Weights option in the Weight Table dialog's Edit menu

Testing

Before exporting the model, it’s a good idea to test whether it animates properly. I often find that there are one or two vertices I forgot and it looks just awful if a single vertex in the model’s base distorts everything when the turret rotates, producing weird polygon garbage.

Screenshot of the finished model with bones and skin weights applied

The easiest way to verify your model is to select the bones and use the rotation transform tool to rotate them around. Look closely for any misbehaving vertices!

Screenshot of the finished model with rotated bones

9 comments

  1. Jack says:

    Beautiful article. I think it would be easier (and quicker) to write a content processor that merges the geometry and sets up the bone weights automatically. Then you could avoid the tedious manual labour in 3DS MAX and process multiple models …

  2. Devinda says:

    Hi, then how did you export the model into XNA with texture+bone and grammatically animate it. I need help for these too. There are not much tutorials on this. I’m sick of trying for this…Plz help.

  3. Cygon says:

    XNA doesn’t have any bone animation classes itself, so you need to either base your code on the skinned mesh example by Microsoft or use one of the libraries (xnanimation, XNA animation component library, sgMotion) for that.

    I show the 3ds Max to XNA export process in this tutorial: http://blog.nuclex-games.com/tutorials/graphics/mesh-based-bone-animation/
    Can’t provide much more than that because my 3ds Max trial has run out and I’m not doing XNA anymore.

  4. Devinda says:

    OK that link helped me a lot this what I’ve been looking for.. thanks again…:)

  5. Dan Grube says:

    I know you think a tutorial means everything you just learned and start at that point. Everyone who liked are at your level… not a tutorial. I’d recomend you build models. Sounds like you’re very good at it but stay out of education… it appears you’d rather start in the middle and impress you peers…. TUTORIAL for those who don’t know. You just clog the search engine. Best of luck on you profession but please stay away from the education side… you’re not built for it.

  6. Cygon says:

    And who might have stepped on your little toe to make you so angry? :)

    It’s hard to even tell what you’re complaining about. My best guess would be that your googling skills failed you and you ended up with this not-a-tutorial that’s either below or above your skill level, so how dare this blogger publish something that ends up in your web search!

    Or perhaps, since you said “start in the middle,” and somehow got the impression that I build models, maybe you’re looking for a tutorial on modeling in 3ds Max? If so, search for “modeling” or “sculpting,” not “rigging.”

    I start from a completed model precisely because there already are thousands of tutorials showing everything up to that point, but few that show how to proceed from there. Many game developers also purchase completed models and then need to animate them without prior knowledge about 3ds Max. So there’s my target audience.

  7. Ben says:

    How exactly did you individually select the vertices of the base bone? I’m trying to do this with a simple turret that I made (made of boxes and cylinders), and it’s selecting vertices from other parts, that I don’t want selected. How do I deselect these? It’s stopped my progress completely, and I can’t find an answer anywhere

  8. Bruno says:

    Just to say, great tutorial. Straight to the point, fast. Must admit, a tuto the way I like it, no cometics or execive things, just the info I was looking for and the title pretend it will give. Thanks!!

  9. Treereaver says:

    Ben

    I am assuming you know that alt+LMB deselects vertices!

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Please copy the string 67cX23 to the field below:

Social Widgets powered by AB-WebLog.com.