author: blaine (dot) simpson (at) admc (dot) com
This tutorial shows you how to export models with or for animation from a Blender scene into jME, using the HottBJ Exporter. If you haven't at least skimmed the Basics Tutorial yet, do so before starting this tutorial. I'll cover Blender skin & bones animations (aka actions), as well as some other types. Do scan the exporter's online help page about skin & bones, at least to see what it contains. If you ask for support and it turns out that the solution is in the help page, you will be exposed to public ridicule.
Note: HottBJ was named Blender ⇒ jME Exporter before version 0.3a.


(Model by Tucho Fernández Calo, animated by Thomas Trocha)
You may be disappointed that in this tutorial you won't be generating highly texturized models. That's because we have a lot of ground to cover, and we can't afford an unnecessary distraction. Textures and materials are covered in the Materials Tutorial. To make a highly texturized animated model, you simply follow the instructions in the Basics Tutorial and the instructions in this tutorial. I'm purposefully using models as-simple-as-posslbe-for-the-purpose in order to teach you what you need to know as easily as possible. My goal is not to make your game or your game models for you.
Unless the context indicates otherwise, a single letter in quotes means to type that letter. For example, “a” means to hit the “A” key without SHIFT or caps lock.
Case is significant, so “S” means SHIFT s.
I indicate mouse buttons with Blender's convention of LMB for Left Mouse Button, etc. MW = Mouse scroll wheel.
Animation with nested objects is a very efficient method of animation, as long as you don't need meshes to deform.
I.e., as long as you don't need skinning.
Though this method is much more simple to implement, it is still both high-performance and powerful.
With some programming, you can make generic controllers that can drive common animations for a set of actors with dynamically changing parts.
This strategy is most applicable to robots or other non-deforming machines like carts or turrets, since the animations just move the individual parts, it can't deform them.
Therefore, we are going to create a robot forthwith.
When working with humanoid animation, you can accommodate a tremendous amount of realistic animation with just rotational FK, or Forward Kinematics (if you don't know what that means, you'll have to look it up elsewhere), because that is how humanoid bodies really work for the most part.
Nested object animation is only easily applied to FK, not IK (Inverse Kinematics).
There are certainly game use cases where machine IK would be useful, but that would be a much more complex undertaking than what we can cover here.
For machines and robots, you can generally have sliding and extending parts, not just rotating parts.
For brevity, we'll only implement rotational FK animations for our robot.
The reader can apply the same method to implement translational FK motion.
Start up blender with the
tutorialenv.blend file, as expalined in the
Basics Tutorial.
I'm not going to spend time repeating what was covered there, so review that tutoriaa if you need to.
If the Outliner doesn't look populated right, then CTRL-Uparrow twice, just like in the Basic Tutorial.
File / Save As so you don't accidentally overwrite the template .blend file after you make changes. From here on, don't LMB click until we have finished creating all of our meshes. This is because the input cursor is now on the origin, so that's where our meshes will be created. If you click somewhere else, it's more work to keep the different meshes aligned. (Use “S” to reposition the cursor if you need to).
Create the base meshes
Add a cylinder Mesh Object with Add / Mesh / Cylinder. In this case we will size it graphically, and leave Vertices at 32. We need pretty good resolution because this will become an essential component of our model. You'll be happy to hear that, unlike the previous tutorials, Blender happens to create the meshes for this model with the orientation that we want. So we won't need to rotate the objects. CTRL-LMB on Cylinder in the Outliner window to the right, and key in the object name ”Torso”. When working with nested object animation, you must take the time to name your mesh objects appropriately. Memorize that although to replace text in Blender you usually SHIFT-LMB, in the Outliner you must CTRL-LMB.
-
Add an Icosphere with 3 subdivisions (if we were going to texturize this robot, we'd probably be better off with a UV Sphere). Don't worry that some of these items are obscuring one another. As long as the objects show up in the Outliner window to the right, you're all set. Rename the Sphere to Head in the Outliner.
Add another cylinder mesh, but this time we don't need as high resoution, so set the vertices to 8. Rename this Cylinder to
Thigh.L to indicate
Left Thigh. Here's what your scene should look like now:

Become Adroit at Object Selection
You really must be adroit at object selection if you are doing to do nested object animation. Play with the Outliner window and notice that you LMB on Objects (items with tri-arrow icons) to select then, and SHIFT-LMB to select multiple. The remainder of this section assumes you know how to comply if I just say to select specific objects.
Click on the eyeball icons in the Outliner to see how you can make objects transparent.
Become adroit with “a”, RMB, and SHIFT-RMB with Object Mode in the 3D view to select objects.
Size and place the base meshes. It would be worth your time to practice these idioms until you have them down pat. These placements eliminate much repeated manual adjustment and final model imprecision due to eyeballing.
The only thing that we have sized so far is the height of the torso. Therefore, we'll size everything to agree with the torso height. Since the torso will be the root object of our robot, we will also locate all other meshes with respect to the torso.
Toggle off all of the mesh object icons in the Outliner other than the one for the Torso, and select just the Torso.
Numpad 7 (in 3D View) to view our model from the top.
In the 3D view, “s” “y” and mouse to re-aspect the torso as shown. No need for precision here.

Still looking down from the top, change the eyes so that you can see both Thigh.L and Torso, with only Thigh.L selected.
Use “s” and mouse to scale down the Thigh until it is a little inside the torso (i.e.. when the leg just becomes invisible inside of it).
Do the same thing for the head. With only Head and Torso visible, and only Head selected, scale the Head down until just the front and back bulge out beyond the torso somewhat.
Numpad 1 to switch back to front view.
Head should still be selected, so “g” “z” to translate the head up to sit above the torso, with a smidgeon of overlap. Our robot has no neck. You can use “s” to adjust the head size if the proportion looks wrong.
Turn on all all the eyeballs in the Outliner, then translate the Thigh.L down about a meter below the body (just temporarily).
“s” “z” and mouse to scale Thigh.L until it is about 2/3 the height of the torso which you can see above it.
“g” “z” to translate Thigh.L up until the torso overlaps it a smidgeon, just like we did with the Head before. Yes, I realize that we have the leg in the center of the body.
Complete the Robot Components
“D” then “z” and use mouse to position the copy of Leg.L downward.
Rename the new object to Foreleg.L.
“s” to scale Foreleg.L to be a little smaller than Thigh.L.
“g” “z” to translate Foreleg.L to it inserts into Thigh.L a little.
Select both Thigh.L and Foreleg.L and “g” “x” to position them to your right (robot's left) to where they look natural.
Numpad 3 and SHIFT Numpad 3 to check sizes and positions from the left and right. Use “g” and “s” to adjust as necessary.

Back to the front view, with both Thigh.L and Foreleg.L selected, ALT-d then X to move the new leg to your left, symmetrically opposed to the first leg. Normally you should use mirroring to automatically mirror work on symmetrical body members, and the Blender manual and several tutorials cover explain how to do that. TIP: Use ALT-d to copy instead of “D” unless the source and destination meshes will have their shapes differentiated anytime in the future, including Skin & Bone deformation. ALT-d makes a deep link instead of a copy. A future version of the exporter will generate com.jme.scene.SharedMeshes from these.
Rename the new thigh to Thigh.R and the new foreleg to Foreleg.R.
Nest the Robot components
Select just Foreleg.R then select Thigh.R also. CTRL-p and Make Parent. In the same way, parent Foreleg.L to Thigh.L.
Select Thigh,L, Thigh.R, and Head, then add Torso to the selection last. CTRL-p and 'Make Parent' to parent the 3 objects to Torso.
Expand the nodes under Torso in the Outliner window and compare your object nesting to that shown here:

Relocate Joints. For nested animation models, mesh origins are the joints. Therefore, we need to translate the mesh origins.
Now we're going to move the insertion cursor. Numpad 1 to make sure you're looking from the front. LMB and click on the center of the knee between Thigh.L and Foreleg.L. Numpad 3 to see that Blender left the y position at 0, then Numpad 1 back to front view.
Select just Foreleg.L and click the square mesh icon in the Buttons window to bring up the Mesh buttons.
Click the Center Cursor button in the Mesh panel of the Buttons window. Notice that this moves the origin indicate dot for Foreleg.L from the middle of the foreleg to where you placed the cursor. (NOTE: We should have really relocated the joints before duplicating the symmetrical members… I forgot to then, and I'm not going to redo this section).
In the exact same way, use the Center Cursor button to translate the member origins for Foreleg.L, Thigh.L, Thigh.R, and Head.
Translate the origin of Foreleg.R to the center of the right knee
Translate the origin of Thigh.R to the top of Thigh.R
Translate the origin of Thigh.L to the top of Thigh.L
Translate the origin of Head to the bottom of Head
Transform the Robot in Blender
Save your work.
Numpad 0 then MW to scroll in, to see the robot at a gentle angle.
Select Different Objects, just one-at-a-time, and rotate them with “r”. The goal isn't to save any changes to your model, but just to observe the effect of these translations.

You should see opportunities to improve animations by adjusting amounts of overlaps between members, locations of origins/joints, etc.
Export Robot
Load the copy that you saved before you played with the transformations.
Export, making sure to set * in Scene.
Import Robot into jME
-
Move the camera around with WSAD (or arrow keys) and click&drag, like normal jME SimpleGame, to view the robot from an angle. The SHIFT key increases the movement speed.
Use SHIFT+F7 and SHIFT+F8 to bring up two widgets and click&drag to position them to the edges.
Click on nodes in the tree below the Torso (items with the red and blue node icon) to select them, then change the X angle rotations by using the first Euler field in the Spatial properties widget, and hit “apply”.

All that the Modeler program is doing is applying Spatial.getLocal*().set*() methods to the Spatials which you select.
We have to move on to other subjects now, but hopefully you can deduce how your programs can automate these movements, say to make a head turn to watch a moving game world object, or for a turret to turn and aim its guns, or to make the avatar walk,
jME's SpatialTransformer class works great with Nested Object models.
I wish I had the time to work up an example using a SpatialController to toggle walking animations for our robot.
Email me if you want to see this.
In this section we are working with Skeletons.
Not the kind of skeleton you can see, but the invisible rigging that is implemented as a tree of Blender Bones which are exported into jME as com.jme.animation.Bone s.
Even if you are interested in boned animation and couldn't care less about nested object animation, I must insist that you work through the Nested Objects section above, because I am not going to repeat all of the essential stuff that I already covered there.
You need to pay full attention to this chapter, because the following sections will assume you understand this one.
We are going to make a very small, but far from trivial, skeleton, of a woman.
Start up Blender. Save the scene to an approriately named .blend file, and fix the Outliner.
Create base skeleton
Add / Armature
Expand the Armature in the Outliner window until you can see “Bone”. CTRL-LMB click on Bone and key in ”Spine”.
SHIFT-LMB int he LocX field of the Transform Properties widget and key in ”1”.
In the same way, set LocZ to ”-1'”.
We moved the armature from the origin because armatures are often offset from the origin, and for training purposes this will allow us to differentiate between something being located at the scene origin vs. something being located at the armature origin.
Now zoom in with MW so that the armature is near the bottom of the window. Just as in the previous section, we are going to work in our target game scale to eliminate any extra integration steps to get this model into a game.
Don't scale the armature or the bone. The bone will get sized exactly as we need it just by positioning the Tip later on.

Now, what I really wanted was to have the woman positioned standing on z=-1. We could move the armature, but we'll learn more by moving the spine bone to where we want it. TAB into Edit mode, select the Spine bone and “g” “z” upward until the Root end of the bone is at about -0.2. Notice that the pink indicator of the Armature origin location did not move. (Take my word for it that these modifications are not as pointless as they seem. We will learn some important things from them later on).

Still in edit mode, select just the Tip of the Spine, “z” “z” to reposition it to where her neck would be at about z=+1.4.
“e” “z” and drag upwards to about 1.64 and LMB click. Use the Outliner window to rename this bone to Head.
RMB click on the center of the Spine bone to select the entire bone again, and “e” “x”, dragging out to about 0.5 and LMB click. Rename this bone to Arm.R.
Repeat the previous step to create Arm.L (we would use mirroring to do this for anything more substantial).
Now, you may notice that we need a collar bone or the arms won't move realistically. That's right, except that the collar bone would serve no purpose except to offset the arm pivots, and we don't need an extra bone for that. With the entire Arm.L or Arm.R selected while in Edit mode, go down to the Buttons window and de-select Co in the Armature Bones panel. Go back to the 3D view select another bone then select that arm again, to force Blender to see your property change. Now “g” “x” in the 3D view and offset the arm an appropriate distance from the neck. Repeat for the other arm.
We could do the same exact thing for the thighs, but instead we're going to make our model a gymnast whose thigh bones are connected to her body, but are not effected by every single rotation of the spine. If you're having trouble seeing the singificance, now we can rotate her spine to make her do toe-touches. The spine rotation will cause the disconnected arms to move, but not the legs; yet if the Armature Object or the Armature itself rotate or move, the legs will go with. With any bone selected, “e” to extract a new bone of any length and direction. (POSTNOTE: An easier way to create additional root bones is to select just the root end of any root bone and “e” to extend from that).
Select the entire new bone and back in the Armature Bones panel, use the pulldown to change ”child of:” to nothing at all.
In the Outliner, rename this new bone to Thigh.L.
Once again. select another bone and select Thigh.L again. Blender is really bad at applying bone attribute changes.
“g” and move the Thigh.L Root end down to where it belongs, to the right side (as you face her) of the Root end of the spine. Just ignore the bone body and the Tip for now.
Select just the Tip of Thigh.L, “g” and shorten the bone and move it in so the thigh is positioned nearly vertically.
Select the entire Thigh.L and “e” “z” to extract the foreleg down to z=-1.
Rename the new foreleg bone to Foreleg.L
Select all of Thigh.L and Foreleg.L and “D” “x”, translating the copies to your left until the hip joint is at the right place.
Select just the right knee, “g” “x” and move it to your left a tad, to match the other side. Do the same thing for the right foot.
Rename the new bones. I think you can figure out the naming convention by now.
Before leaving Edit mode, select all bones and do CTRL-n, Clear Roll….
You probably want to save your work now. Your skeleton and Outliner should now look something like this

Strike some poses. So far we have only modified the rest positions of bones. This is the position that the bones will take in jME before any Controller effects them. Back to Blender, the rest position is the position you will always see when in Edit mode. Object mode and Pose mode, however, will always show the bones as posed for the current Frame. We're not going to save any poses in this section, so you can just ignore the concept of frames for now.
Switch to Pose mode by Selecting Pose under the Armature in the Outliner windows (you could also use the 3D View pulldown).
We only have time to investigate FK rotational translations, which are by far the more important type for animal models. Therefore, select the Spine bone, R and rotate it. Notice that the whole upper body follows it because, as the Outliner shows, everything up there is a descendant of the Spine.
Rotate the other bones and see that only the Spine and the Thighs have cause dependent rotations.
Tab back and forth to Edit mode to see how Edit mode knows nothing about poses, only the rest position.
When you have played enough, go back to Pose mode, “a” until all bones are selected, then ALT-r, Clear rotation. Now the Edit mode (i.e. rest) position will match the pose positions of Pose and Object mode again.
GOTCHA: It's quite confusing that most Blender modes show the ephemeral pose state instead of the rest position. I'll clarify and advise on this point when we start working with Actions. Normally you would ALT-r, ALT-g, and ALT-s, but we are only working with rotations so far.
Export the skeleton. When you export an Armature object, it always and automatically exports all the Bones of that armature.
Load with the skeleton into Modeler
If you still don't know how to load a *-jme.xml file into Modeler, you're not listening.
You may be disconcerted. The Armature is listed in the tree, but nothing appears in the game world. Use ALT+“v” “b”, or the corresponding pulldown menu, to toggle on the bone debugger.
If you haven't already, click / to display a grid. Move the camera a little so you can see the XZ plane grid. You can see that the skeleton is located and oriented correctly, corresponding to how it is in Blender.
There are a few important things to understand here.

First off, you may not even recognize the skeleton until you understand that there is an extra bone depicted here, the Super Bone. The super bone is a bone automatically created by the exporter which represents the entire skeleton/armature. This is required to support multiple root bones, since com.admc.animation does not support skeletons with more than one root bone. The bottom-most red ball that you see is the Super Bone. White lines connect the Super Bone to each Blender root bone. For the sitation of a Blender Armature with a single root bone with no offset from the Armature Object location, the Bone Debugger would give you no visual indication of the Super Bone at all, since the root bone would sit right over top of it.
No indication of the leaf bones is shown. That is not quite correct. Actually, what the Bone Debugger shows you is just the red Root end of each bone, with thick white lines connecting them. The white lines stricly depict only parenting between the red bone roots. Unfortunately, without the white line, we can't tell anything about the rotation of the leaf bones, since all we see about them is a red ball. The crucial thing to understand here is that jME Bones do not have an extension or multiple points. They have simply a position and a rotation. The red balls in Bone Debugger shows you the position of the Bone; and the white lines will indicate the rotation of the Bone only if this bone has a child and the child is Connected in Blender (or has zero offset).
The debugger shows the arm bones as children of the bottom of the spine. This is actually 100% correct, as you can verify by either the Blender Outliner or the Modeler tree widget. It's just a little non-intuitive because the lines depict parenting and give no indication of the bone offsets that you can use in Blender.
Add Dummy Leaf Bones to our Skeleton
Close up the Modeler and open your skeleton model in Blender again. We're going to add dummy leaf bones because without them, we can't see the effects of bone transformations in jME: the whole point of the jME Bone Debugger.
Select each leaf of the Armature in turn. Make sure you are in Edit mode, and “e” to extend a bone. Makes no difference what direction of length you make them, since they are just dummy bones.
Select each bone in turn (the whole bone, like by RMB clicking in the middle in 3D View in Edit mode) and click off the Deform toggle button in the Selected Bones panel of the Mesh Buttons panel.
Grab the divider between the 3D View and the Outliner and LMB drag it to the left until the Outliner is wide enough to show most of the names of the new leaf bones.
Rename all of the dummy bones with names which make it very clear that they are dummy bones.
At this point, things should look something like this.

We don't want these dummy bones getting in the way of real work, so toggle off the eyeball icons for every dummy bone in the Outliner.
Switch to Pose mode and notice that the dummy bones have re-appeared in the 3D View, and the bones have eyeballs under Pose in the Outliner. This is because, just like for bone positions, Object and Pose modes share one set of eyeball (visibility) settings, and Edit mode has another set. Just turn off all of the eyeballs for dummy bones under Armature / Pose in the Outliner.
Save. You don't want to do this again.
Play with the skeleton in Modeler. Export the model from Blender and import into Modeler again.
Now things should really make sense to you. Increase the spine Euler X rotation, exactly as described in the previous section. Notice that she can do toe touches as I explained.

Rotate other bones and verify that parenting works as you expect.
GOTCHA: It's quite confusing that most Blender modes show the ephemeral pose state instead of the rest position. Worse that that, non-rest ephemeral bone positions will screw up scripts which don't explicitly check for them. By ephemeral, I mean this is whatever you happen to have posed the bones to. It won't be saved to any frame unless you explicitly do so with “i” (as we will do below), but can and does silently effect other items that you need to save.
Load up your skeleton in Blender again. We're going to create two Actions. Action is what blender calls their named skeletal animation sequences.
Select the armature and enter pose mode (one way of doing this is closing on the Armature's ”Pose” child in the Outliner window).
Select all bones with “a”. Make sure the Buttons panel is showing the Mesh buttons. Notice that the frame indicator to the right of the toolbar says ”1”, meaning frame #1 (unlike jME frames, these start at 1 instead of 0).
“i”, LocRot to write frame #1. Notice that the Action Editor window to the bottom right finally populates with something meaningful.
Notice that the Action Editor now shows channel diamonds in the column for frame 1, This is a key frame.
Use the Outliner window to rename Action to staticPoses. We are actually not using this Action for animation, but simply as a workaround for Blender's lack of an easy way to clear pose positions. From this point on, Rest Pose Frame means frame #1 in your staticPoses Action, or more generally, any saved frame containing the rest poses of all bones.
For now on, whenever you are finished posing, for weight painting, key framing, or other purposes, restore the rest pose selecting the Rest Pose Frame. I.e. set the empheral pose to your Rest Pose Frame poses by selecting Action ”staticPoses” then selecting frame #1. If your armature has any Action defined, you must always have a rest pose selected before exporting any object that has an Action. Even if you are exporting the Object without the Armature with the action, the Action would still hose the export. If you have the Rest Pose Frame active already, but the exporter says it is not, then your Rest Pose Frame positions have become out-of-sync with your edit positions. In this case, select all bones in pose mode, ALT-r, ALT-g, ALT-s, then “i”, LocRot to re-save updated rest poses for all bones.
Now use the pulldown in the Action Editor window to create a new Action and name it ”Walk”.
First we are going to set the pose for the exact mid-point between strides. Select each arm in turn and use “r” to rotate them down to hang down, poised outward slightly.
Numpad 3 to look at the skeleton from the right side.
Select each thigh in turn, and rotate them forward just a little.
Select each foreleg in turn, and rotate them backwards a little. We're modeling the legs to reflect the fact that you don't walk with legs fully straight. I would definitely bend her elbows too, if she had any– ha!
Click “a” until all bones are selected.
Make sure that frame #1 is the current frame, then “i” and select
LocRot. This will save key frame frame 1 of Action
Walk..
A couple important considerations which apply only to animation start frames: You should include in the Selection every bone that will have a channel in any frame of the animation; and you should LocRot to initialize both translations and rotations even if you plan on changing only translations or only rotations.

SHIFT-LMB on the frame number to the right of the Buttons window toolbar and change the frame to 21.
Select just the leg bones (all of them) and save keyframe 21 with “i”, Rot.
Note that for efficiency, we are storing only Rots, since we are only posing with rotations in this example; and that we select only the bones that we want to modify for this frame (in this frame we want to reset the leg rotations we'll make in frame 11 later on). Bones which have channels but which are not included (Selected) in the current keyframe will just interpolate as if this keyframe was not present.
Switch to frame 41 and save another keyframe in the same exact way we did for frame 21.
Change the frame to 11 and lets pose the left-leg-forward stride.
Rotate the left thigh forward and the left foreleg backwards a little.
Rotate the right thigh backwards.
Save key frame 11 as usual.
Copy the bone poses of frame 11 by clicking on the 3D View icon showing a little arrow pointing down to orange. I am running with a tiny little window just to make good res screen shots, so I had to close my Outliner to show this.

Switch to frame 31 and use the little icon two to the right of the save-to-buffer button that you just used. This loads the poses from the buffer, with *.L bones swapped with *.R bones. It understands a couple other symmetry naming conventions too.
Save key frame 31 as usual.
Click and drag the green current frame horizontally in the Action Editor window to animate the figure with the poses. Blender uses Bezier interpolation (by default) to interpolate motion between the key frames.
Select your Rest Pose Frame as described above. You always need to do this before making an export an object used in an Action.
Save and export. As long as you leave the Blender animations button set to Include, the Action will export when you export the Armature.
Load into Modeler. Remember to turn on the Bone Debugger with ALT+“v” “b” or the pulldown menu.
Use SHIFT+F7 and SHIFT+F8 to bring up two widgets and click&drag to position them to the edges.
Move the camera so you look at the skel from the side. As shown in the diagram, select the SuperBone in the tree, then use the pulldown in the Spatial Properties widget to select and execute the Walk action.
(Note: The screenshot shows the super bone named ”ArmatureRootBone”, but your version of the exporter should write ”ArmatureSuperBone”.)
You can nest regular (non-skinned) mesh objects under individual bones, and they will transform with that bone as expected.
If this tutorial weren't so long, and my time so short, I'd add an example of that.
The great difference between this and Skin & Bones is that there is no pixel-by-pixel deformation here,. The whole nested object (which could be a bushy collection of Meshes) transforms as a single, solid object.
Follow the instructions in the Basics Tutorial about programmatically loading jME XML files into jME apps. The only additional piece you need is to use Spatial.getController() or Spatial.getControllers() on the imported SuperBone Spatial. You can use the methods documented in the API spec for com.jme.animation.AnimationController and com.jme.animation.BoneAnimation to select, start, stop, and so forth, the individual BoneAnimations which correspond to Blender Actions.
Here is the content of the XmlAnimator sample class, stripped of the copyright boilerplate. This class works fine for plain skeleton animations like we made in this section, as well as for normal skin & bones animations. The full source code is available for viewing or download here. This is a subclass of the XmlWorld class presented in the Basics Tutorial.
import java.net.MalformedURLException;
import java.util.List;
import com.jme.scene.Controller;
import com.jme.scene.Spatial;
import com.jme.animation.AnimationController;
import com.jme.animation.BoneAnimation;
import com.jme.animation.Bone;
/**
* Sample SimpleGame class which extends the behavior of XmlWorld to execute
* the first animation of a Bone named with suffix 'SuperBone.
* This Spatial will be created automatically by the * Blender ==> jME Exporter
* if your Blender scene has an Armature with Blender's default name of
* 'Armature' (and you select it for export).
*
* @author Blaine Simpson (blaine dot simpson at admc dot com)
* @see #main(String[])
*/
public class XmlAnimator extends XmlWorld {
/**
* Instantiate a jME game world, loading the specified jME XML models
* into the scene, then executing the first animation present.
*
* @param args
* <CODE><PRE>
* Syntax: java... XmlAnimator [-r] file:model1-jme.xml...
* </PRE><CODE>
* where "-r" means to display the settings widget.
*
*/
static public void main(String[] args) throws MalformedURLException {
XmlWorld.parseAndRun(new XmlAnimator(), args);
}
/**
* Loads and runs the animation.
*/
protected void simpleInitGame() {
super.simpleInitGame();
AnimationController ac = getAnimationController();
System.out.println("Available animations:");
for (BoneAnimation anim : ac.getAnimations())
System.out.println(" " + anim.getName());
ac.setActiveAnimation(0);
System.err.println("Executing animation '"
+ ac.getActiveAnimation().getName() + "'");
}
/**
* Gets the AnimationController of the descendant Bone Spatial named
* 'ArmatureSuperBone'"
*/
public AnimationController getAnimationController() {
List<Spatial> armatures =
rootNode.descendantMatches(Bone.class, ".+SuperBone");
if (armatures.size() < 1)
throw new IllegalStateException("Sorry. Program assumes "
+ "you have a node named with suffix 'SuperBone'");
if (armatures.get(0).getControllerCount() != 1)
throw new IllegalStateException(
"Armature should have 1 controller, but has "
+ armatures.get(0).getControllerCount());
Controller controller = armatures.get(0).getController(0);
if (!(controller instanceof AnimationController))
throw new IllegalStateException(
"Controller is of unexpected type: "
+ controller.getClass().getName());
return (AnimationController) controller;
}
}
Skin & Bones is the system where a mesh of vertexes and normals is deformed by weightings by associated bones.
Much more computing is required of the game engine for this than for nested object animation.
To use skin & bones in your game, you need to have a Blender Mesh Object, a Blender Armature Object, and then associate the Mesh to the Armature, and specify how much influence each bone of the Armature has on each pixel of the Mesh. The Mesh in this association is referred to as the Skin.
Create a simple Skin Mesh
Start up Blender with the tutorial template file, save as a new name, and fix the Outliner.
We're going to create a quadruped skin mesh as fast as possible, because the goal of the tutorial isn't about making high quality meshes. You can apply what you learn here to high quality meshes, but we don't supply them. I don't want to dignify the creature which may result by a species name.
Create a Ico Sphere Mesh Object with 4 divisions and radius .3.
Rename the Object to Body.
MW scroll in so that only 2 of the original grids fit across the width of the 3D View.
“s” “x” and stretch until it looks like a quadruped's torso.
SHIFT-LMB on RotZ and key in 90 to face our… quadruped forward. Cute, isn't he? (There's a much quicker way to apply exact numeric changes, but it doesn't work for changing non-zero values to an absolute: just key in “r” “z” “90” ENTER.)
Add a cylinder with 8 vertices radius .05, Depth .3. You won't see it appear because the quadruped ate it. (It's really looking like a sheep. Am I too tired to be working on this?…)
“D” “z” to duplicate the hidden cylider then raise it up, leaving like 50% overlap with the torso. This will be the neck.
RMB click the center of the torso until (just) the other cylinder is selected (or select it with the Outliner). Use “g” to move this leg to a correct front-on position for a leg. Leave a little overlap with the torso.
“D” “x” and move the leg copy to the other side of our… lamb.
Numpad 3 to look at the lamb from the right side.
Select that neck up, “g” “y” and move it to the left where a neck should be. R and angle it to the left a little.
Add another Ico Sphere Mesh Object. This time with 4 divisions and radius .15. “g” and stick it onto that neck, with overlap.
Select both legs and “g” “y” to move them towards the frome while still allowing for a tiny overlap.
“D” “y” and move the back legs towards the butt in the same way.

Now select all of those mesh objects, and make sure to select Body last. CTRL-j, Join Selected Meshes.
Save. Skin Mesh completed. Hm. Looks more like a duck now.
Create Armature
Add / Armature and rename the root bone to Spine. If your insertion cursor has moved, select the mesh Object and “S” Cursor → Active before creating the Arma.
Regardless of whether you create the armature object first or the skin object first, when they are paired, these two objects must have the same exact transform values. With the “n” widget up in Object mode, RMB back and forth between the two and if necessary change the Loc, Rot, and Scale values to match the partner object.
Click the X-Ray button in the Armature panel of the Mesh Buttons panel, so we will be able to see the bones through the sheep.
“g” to translate the entire armature so that the root bone's root end is in the middle of the torso above the rear legs.
TAB into edit mode. Select just the tip of Spine and move it so the spine becomes horizontal and stops about where the neck would intersect.
“e” and exend a neck bone up to the base of the head.
“e” and extend a head bone to the top of the head.
Use the Outliner window to rename these new bones.
Select just the Root end of the Spine bone and extend a new root bone. Blender's kinda unreliable with this, so you may have to select other objects and retry it a couple times.
Move the camera around and use “g” (repeatedly if necessary) to get the new bone's Root end to where the sheep's thigh bone joint should be. Make sure to check it from multiple directions.
Select just the tip of the same bone and “g” it to the corresponding foot.
Select the entire new leg bone, “D” “g” to move the new leg bone to inside another leg.
Repeat until the duck has all 4 legs. Rename the legs like
Leg.FR for Front/Right and
Leg.BL for Back/Left.
(NOTE: I am not using automatic symmetry mirroring for this tutorial. I'm guessing wildly about the supported name conventions for front/back members. I do use plain *.L and *.R for real all the time.
.)

We don't have any non-deform bones, i.e. bones which are used for parenting but which should deform no skin vertexes. If we did have non-deform bones, we would need to use the Armature Bones panel of the Editing Buttons panel for the Armature and click off the Deform toggle button for each such bone. This must be done before applying bone heat, for obvious reasons.
If any extra bones were created, just select and DEL key them.
Before entering pose mode (i.e., as the last change you make in edit mode), make sure to “a” select all bones and CTRL-n, Clear Roll…
Make the Body Mesh Object into a Skin by associating it with the Armature Object.
TAB into Object mode and select the Body Object.
Open the Mesh Buttons window and click Add Modifier in the Modifiers panel. Select type Armature.
Click Envelope to disable that settings (that is no help at all for exporting). Verify that Vert Group remains set.
SHIFT-LMB on the Ob: field and key in ”Armature” (must the the exact name of the Armature Object to link with).
In the outliner, click on Pose to switch this Armature to Pose Mode.
“a” until all bones are selected in pose mode. (If you had posed anything before now, you would need to ALT-r, ALT-g, ALT-s and clear the bone poses).
Select Body then change the 3D View mode to Weight Paint”.
Type “w”,
Apply Bone Heat… to automatically generate vertex weightings for all bones other than non-deform bones. I know of no way to select multiple bones at once while inside the Weight Painter, so you must select them in Pose mode (like we did above) then switch to Weight Paint mode.
NOTE: IMO, the Weight Painter should not allow you to manually assign weights for non-deform bones, but it does. Be aware that weights assigned for bones with the Deform option off will have no effect.
Now select bones and rotate them, as if you were in Pose mode, to see if you are satisfied with the deformations. You can adjust the automatically applied bone weights by selecting a bone and Adding or Subtracting the influence of that bone upon mesh pixels. Towards red approaches 100% influence. Towards blue approaches 0% influence.

Weight Painter mode is yet another mode that shares the pose state with Object and Pose modes. Unless you know of a way to select all bones inside of the Weight Painter, after you exit, enter Pose Mode, select all bones, and ALT-r to clear all rotations. (Normally you will ALT-r, ALT-s, and ALT-g here).
Add dummy bones onto the 5 leaf bones. I do this late in the process to keep things less cluttered until we need them, but you can create them earlier as long as you turn off the Deform options. Same exact procedure as when we added them to our skeleton in the previous section. Remember to disable the Deform option for the dummy bones, and to turn off visibility under both Pose and Armature in the Outliner window.
Export and Load into Modeler
In modeler, rotate the bones just like in the previous section. One important thing though, in Modeler the skins will not deform to reflect bone movements until you select the skin node then click the bone refresh button in the Properties widget. The reason is that the
com.jme.animation system only updates skins if its animation controllers are in charge or if you run
.boneChanged(null) on the skin mesh
Node. This second is all that Modeler does when you click that button.

The skin deformation of our example model would have been much more impressive if I had added more vertexes to the meshes around the joint areas. I wanted to, but I am too pressed for time. You can enhance the appearance of your own deformations this way though, by using Subdivision, subsurf, or other Blender tactics to selectively increase pixel density.
Another thing that I would have liked to shown you if I had had time, is how you can hang props on bones, and the props will follow the bones just like the skin, but without deformation. I did touch on this at the end of the previous section, but this really takes on importance when combined with skin & bones animation. There are many reasons why you should usually not include non-deformable objects like a sword or a torch in a skin mesh, including the difficulty switching the prop at runtime, and the performance cost of unnecessary bone-weighting. At the risk of leaving the domain of a tutorial and becoming descriptive, I'll briefly describe how you can implement this powerful tactic on either the Blender or jME side.
In Blender, just parent Mesh Objects, or even trees of Mesh Objects, to a bone. It's easy enough to do, once you know the trick. Select Pose mode for the Armature (I prefer to use the Outliner window to do that) and select the target bone. Then select the skin object followed by the armature object and CTRL-p. You can select Parent to Bone.
In jME, just parent Spatials, or even trees of Spatials, to a bone.
This is the traditional, non Modifier method of associating the skin mesh to the Armature.
The procedure described above uses an Armature Modifier, because that seems to be the new method preferred by the Blender people.
Just as for the modifier method, you need to toggle off Deform for all bones that you don't want to deform the skin before applying bone heat, as described above.
Instead of creating an Armature Modifier:
Put the Armature into Pose mode.
Select the skin-to-be Object followed by the Armature Object and CTRL-p, Parent to Armature.
Select Create From Bone Heat.
This results in automatic Bone Heat weightings to each non-no-deform bone, the same as if you did the Weight Painter “w” procedure with all bones selected.
You can then adjust bone weightings with the Weight Painter if you wish to, the same as if you used a Modifier.
In this section you learned how you can programmatically transform bones in your jME app, and the skin will realistically deform accordingly. The next section shows how you can design animation sequences for the bone movements in Blender. You can also, however, use controllers such as jME's com.jme.animation.SpatialTransformer, combinations of existing controllers, or custom controllers, to execute animations on skin & bone models as explained in this section. Custom controllers can leverage your own design conventions so that a single controller can make a model perform a set action (like walking, clapping, etc.) with no model-specific design work.
If you have actually worked through the tutorial to here, then congratulations, because now you know how to create Blender skin & bone animations, export them to jME and execute them in your games.
Create your skin & bones model as explained in the Skin & Bones section above; then create Actions, export, load into your game, and finally execute the actions, all as described in the Skeletal Animations section above. You may want to start with the sample code in the Loading Blender Animations into your own Apps .
Multiple models which are anatomically similar can have unique skin meshes but copies of the same armature. jME and the exporter can't yet exploit all of the possible efficiencies, but you can certainly use Blender Object copies (or links) to re-use armatures on the design side. Imagine the design work you can save, and the quality consistency you could achieve, by using a single, excellent Armature with 20 tested animations, as the skeleton for a hundred different adult human models.