Skeletal Animation Example

From Croquet Consortium

Jump to: navigation, search

Contents

Intro

The Croquet Team at UMN has released a fine Skeletal Animation package for Croquet Jabberwocky. They are using this package internally for a proprietary language learning environment project. The models and animations that they are using are purchased and cannot be shared with the public Croquet community.

SO, the point of this project is to build a complete working example of the UMN Skeletal Animation package which can be freely distributed under the Croquet license. It appears that the biggest part of this project is to create one or more model meshes, create one or more animation sequences for the meshes, and export the meshes, all related textures and materials, and all animations in the Ogre XML format.

Blender3D version 2.44 will be used for this example. The Ogre Meshes Exporter was chosen as it appears to be comprehensive and current. This exporter requires Python 2.5 to be installed, not just the cut-down version of Python included with Blender3D. While I was at it, I also grabbed a download of Python-Ogre because it has lots of interesting examples, although it will not be directly used by this project. At least that was the original plan - actually the binary<->XML translator program was used to translate a couple of free models from Psionic. So now there are three rigged, skinned, and animated models available; the Star model built during this project, and two models made available by Psionic and translated to Ogre XML for this project, with his permission.

The Movies

Croquet Skeletal Animation example

Another example

Preliminary Guidelines

  • I went through the "Your First Animation in 30 + 30 Minutes" tutorials in the Blender manual at http://wiki.blender.org/index.php/Manual to build Gus, a gingerbread man with a skeletal walk animation. This makes the 3rd or 4th time I have done Part I of these tutorials over the last couple of years. Part II was surprisingly easy.
  • As far as I know, I have complete rights to this figure, even though it was built by following a tutorial that has someone else's ownership rights attached to it.
  • It took me about 4 hours to go through these tutorials. I suspect that you would have to be quite familiar with Blender to get through them in 60 minutes. I had to backtrack a few times to fix one error in the tutorial and a couple errors of my own.
  • The Gus model uses subdivision surfacing, which can be a little tricky when exporting the model for other renderers such as Croquet. It is best NOT to "apply" the subdivision modifier if you are going to further change the model in Blender. However if you want to use the mesh in something else like Croquet, you have to apply it to get a better approximation of the subdivision surface because neither the export format nor Croquet know how to deal directly with subdivision surface rendering. So save your model in the native .blend format BEFORE applying the subdivision modifier. Keep the levels and render levels numbers low (I used 1 and 2 respectively) to keep the number of polygons in the model reasonably low.
  • When you DO get around to applying the subdivision surfacing modifier, this will change the vertex groups associated with the armature bones, so you should again check those as shown in Part II of the tutorials.
  • The Croquet importer expects the entire model to be in a single mesh, and if you follow the Part I tutorial, you actually end up with several separate meshes for the body, buttons, and face. So it is necessary to join or parent these meshes together. So far I have only tried a join, but I think parenting should work as well. A group will not work. If you do a join after completing the Part II tutorial, as I did, you will have to reparent the body mesh to the armature again by removing the body's parent and re-establishing the armature as the body's parent as described in the tutorial.
  • The rendering of the TAnimatedMesh is built to use at most 1 texture for the entire model. Additional sets of texture coordinates are used internally to hold bone positions and indices. So if your model has multiple textures, they must be "baked" to a single texture and a single set of texture coordinates.
  • The Croquet Ogre model loading process expects there to be a "root" bone (exactly one bone with no parent bone), which is not present in the simple tutorial-based models, so this should be added. There is an example in the "Blender Summer of Documentation Introduction to Character Animation tutorial", which I have so far just skimmed through.
  • The original code had a limit of 24 bones hardcoded in several places. This was increased to 28 in order to accomodate the ninja model from Psionic.
  • There are some notes at http://www.ogre3d.org/wiki/index.php/Tools:_Blender#FAQ that are useful to the Blender->Ogre export process.

Background

From the mailing list:

With the skeletal animation package available to the public we're happy to have people using the code and building applications with it - what we don't currently offer are any models we can freely distribute for people to at least initially test with. We're looking to get one or more character meshes with a skeleton and a few animations (say stand, walk, dance) to show-case what these animated models are like and how others can use them in their croquet projects.

We've been using Maya to create these models, but since we use the Ogre model format, a number of other popular programs support the format (blender, 3ds max, to name a few).

An Ogre animated mesh (for us) looks like:

  • test.mesh.xml
  • test.skeleton.xml
  • test.material
  • test.png

The mesh contains the vertices, normals, texcoords, bone weights, and any vertex animations (so we use these to get the characters or talk and blink). The skeleton contains the initial bone transforms (often called the bind pose) and any skeletal animations. The animation times are relative for both of the animation type (so each animation's keyframe set will start at 0.0). The material file is referenced by the mesh file and contains lighting data and which texture to apply.

I'm asking more about skeletal standards like "the skeleton must contain 2 toe groups, 2 feet, 2 lower legs, 2 upper legs" etc. I believe that HAnim spells out such a thing and the SL avatars also must have a similar skeleton "standard" structure. Does this apply to your package or is it more general?

It is more general. It can handle any type of skeleton structure you provide as long as the mesh is properly rigged. For instance, you could just as easily import a cow avatar as a human.

I'm starting to get the idea for the model and animation needs. I'm guessing that your package will load in the ogre format, display it in Croquet and play back the animations.

Correct. You use TLoadOgreMesh to parse the xml mesh, skeleton and animation data. TLoadOgreMesh>>frame returns an instance of TAnimatedMesh which is what you will add to your space. For example:

fileName := FileDirectory pathFromURI: 'Contents/Characters/ Joe.mesh.xml'.
mesh := (TLoadOgreMesh initializeWithFileName: fileName scale: 0.03) frame.
space addChild: mesh.

What triggers the animations? Are they tied in to your earlier robot work and its triggers? Or is some kind of UI work also needed for a complete example?

To trigger an animation you send either #playAnimation:type: or #playAnimation:type:playType: to your TAnimatedMesh object. The animation type can be either #skeletal or #vertex while the play type can be either #cycle (looping) or #action (one-time). Sending #playAnimation:type: defaults to #cycle for skeletal animations and #action for vertex animations.

This is all new code and is completely separate from any previous work we've done.

Views
Personal tools