Child nodes don't stick to parent joints when attached

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
MirceaKitsune
Posts: 9
Joined: Thu Nov 08, 2012 10:49 pm

Child nodes don't stick to parent joints when attached

Post by MirceaKitsune »

Hello. I'm trying to attach a node to another node in my code, both nodes of type IAnimatedMeshSceneNode and using skeletal animated models in the x format (exported with Blender and its native x exporter). I do so with the following code and in the following order:

Code: Select all

child->setParent(parent);
child->setPosition(offset_position);
child->setRotation(offset_rotation);
child->updateAbsolutePosition();
If parent is the mesh node of our parent object, everything works fine. But my code is also meant to support attachment to joints of the animation skeleton. In that case, parent is set in the following way (then the code above happens):

Code: Select all

parent = parent_node->getJointNode(bone_name);
What happens is: The child appears to be attached at the origin and rotation of the bone (not sure yet). But as the parent mesh is animated (by playing an animation via setFrameLoop(start, end)) the attachment does not stick to the bone and keep following it. It does however stick to the parent and move / rotate with its mesh node.

What could be causing this? Could it be something I'm forgetting in the Irrlicht configuration, or something else I might have messed up in my code?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Child nodes don't stick to parent joints when attached

Post by mongoose7 »

You can't do animation like this. The parent/child relationship is between nodes and is pretty much static. When you get the bone node, I don't think it contains any animation properties - the actual (imagined) position of the bone is set by the animation system and can't be set by transforming the scene node.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Child nodes don't stick to parent joints when attached

Post by Mel »

No, you can alter the bone transformations using the EJUOR_CONTROL mode, and the changes get reflected (it is posible to make ragdoll animations like that)

It is due to a small problem with the skinned meshes that the child nodes attached to bone nodes get delayed one frame. Currently, there is no direct solution but i found a workaround while this gets solved, it requires the engine to be recompiled though.

http://irrlicht.sourceforge.net/forum/v ... =7&t=47041
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
MirceaKitsune
Posts: 9
Joined: Thu Nov 08, 2012 10:49 pm

Re: Child nodes don't stick to parent joints when attached

Post by MirceaKitsune »

I know this is possible somehow as I seen Irrlicht videos of characters holding weapons in their hand, the weapons being attached to the hand of the mesh (some are from many years ago). From what I heard you just parent the object to that joint node and it will have a relative position / rotation to it.

Being delayed by one frame is likely not an issue and shouldn't even be visible. Problem is that the attachment is not moved at all with the parent joint, and acts as if I parented it to the note itself (just moves with the object). Is this itself a problem with Irrlicht, or is it more likely I've done something bad in my code or forgot to set a flag?
MirceaKitsune
Posts: 9
Joined: Thu Nov 08, 2012 10:49 pm

Re: Child nodes don't stick to parent joints when attached

Post by MirceaKitsune »

Never mind, I tested it again and it works. Not sure what I did wrong, but now the child leans and rotates together with the bone of the parent while the parent is animated.

Only remaining issue is that the child goes to origin 0,0,0 if attached to a bone when the parent is given setJointMode(irr::scene::EJUOR_CONTROL), which breaks animations and mesh visuals too. I posted about that issue over here if anyone wants to take a look.
Post Reply