Global rotation of joints
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
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.
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
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
Eclipse
Boost
thanks for helping :3
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
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));
}
}
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
Hi,
pls try this:
This should frezze the bone to its own system.
If you have this try to rotate the bone on this.
MfG
Scarabol
pls try this:
Code: Select all
back->setRotation(-currot);
If you have this try to rotate the bone on this.
MfG
Scarabol
Irrlicht 1.7.2
Eclipse
Boost
Eclipse
Boost
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
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
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
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
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]
It does something similar to what you need on normal scene nodes. But joints are type of scene nodes so it might work.[/url]
omg,
i think it works:
MfG
Scarabol
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());
}
}
Scarabol
Irrlicht 1.7.2
Eclipse
Boost
Eclipse
Boost