Page 1 of 1

Child nodes don't stick to parent joints when attached

Posted: Fri Nov 09, 2012 12:13 am
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?

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

Posted: Sat Nov 10, 2012 9:44 am
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.

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

Posted: Sat Nov 10, 2012 9:56 am
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

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

Posted: Sat Nov 10, 2012 3:47 pm
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?

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

Posted: Wed Nov 14, 2012 1:35 pm
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.