Problems with programatically constructing a Skeleton & viewing it with SkeletonDebugger


I’m trying to programatically construct a skeleton and view it in a viewer program via a SkeletonDebugger. The issue is that I’m getting some very strange behaviour from SkeletonDebugger, and I’m not at all sure why. Here’s the relevant code:

[java]//construct the node

Node node = new Node();

//construct the bones and the bone array

Bone root = new Bone(“Root”);

Bone child = new Bone(“Child”);

Bone child_two = new Bone(“ChildTwo”);

Bone endsite = new Bone(“EndSite”);

Bone[] bones = {root, child, child_two, endsite};

//set different positions for the child bones

child.setBindTransforms(new Vector3f(0.0f, 1.0f, 0.0f), Quaternion.IDENTITY, Vector3f.ZERO);

child_two.setBindTransforms(new Vector3f(-1.0f, 2.5f, 0.0f), Quaternion.IDENTITY, Vector3f.ZERO);

endsite.setBindTransforms(new Vector3f(1.0f, 3.0f, 0.0f), Quaternion.IDENTITY, Vector3f.ZERO);

//add the children - this is the desired result, but for some reason, SkeletonDebugger

//will not show any children of the root bone’s children, or any of their children either




//They are visible if they are added as children to the root bone - but this

//is not the desired end result, it is only a test to see if they would be displayed

//by the SkeletonDebugger



//Set up the Skeleton and SkeletonControl, add the SkeletonControl to the node

Skeleton skel = new Skeleton(bones);

SkeletonControl control = new SkeletonControl(skel);


//Set up the SkeletonDebugger with the Skeleton constructed above

SkeletonDebugger skeletonDebug = new SkeletonDebugger(“skeleton”, skel);

//Print out the bone indices - not significant, only for debug purposes

for(int i = 0; i < skel.getBoneCount(); i++){

Bone b = skel.getBone(i);

System.out.println(b.getName() + " " + i);


//Set up the material on the SkeletonDebugger - borrowed from

Material mat2 = new Material(getAssetManager(), “Common/MatDefs/Misc/Unshaded.j3md”);


mat2.setColor(“Color”, ColorRGBA.Green);



//Part of the code borrowed from - not sure if this is significant

//to the bones being displayed




The skeleton is attached to an empty node - this is because the point of the viewer program is to view the skeleton only for debug purposes, without it being attached to an actual mesh object. The comments in the code above pretty much explain the issue I’m having. If I comment out the two lines that add child_two and endsite to the root bone, then only the root bone and child are displayed, even though child_two is properly added as a child of child and endsite is properly added as a child of child_two. I’ve done some other experiments, and any bones added directly as children to the root bone will be correctly displayed. The only issue is that children of children of the root bone are never displayed, unless they are added as children of the root bone also, which is both incorrect in structure and results in a web of green lines rather than a tree.

I searched and re-searched the JavaDocs for any explanation as to what had to be done to properly construct a skeleton to no avail. I also looked at the relevant source of the Ogre SkeletonLoader in detail, but didn’t see that it was doing anything differently than I was doing.

I would very much appreciate any relevant info that may be of use in figuring this one out… thanks!

You may need to call update the Skeleton object, otherwise the intermediate data that is used by SkeletonDebugger is set to invalid values.

I’ve altered the above code to call skel.updateWorldVectors() both immediately after the skeleton is created but before the SkeletonDebug is attached and in simpleUpdate(), but it’s still behaving exactly the same.

Edit: I’ve also tried calling updateLogicalState() (from simpleUpdate()) on the skeleton debugger as well as the node, but neither makes any difference.

Edit2: I also called update() on the skeleton control from simpleUpdate(), but to no avail… I know the node’s updateLogicalState() is supposed to do that, but I wanted to check it manually in case something wasn’t quite right there. I also tried creating and attaching an AnimControl to the node, just in case there was a bug in the SkeletonControl that was keeping it from playing nicely without an AnimControl present since it seems like they’re usually used together, but that made no difference either.

Edit3: I ran it again, this time linking against a fresh build from SVN in case there was a bug that had been fixed. It’s still behaving exactly the same.

try changing Vector3f.ZERO to Vector3f.UNIT_XYZ on lines 12,13 & 14.

Hadn’t touched this project in a couple of years, but just went back and looked at it again. Changing Vector3f.ZERO to Vector3f.UNIT_XYZ fixed the problem. All child bones now display as they should.