[ODE] How to use the rotation matrix returned by dGeomGetRotation
Duncan Frostick
duncanf at f2s.com
Sun Oct 10 15:32:27 MST 2004
Hi all,
I'm having quite some trouble working with the rotation matrix returned
by dGeomGetRotation. I've got some trimeshes loaded into DX and ODE and
I'm trying to get the position and rotation of the trimeshes from ODE to
render them in the correct locations in DX.
The matrix I'm getting back from ODE on the first (and subsequent)
worldstep is rubbish basically, all 16 elements are 0 except 2 elements
which are 1.875. Even if I combine this with an identity matrix to try
and make it render something visible, there's massive distortion of the
mesh. All I'm doing is getting the rotation matrix from ODE then
converting it using the method outlined on the ODE wiki FAQ area then
using the resultant matrix as the rotation matrix combined with a
translation to the location specified by ODE. That seems to me to be the
most obvious thing to do. The position vector returned by ODE is fine,
just the rotation matrix doesn't seem to make any sense.
What exactly needs to be done to make the rotation matrix returned by
dGeomGetRotation useable? Could I be missing a step in initialising ODE
or my Geom object which is confusing ODE and making it return a garbage
matrix? I've been having trouble with getting trimeshes loaded anyway,
could dodgy trimesh data be causing the rubbish matrix? The test code in
test_moving_triwmesh seems to do this to get the transforms correct:
dGeomID g2 = dGeomTransformGetGeom (g);
const dReal *pos2 = dGeomGetPosition (g2);
const dReal *R2 = dGeomGetRotation (g2);
dVector3 actual_pos;
dMatrix3 actual_R;
dMULTIPLY0_331 (actual_pos,R,pos2); //6
actual_pos[0] += pos[0]; //7
actual_pos[1] += pos[1]; //8
actual_pos[2] += pos[2]; //9
dMULTIPLY0_333 (actual_R,R,R2); //10
drawGeom (g2,actual_pos,actual_R,0);
But I have no idea why and what lines 6, 7, 8, 9 and 10 do (the
functions in 6 and 10 don't seem to be documented) so I can't glean much
information from the test code.
Can anyone help?
Cheers, Duncan
More information about the ODE
mailing list