[Solved]Bone anim issue with attaching/getting abs. bone pos
[Solved]Bone anim issue with attaching/getting abs. bone pos
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!
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!
Last edited by MrJones on Fri May 28, 2010 9:16 am, edited 1 time in total.
blub
I'm not sure for what it is, but you'll have to remove the setJointMode:
I guess if you set it to EJUOR_CONTROL you'll have to update the joints manually (bc. you have the control over them) ???
Code: Select all
if (node)
{
node->setScale(vector3df(10,10,10));
// node->setJointMode(EJUOR_CONTROL);
node->setMaterialFlag(EMF_LIGHTING, false);
}
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
I agree !!!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.

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 !?!?!

while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Umm... you`re using EJUOR_CONTROL, but are not animating the node joints?!
Like:
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();
}
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
ahh, so my first guess was right !!!shadowslair wrote:Code: Select all
node->animateJoints(); // for EJUOR_CONTROL animate`em manually

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) ???
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Can you recall which method that is?hybrid wrote:IIRC you have to call some update method before checking the position. You can also render the mesh, which updates the positions.
Does that mean the fix is only in the SVN? Or also in 1.7.1?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.
blub
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
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? 

"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
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).Just wondering why are you so sure it`s a bug?
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)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?
Last edited by MrJones on Thu May 27, 2010 12:52 pm, edited 1 time in total.
blub
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
Well, you simply call animateJoints(); so Irrlicht will update them with animations(if any), and you rotate them AFTER the call. Like:
That`s the point of the "animateJoints()" call, because Irr never knows where you`re gonna put your joint transf calls.
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();
}
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Actually shadowslair gave you exactly one method to call, what do you think would I suggest instead?! Just call that message.MrJones wrote:OMG if that works then you just made my day! *tests*shadowslair wrote:Well, you simply call animateJoints(); so Irrlicht will update them with animations(if any), and you rotate them AFTER the call.
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??
->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*
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??
I hoped for something like ->recalculateAbsoluteBonePositions();hybrid wrote:Actually shadowslair gave you exactly one method to call, what do you think would I suggest instead?! Just call that message.
->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*
blub