[ODE] Mapping to OpenGL axis system

Jani Kajala jani at sumea.com
Tue Nov 20 16:58:21 MST 2001


Check
http://research.microsoft.com/~hollasch/cgindex/math/matrix/column-vec.html
(btw: X=left, Y=up, Z=out of monitor is left handed, X=thumb, Z=middle
finger...)


Regards,
Jani Kajala

----- Original Message -----
From: "Ruud van Gaal" <ruud at marketgraph.nl>
To: <ode at q12.org>
Sent: Tuesday, November 20, 2001 10:10 PM
Subject: [ODE] Mapping to OpenGL axis system


> Hi Russel and the group,
>
> I'm trying to create an ODE version of my racesim, and due to my lack of
> insight on matrices, I run into some trouble with coordinate systems. My sim
> uses the OpenGL axis system, meaning a right handed Y=up, X=left, Z=out the
> screen. For the cars, this ends up as the Z axis point from the seat of the
> driver towards the front bumper, X left out the door, Y up.
> Now I don't know exactly what ODE uses, but it seems like left-handed, with Z
> going up?
>
> After modifying my rigid body class to create an ODE dBody, for painting in
> OpenGL I had to map ODE's axis system to my (OpenGL) axis system. As it turned
> out, inverting the quaternion from ODE worked using myQuat.w=odeQuat.w,
> myQuat.x=-odeQuat.x, myQuat.y=-odeQuat.y and myQuat.z=-odeQuat.z. So I had to
> negate the xyz members. Then I derived my own 3x3 matrix as before ODE, and
> with this matrix the car started painting in the expected orientation again.
>
> However, when applying forces and torques using dBodyAdd[Rel]Force(), I seem
to
> have to do an extra mapping. Adding body forces seem ok with
dBodyAddRelForce()
> and I can just pass force.x,force.y,force.z (although I'd rather pass a
pointer
> to these 3 floats, but that's another story).
> Adding torque values are weird though. When using dBodyAddRelTorque() with my
> (OpenGL-based) torque.x/y/z, things go bad quickly. Using world coordinates
and
> passing them as body coordinates, I seem to get closer with
> dBodyAddTorque(bodyID,-torque.x,torque.y,-torque.z), but then steering left
> pushes the car around right and vice versa. Adding some negations here & there
> make it graphically correct, but the car is very sensitive to spinning and I
> feel my coordinate system hack just doesn't work.
>
> Does anybody have a good idea about how get the OpenGL and ODE's axis system
to
> work together like it should? It seems I must convert from right- to
> lefthanded, but as quaternion rotations are done presumably assuming a
> lefthanded system, my AddForce()/AddTorque() calls go wrong.
>
> Thanks for any ideas, I've spent multiple hours in this already and getting a
> bit nuts and I see a maze of negations coming up, which is definitely NOT good
> (and pretty endless too).
> I want to avoid switching all MY stuff to lefthanded, since that would make
the
> conversion bigger than it's supposed to be.
>
> Ruud van Gaal
>
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode
>




More information about the ODE mailing list