MD5 Model adding child model (solved)

Hey everyone, I’m new to JME and I’m having some troubles getting my models to behave the way I want them to.



I’m using JME2 and Neakor’s MD5Importer along with a couple models I have, one of which is a body model, and the other a hand-held tool. My body model has animations in which it moves its hands, and this works quite well. My problem is putting the tool into his hand, and having the tool model follow the motions of the body animation (the tool model has no animations itself). The body model has joints corresponding to its hands.



I’ve tried to use attachChild() with the hand-joint, and then putting both the tool and the body in my update loop with swapBuffers(), but this seems to have no effect on the tool. attachDependent() moves the tool, but puts it in the wrong place.



Does anyone have any advice?







In case anyone else is dealing with this problem, my solution was:



-parent is the animated MD5Node

-child is the non-animated MD5Node tool

-“Rhand” is a joint on my parent model



To attach:

[java]parent.attachChild(child, “Rhand”);[/java]



In my parent’s update loop:



[java]if(child != null){

for(IJoint j : child.getJoints()){

j.updateTransform(new Vector3f(0,0,0), new Quaternion(0,0,0,-1));

j.processRelative();

}

child.updateMeshes();

}

[/java]



This can obviously be improved a bit, but it’s a start. Hopefully it helps someone :slight_smile: