Global rotation of joints

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.
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Post by Scarabol »

Well, i think its time for you to show us some of your code...

MfG
Scarabol
Irrlicht 1.7.2
Eclipse
Boost
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

lol. i need a calculation method. what code do i have to show?
Image
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, code that does what you expect the mesh to do would help. As you might know, you can do ragdoll movement with skeleton meshes in Irrlicht. So program the rotations such that they behave as expected and show us how. Then we can check if that happens to be already in the engine, or that we can add the code. Seems like the only option left.
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

umm... maybe my understanding is bad but..
im here to ask HOW can i do it.. then u say i should do it, tell u how i did it, and then u tell me u did it bad!
that makes no sense XD

how could i show a working code about something what i dont know how to do?
Image
Image
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Post by Scarabol »

You can't show us code that works, but whats about the code that does not work?

Edit:
This is my brainstorming, dont comment:
u have getRotation() to get the local rotation of the joint
u have getAbsoluteTransformation() to get the absolute rotation of the joint
u have setRotation() to set the local rotation of the joint
u want setAbsoluteRotation() to set the global rotation of the joint

I think u have to get the rotation to its parent get the difference to the world rotation add your absolute rotation and set it to the joint
[/Edit]

I think thats it:
[pseudocode]
vector3df rot = parent->getAbsoluteRotation();
vector3df newrot = vector3df(0,90,0) + rot;
joint->setRotation(newrot);
[/pseudocode]

MfG
Scarabol
Irrlicht 1.7.2
Eclipse
Boost
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

thanks for helping :3

Code: Select all

		if (vertical != 0)
		{
			IBoneSceneNode* back = upperAnimNode->getJointNode("hip_up");
			if (back)
			{
				matrix4 m = back->getParent()->getAbsoluteTransformation();
				vector3df currot = m.getRotationDegrees();
				back->setRotation(vector3df(currot.X+vertical, currot.Y, currot.Z));
			}
		}
with this code the character turns around, maybe thats just my fault rotating on the wrong axis XD
But the problem is, that it changes rotation how i change my characters rotation
tried to currot = rotationdegrees - modelrotation. didn't work, just like + modelrotation.

tried matrix4 m = back->getParent()->getAbsoluteTransformation() - node->getAbsoluteTransformation(); and reverse, didnt work either.
tried inverse the m, that didn't work either.

the result was like this:
http://dotdotdot.site90.com/FTP/30.jpg
http://dotdotdot.site90.com/FTP/31.jpg
http://dotdotdot.site90.com/FTP/32.jpg
Image
Image
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Post by Scarabol »

Hi,

pls try this:

Code: Select all

back->setRotation(-currot); 
This should frezze the bone to its own system.

If you have this try to rotate the bone on this.

MfG
Scarabol
Irrlicht 1.7.2
Eclipse
Boost
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

well, i dont know what did u want to achieve with that, but not really working XD

btw i made a little application, to test it.

http://dotdotdot.site90.com/FTP/FooChar.rar

In character.cpp search for "if (vertical != 0)"

you can change weapon with 1-2, and change vertical rotation with mouse wheel
Image
Image
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Post by Scarabol »

Hi,

im testing your code right know.

First point i figured out is, that "hip_up" is rotated at startup.

I think you have to reposition hip_up, such that if you call:
back->setRotation(vector3df(0,0,0)) nothing changes.

MfG
Scarabol
Irrlicht 1.7.2
Eclipse
Boost
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

well of course its rotated coz it has animation.
my problem is that i want to rotate it on a global axis, with animation.
if i wouldnt need the animation, i could just rotate the joint in animation software so it always points towards.
but because its rotated in animation, i need to calculate the global rotation XD
Image
Image
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

You may try to look at code I posted here: http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=35341
It does something similar to what you need on normal scene nodes. But joints are type of scene nodes so it might work.[/url]
Scarabol
Posts: 167
Joined: Sat Jan 03, 2009 5:26 pm
Location: Aachen, Germany

Post by Scarabol »

omg,

i think it works:

Code: Select all

	if (vertical != 0)
	{
		IBoneSceneNode* back = upperAnimNode->getJointNode("hip_up");
		if (back)
		{
			matrix4 m, n;
            back->getParent()->updateAbsolutePosition();
            back->getParent()->getAbsoluteTransformation().getInverse(m);
            back->updateAbsolutePosition();
            n = back->getAbsoluteTransformation();
            m *= n;
			m.setRotationDegrees(m.getRotationDegrees()+vector3df(vertical*10,0,0));
            back->setRotation(m.getRotationDegrees()); 			
		}
	}
MfG
Scarabol
Irrlicht 1.7.2
Eclipse
Boost
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

nope its not ><
updated the source, so u can see why it isnt work (check the pistol animation)
Image
Image
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

oookay, i need to bump this again Q_Q
Image
Image
B@z
Posts: 876
Joined: Thu Jan 31, 2008 5:05 pm
Location: Hungary

Post by B@z »

please help ><
Image
Image
Post Reply