More documentation for Bone, BoneAnimation, BoneTransform and BoneDebugger

I am looking for some examples about using BoneAnimation and BoneTransform to animate a Bone.

I try to migrate the MD5 Reader 2 to a full jME support, but I am unable to understand exactly how to:

  1. animate Bones;
  2. create a skeletal system/hierarchy;
  3. using BoneDebugger to make Bones visible.

    I made a simple test, but it does not work. At least I am not sure. It runs and something happened, as I have been able to test using a simple System.out.println() at the end of simpleUpdate() method. But I am not sure of what is happening. :smiley:


    package org.md5reader2.test;

    import com.jme.animation.Bone;

    import com.jme.animation.BoneAnimation;

    import com.jme.animation.BoneTransform;



    import com.jme.bounding.BoundingBox;

    import com.jme.math.Matrix3f;

    import com.jme.math.Matrix4f;

    import com.jme.math.Quaternion;

    import com.jme.math.TransformMatrix;

    import com.jme.math.Vector3f;

    import com.jme.scene.shape.Box;

    import com.jme.scene.shape.Capsule;

    import com.jme.util.BoneDebugger;

    public class TestBoneAnimation extends SimpleGame {

    private Bone bone;

    private BoneAnimation boneAnim;

    protected void simpleInitGame() {

    boneAnim = new BoneAnimation(“boneAnim”);

    BoneTransform boneTrans = new BoneTransform();


    // Setup times (each keyframe has a position in time).

    float[] times = { 0f, 1f, 2f };


    // Setup start/end frames.



    // Setup transforms.

    Matrix4f m1 = new Matrix4f();

    m1.angleRotation(new Vector3f(0f, 10f, 0f));

    Matrix4f m2 = new Matrix4f();

    m2.angleRotation(new Vector3f(0f, 20f, 0f));

    Matrix4f m3 = new Matrix4f();

    m3.angleRotation(new Vector3f(0f, 30f, 0f));

    Matrix4f[] transforms = new Matrix4f[3];

    transforms[0] = m1;

    transforms[1] = m2;

    transforms[2] = m3;


    // Setup interpolations.

    int[] interpolations = { BoneAnimation.BEZIER, BoneAnimation.BEZIER,

    BoneAnimation.BEZIER };


    bone = new Bone(“bone”);

    bone.setLocalTranslation(new Vector3f(0f, 0f, 0f));

    // bone.setLocalRotation(new Quaternion().fromAngleAxis(2, new

    // Vector3f(0f, 1f, 0f)));





    protected void simpleUpdate() {


    boneAnim.update(tpf, com.jme.scene.Controller.RT_CYCLE, tpf);

    System.out.println("Frame: "
  • boneAnim.getCurrentFrame()
  • "; Rot: "
  • bone.getLocalRotation()
  • "; tRot: "
  • boneAnim.getBoneTransforms().get(0).getRotations()[boneAnim


    BoneDebugger.drawBones(new Box("Box", new Vector3f(-1f, -1f, -1f),

    new Vector3f(1f, 1f, 1f)), display.getRenderer());


    public static void main(String[] args) {

    TestBoneAnimation app = new TestBoneAnimation();






I just found the TestSimpleBoneAnimation and it has been really usefull to understand some of the questions above. The sad thing is that the animation of the bones in that example is controlled by mouse movements and so I have no idea how to control bones animations programmatically.

Also, I read the code of AnimationController and finally I found what was the real Controller responsible for Bone animations. At least this is what it seems.

But now, that I have understood that BoneAnimations should be controlled by an AnimationController is still hard for me to figure out how to make all the things working together.

Would you like me to add another test using the TestSimpleBoneAnimation as a basis that makes use of an AnimationController? That should answer most your questions?

Do you have any specific questions that you need answered?

If you update from CVS I added a VERY basic AnimationController. It basically pops the bone into various rotations and translations over time. Ugly as hell, but should help.

Thank you a lot.

It seems that I made a lot of "trash" code. :smiley:

No need for update calls, neither in simpleRender() or in simpleUpdate() methods! :lol:

Thank you.