Global/local ODE coordinates ?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
Joeker
Gnoblar
Posts: 9
Joined: Mon May 30, 2005 11:20 pm

Global/local ODE coordinates ?

Post by Joeker » Sun Jun 05, 2005 4:04 am

Hi,
I'm trying to run some ODE-simulations on the robot.mesh. Problem is, I have trouble converting ODE's flat world (world) to the hierachial scenegraph coordinates of the skeleton-joints.
It looks as if the pitch/roll/yaw(D,TS_WORLD) to some degree does that, but they allways ADD to the current rotation instead of setting it..
I've looked in the forum and saw numerous discussions about ragdolls but I'm not sure they answer my questions.

Any help greatly appreciated,

J.

PS is is possible to use the C ode libraries directly from Ogre or do you have to use OgreOde ?
0 x

User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands

Post by :wumpus: » Sun Jun 05, 2005 12:33 pm

This is the classical ragdoll problem, I'm sure it's solved a few times already.

Of course it is possible to use plain ODE with Ogre, Ogre doesn't limit your freedom to use other libraries in any way. OgreODE is just there for convience, so that you don't have to write all kinds of glue code yourself.
0 x

Joeker
Gnoblar
Posts: 9
Joined: Mon May 30, 2005 11:20 pm

Post by Joeker » Sun Jun 05, 2005 3:58 pm

Do you have any samplecode ?
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Post by jacmoe » Sun Jun 05, 2005 4:08 pm

Sample code of what?
ODE with Ogre?
Take a look at the reference application in Ogre source.
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

Joeker
Gnoblar
Posts: 9
Joined: Mon May 30, 2005 11:20 pm

Post by Joeker » Sun Jun 05, 2005 4:47 pm

No I have some experience with ODE so I don't think that would be *the* problem. Just some hints on how to make the conversion from ode coordinates to Ogre coordinates.

It would be SO cool if you could import the robot mesh and make him act like a ragdoll. And I mean, not only in death scenes, but being able to apply forces to joints/bodies and have the mesh follow the movements.

My plan was really to import the mesh, rig it up with physics then apply forces to the joints to make the characte use the predefined movements using physics. I made something similar with Java3d and it actually worked pretty well with a decent framerate.
The character would stand on the ground throwing punches and walking back and forth.

The advantage with this approach as I see it : if you make for example a fighting game, the characters will react ultra realistically when hit. You wouldnt have to make up artificial rules like "when player a hits player b with a right hand, player b must shift to animation hit_by_right_hand but not if his current move is blocking_all_right_hands".

Problem was, Java3d has allmost no features in the graphics department compared to libraries like ogre, so I had to make the switch.

Now you propably wonder why gravity didnt pull the guy to the floor right ? Well if your a mindless ragdoll, it's easier to stand when you have 4 legs and kingsize feet :)
0 x

User avatar
jwatte
Gnome
Posts: 347
Joined: Sat Feb 05, 2005 12:56 am

Post by jwatte » Sun Jun 05, 2005 11:49 pm

You can get the basis axes from ODE (it's the "R" 3x3 matrix you get from dBodyGetRotation(), IIRC).

Pluck out the axes, and turn that into a quaternion for Ogre. "FromRotationMatrix" should do it. There's really not much to it, except getting the matrix column/row order right. When it's wrong, things will rotate the wrong way :-)

Note that Nodes in Ogre typically are relative to their parent, whereas in ODE they are relative to the world (as if all nodes were parented to the root). It might be easiest if you just parent everything to the root in Ogre.
0 x

Joeker
Gnoblar
Posts: 9
Joined: Mon May 30, 2005 11:20 pm

Post by Joeker » Mon Jun 06, 2005 12:45 am

jwatte wrote:You can get the basis axes from ODE (it's the "R" 3x3 matrix you get from dBodyGetRotation(), IIRC).

Pluck out the axes, and turn that into a quaternion for Ogre. "FromRotationMatrix" should do it. There's really not much to it, except getting the matrix column/row order right. When it's wrong, things will rotate the wrong way :-)

Note that Nodes in Ogre typically are relative to their parent, whereas in ODE they are relative to the world (as if all nodes were parented to the root). It might be easiest if you just parent everything to the root in Ogre.
Yes jwatte but the meshes are all hierachies so if I wanted to use Ogre skeletons then what ?
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Post by jacmoe » Mon Jun 06, 2005 8:54 am

Take a look at what monster does in OgreODE.
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
jwatte
Gnome
Posts: 347
Joined: Sat Feb 05, 2005 12:56 am

Post by jwatte » Mon Jun 06, 2005 5:26 pm

The skeleton matrices will typically end up expressing their transform in the local coordinate system of the object/entity being rendered. Thus, you get the orientation of the bone, and multiply that matrix (it's a 4-element, because there's translation too) by the matrix of the object itself. Then pick out the 3x3 for orientation, and the translation, as separate quantities.
0 x

Post Reply