Page 1 of 1
[Solved]Bone anim issue with attaching/getting abs. bone pos
Posted: Tue May 25, 2010 2:57 pm
by MrJones
Hi,
In my recent project I am having huge issues with getting the absolute position of a bone scene node. Whatever I do, I don't seem to be able to get correct results. I get a completely off position in world space that does not move if I move the whole IAnimatedMeshSceneNode (which should of course affect the bone aswell).
During my journey to find the bug I asked a lot of people and Sudi came up with attaching a billboard to the bone - which worked for him using my model just fine, but when I filled it into code myself I got the same strange issue: the billboard appears at a visibly wrong position (not where the bone is if I check in Blender) and if I move the whole IAnimatedMeshSceneNode around, it will NOT get moved as a child but remain at its position.
As nobody of us has been able to find the cause so far, I set up a
modification of the Hello World example of Irrlicht 1.7.1 that features a modified main.cpp, a new model and a slightly changed Makefile to create the executable in the same directory as that's also where that new model file is (the model is an ISkinnedMesh).
Compiling and starting up that modified Hello World demonstrates the issue with the attached billboard. If instead of attaching the billboard one queries ->getAbsolutePosition() each frame and manually sets something (a node, a camera, something else) to that position, exactly the same symptoms appear [position is not at the bone's actual position and doesn't move if the whole bone mesh node is moved].
01.HelloWorld.Modified.zip
I have no idea what's wrong. Maybe I'm simply missing some command to activate something I forgot about, I don't know. I guess some Irrlicht expert needs to take a look at this to find out why it's not working - every sort of help appreciated!
Posted: Tue May 25, 2010 3:17 pm
by Acki
I'm not sure for what it is, but you'll have to remove the setJointMode:
Code: Select all
if (node)
{
node->setScale(vector3df(10,10,10));
// node->setJointMode(EJUOR_CONTROL);
node->setMaterialFlag(EMF_LIGHTING, false);
}
I guess if you set it to EJUOR_CONTROL you'll have to update the joints manually (bc. you have the control over them) ???
Posted: Tue May 25, 2010 6:44 pm
by MrJones
What if I do want to update them manually?
I don't see how the way of animating affects getAbsolutePosition() - it should simply return the bone's position, no matter if it was set through an animation or through direct manipulation.
Posted: Tue May 25, 2010 7:21 pm
by Acki
MrJones wrote:I don't see how the way of animating affects getAbsolutePosition() - it should simply return the bone's position, no matter if it was set through an animation or through direct manipulation.
I agree !!!

but I don't know much about the joint modes of Irrlicht, sorry...
maybe this is a bug in Irrlicht !?!?!
EDIT: that's strange:
if you set the joint mode to EJUOR_CONTROL and debugdata visible to EDS_SKELETON the bones are drawn correct, but if you get the absolute position of the joint you get always the same values regardless where the node is positioned in the scene like if the joints don't move !?!?!

Posted: Wed May 26, 2010 4:58 pm
by MrJones
I really hope the irrlicht devs can shed some light on this.
Posted: Wed May 26, 2010 9:00 pm
by hybrid
IIRC you have to call some update method before checking the position. You can also render the mesh, which updates the positions. A bug in the bone position system had been fixed for Irrlicht 1.7 AFAIK. The last time I checked the test case went through without problems.
Posted: Wed May 26, 2010 10:46 pm
by shadowslair
Umm... you`re using EJUOR_CONTROL, but are not animating the node joints?!
Like:
Code: Select all
while(device->run())
{
node->setPosition(node->getPosition()+vector3df(0.15f,0,0));
node->animateJoints(); // for EJUOR_CONTROL animate`em manually
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
Posted: Wed May 26, 2010 11:29 pm
by Acki
shadowslair wrote:Code: Select all
node->animateJoints(); // for EJUOR_CONTROL animate`em manually
ahh, so my first guess was right !!!

