[Solved]Bone anim issue with attaching/getting abs. bone pos

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
MrJones
Posts: 15
Joined: Sun May 23, 2010 1:02 pm

[Solved]Bone anim issue with attaching/getting abs. bone pos

Post 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!
Last edited by MrJones on Fri May 28, 2010 9:16 am, edited 1 time in total.
blub
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post 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) ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
MrJones
Posts: 15
Joined: Sun May 23, 2010 1:02 pm

Post 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.
blub
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post 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 !?!?! :shock:
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
MrJones
Posts: 15
Joined: Sun May 23, 2010 1:02 pm

Post by MrJones »

I really hope the irrlicht devs can shed some light on this.
blub
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post 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();
	}
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

shadowslair wrote:

Code: Select all

		node->animateJoints(); // for EJUOR_CONTROL animate`em manually
ahh, so my first guess was right !!! :lol:
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:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
MrJones
Posts: 15
Joined: Sun May 23, 2010 1:02 pm

Post 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?
blub
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post 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? :roll:
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
MrJones
Posts: 15
Joined: Sun May 23, 2010 1:02 pm

Post 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)
Last edited by MrJones on Thu May 27, 2010 12:52 pm, edited 1 time in total.
blub
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post 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.
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
MrJones
Posts: 15
Joined: Sun May 23, 2010 1:02 pm

Post 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*
blub
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
MrJones
Posts: 15
Joined: Sun May 23, 2010 1:02 pm

Post 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*
blub
Post Reply