Translating the bones of animations

So I am trying to get an animation that my friend has done in blender to move. The animation is of the character walking so I want it to be able to move with it. The problem is, before even trying to implement dynamic movement I can’t even seem to translate him normally without the animation screwing up horribly. After turning the skeleton debugger on it is clear to see that the bones are still located at the origin and I’m guessing this is why the graphical movement is so messed up.

I have tried looping through each bone in the skeleton and translating it (switching user control on then off for each bone) but no luck.



Thanks to anyone who can help!

that’s very strange…could you post your movement code please?

Well initially I just attempted to use Spatial.move(x, y, z) and that moved the character model fine, but the animation was severely altered. I then tried to move each individual bone in a for loop (which I am sure cannot be the best way) and still no luck…



This is my whole initCharacter method:

[java]private void initCharacter(Node node, AssetManager am) {

character = am.loadModel(“Models/Sardo/masked_guy.j3o”);

Vector3f pos = new Vector3f(120f, -0.75f, 120f);

character.move(pos); // This moves the model, but not the bones

//character.rotate(90f * FastMath.DEG_TO_RAD, 0f, 0f);

//character.scale(0.25f);

node.attachChild(character);



// Init anim

animControl = character.getControl(AnimControl.class);

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

animControl.getSkeleton().getBone(i).setUserControl(true);

animControl.getSkeleton().getBone(i).setUserTransformsWorld(pos, animControl.getSkeleton().getBone(i).getWorldBindRotation());

animControl.getSkeleton().getBone(i).setUserControl(false);

}

// The above simply didn’t work…

animControl.getSkeleton().updateWorldVectors();

animChannel = animControl.createChannel();

animChannel.setAnim(“walk_cycle”);



SkeletonDebugger skeletonDebug =

new SkeletonDebugger(“skeleton”, animControl.getSkeleton());

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

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

mat.getAdditionalRenderState().setDepthTest(false);

skeletonDebug.setMaterial(mat);

node.attachChild(skeletonDebug);

}[/java]



EDIT: Bare with me, I think I may have nearly fixed it…

Ok, don’t worry guys, it’s fixed :smiley:



Turns out my graphics designer managed to create the skeleton at a 90 degree angle from the actual model - he’s fixed it now.



Thanks :slight_smile: