Attaching an object to a model


Is it possible in jme to attach an object to a model, which has animations?

For example a sword to a hand of a model, which is then translating and rotating with the animation of the model correctly?

Or will such a feature come with a ragdoll system? :?

If you use the new model animation system (which currently only supports MD5 models) from here:

That allows models to be attached as children of a particular bone on another model. Currently the head used in the marine test is attached as a child of the shoulder bone of the body.

I have been running into the same problem.

I have an animated model of a dwarf. In one of his hands he has an axe. Its a milkshape model but i also tried converting it into different formats.

Now i thought that if i had an object (like lets say the axe) and could attach that to a hand and then it would move RELATIVE to the movement of the hand.

Using a clever animation for the hand i wouldnt need any seperate animation for the axe itself.

But i have run into different problems.

First of all in the end there is only ONE node. Under that node i find all the other groups as trimeshes (3ds) or jointmeshes (ms3d).

I cant add any node to a trimesh.

So i dont know if at all it is possible to add some object to a PART of a model.

Now i thought it would at least be start to attach it to the node of the model itself (as trimesh for example). Strange however is that i dont see any information in the node that tells me how the trimeshes are alligned and in what relative position to each other they are.

The node simply lists for example 4 meshes (body, left arm, right arm, axe), but i do not see any information that tells me anything about location. So i couldnt for example simply detach the axe from one arm and attach it to the other.

How is this supposed to be done ?

Os simply asked:

What do i need to do to have a basemodel (with some animations) and then attach one object to lets say the hand of the model ?

Does anyone have a solutiuon for this problem? I am facing it too.

It is possible to add multiple JointMeshes to a JointController. So, as a workaround until JointController directly provides a way of attaching meshes to joints, you could load your player model's skeleton in ms3d, design your sword around the hand joint's rest position in ms3d, and attach the sword model to the player's jointcontroller…

To clarify, I made an example using two xml files (you need a new cvs jME for loading jointcontrollers from xml) containing jointmeshes, but only one containing a jointcontroller. You can  load them like this:

Node dude = loadXML("runBody.xml");
Node headN = loadXML("runHead.xml");
JointController jc = (JointController) dude.getChild(0).getController(0);
JointMesh head = (JointMesh) ((Node)headN.getChild(0)).getChild(0);

For brevity, I won't spell out the loadXML method here, if you have problems writing one yourself, I suggest looking at the TestBinaryXML class.
The xml files are:

If you don't want to do what I explained in my previous post for whatever reason, here's a different approach.


  • blender for animating

  • armature (skeletal) animation

  • blender jme xml exporter (latest version from:

  • EDIT: The KeyframeController modification is no longer neccessary!currently, this modified version of KeyframeController:

  • a recent jME from cvs

(Eventually, KeyframeController might be updated in cvs, so you won't have to download it from my site anymore)


  • create an Empty at the position of your Armature's weapon hand. Rotate it so that it's z axis points to where a sword's tip would be. (Put armature in "Rest Position" mode for this!)

  • select the Empty, then the Armature, and switch to pose mode by pressing ctrl-tab

  • select the weapon hand bone (should become light blue), and press "ctrl-p". Select "Make parent to: Bone".

  • select your player model, and export it as jme xml. Check "Morph Target Animation" (once skeletal animation is working correctly, you can use that instead, but for now stick with MTA)

  • select the Empty, export it with "Object Animation" (turn MTA off)

  • load the player model into jme

  • load the second jme file, containing an empty Node with a SpatialTransformer, and attach it to your player model

  • attach your weapon model (hopefully modeled with it's grip at the origin) to the empty Node from the second file

Note that this approach uses blender's "Bone parenting". It is equally possible with "Vertex parenting", but won't rotate the weapon model, only animating it's location.

Hi hevee, I'm currently not up to date on all the model stuff. Maybe cep will be back again for a bit, but if not, of course someone else will look at putting your changes into CVS.

I've already emailed Cep about this, I think he will look at it when he finds the time to. Of course, should he "disappear" again, it would be good to have somebody look at this. Thank you!

a little offtopic: but its for these kinds of situations that i hope that you keep on working with the blender exporter, you're jme only chance for having a program which is fully compatable with jme!

please don't give up!

I feel flattered, thank you!  :D  It's always nice to get some feedback. I am not planning on "giving up" currently, in fact I will have some more time the next weeks to spend on the exporter. If you know any missing features you'd like to see implemented soon, contact me, or post them in the blender exporter thread.

You mentioned

until JointController directly provides a way of attaching meshes to joints

is this already in the making ? or planned ?

EDIT: ah and i haven't had much time to try this stuff recently but i also think You are doing a good job here hevee :slight_smile:

me too, im trying to get up to speed to understand it.

Why do you prefer blender to milkshape or others …


Well, I haven't heard of such plans, but I have some ideas, and it's definitely a required feature for most game types that have any use for skeletal animation. I will most probably eventually have a go at it.


Blender is free, open source, and has an amazing featureset, and it is very quickly evolving. And it can be scripted in python, which, imho, is the most elegant programming/scripting language I know of, and simply fun to work with.

And thanks for all of your appreciation, it is appreciated!  :slight_smile:

Hm looks like cep won't be back for a while, I'll try to do this today.

edit: ah these were more minor than I thought -> check in

Llama, thanks a lot!