Acki wrote:I guess if you set it to EJUOR_CONTROL you'll have to update the joints manually (bc. you have the control over them) ???
Posted: Thu May 27, 2010 8:49 am
by MrJones
hybrid wrote:IIRC you have to call some update method before checking the position. You can also render the mesh, which updates the positions.
Can you recall which method that is?
hybrid wrote:A bug in the bone position system had been fixed for Irrlicht 1.7 AFAIK. The last time I checked the test case went through without problems.
Does that mean the fix is only in the SVN? Or also in 1.7.1?
Posted: Thu May 27, 2010 12:32 pm
by shadowslair
Just wondering why are you so sure it`s a bug? I`m pretty familiar with the IAnimatedMeshSceneNode class, tried dozens of things, mods etc. and everything is working as expected since 1.4.1. The example you posted does not represent any unwanted behaviour- after you paste the "animateJoints();" call as I said, the black billboard is always on the right place. Isn`t that exactly what you wanna do? Did you tried that and it`s still not working?

Posted: Thu May 27, 2010 12:36 pm
by MrJones
Just wondering why are you so sure it`s a bug?
I am not sure at all. Hybrid hinted a command which might help, maybe that can fix my issues. I think it's likely I'm doing something wrong, I just don't know. As he also mentioned an animation bug I simply wanted to know whether that one is still present in 1.7.1 and possibly involved in those issues (the SVN actually doesn't change anything, I just tried that - so most likely completely unrelated).
after you paste the "animateJoints();" call as I said, the black billboard is always on the right place. Isn`t that exactly what you wanna do?
I don't think so. I want to animate the bones manually, not have Irrlicht's animation system override all the stuff I did (Correct me if the command is not doing that)
Posted: Thu May 27, 2010 12:51 pm
by shadowslair
Well, you simply call animateJoints(); so Irrlicht will update them with animations(if any), and you rotate them AFTER the call. Like:
Code: Select all
while(device->run())
{
// animate position of my lovely node
node->setPosition(node->getPosition()+vector3df(0.15f,0,0));
// update transf with animations(if any)
node->animateJoints(); // for EJUOR_CONTROL animate`em manually
// do my custom transf stuff
joint->setPosition( yourPosition );
joint->setRotation( yourRotation );
// let Irrlicht render the stuff
driver->beginScene(true, true, SColor(255,100,101,140));
smgr->drawAll();
guienv->drawAll();
driver->endScene();
}
That`s the point of the "animateJoints()" call, because Irr never knows where you`re gonna put your joint transf calls.
Posted: Thu May 27, 2010 1:21 pm
by MrJones
shadowslair wrote:Well, you simply call animateJoints(); so Irrlicht will update them with animations(if any), and you rotate them AFTER the call.
OMG if that works then you just made my day! *tests*
Posted: Thu May 27, 2010 8:20 pm
by hybrid
MrJones wrote:shadowslair wrote:Well, you simply call animateJoints(); so Irrlicht will update them with animations(if any), and you rotate them AFTER the call.
OMG if that works then you just made my day! *tests*
Actually shadowslair gave you exactly one method to call, what do you think would I suggest instead?! Just call that message.
Posted: Fri May 28, 2010 8:16 am
by MrJones
Well I just tried. It seemed to work... for a second.
The problem is, I get the absolute position of the bone before changing its rotation manually.
What I would like is to change its rotation and then have Irrlicht tell me the absolute position the bone has AFTER that rotation (without resetting that rotation again). Or am I expected to calculate it myself while taking all parent bones into account??
hybrid wrote:Actually shadowslair gave you exactly one method to call, what do you think would I suggest instead?! Just call that message.
I hoped for something like ->recalculateAbsoluteBonePositions();
->animateJoints() destroys my animation. And if I animate manually afterwards to prevent that from happening, those animations won't be taken into account for the absolute positions returned. Therefore I'd really need something that recalculates the absolute positions WITHOUT resetting my custom rotations.
Edit: I added some ->updateAbsolutePosition() calls and now it works O_O !!!! YAY *hugs everyone collectively*