[ODE] Rotation troubles
Ken M
wgold at flyingplastic.com
Thu Feb 28 17:27:02 2002
This is a multi-part message in MIME format.
------=_NextPart_000_0180_01C1C08C.BD3F6F10
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi all -
I'm having a little difficulty integrating ODE into my system.. I =
thought I had it all working (all joints are working except AMotor, and =
my system responds to ODE's CD) until I began trying to rotate objects =
maually and found that I get unexpected behaviour. It seems that the =
rotations I send to ODE work exactly opposite of what I would expect.
The fact that I'm not very fluent in matrix computations is hindering my =
debugging capabilities, I'm sure, so any help here would be appreciated.
After reading over "Drawstuff.cpp" and seeing this code:
static void setTransform (const float pos[3], const float R[12])
{
GLfloat matrix[16];
matrix[0]=3DR[0];
matrix[1]=3DR[4];
matrix[2]=3DR[8];
matrix[3]=3D0;
matrix[4]=3DR[1];
matrix[5]=3DR[5];
matrix[6]=3DR[9];
matrix[7]=3D0;
matrix[8]=3DR[2];
matrix[9]=3DR[6];
matrix[10]=3DR[10];
matrix[11]=3D0;
matrix[12]=3Dpos[0];
matrix[13]=3Dpos[1];
matrix[14]=3Dpos[2];
matrix[15]=3D1;
glPushMatrix();
glMultMatrixf (matrix);
}
A light came on and I thought that ODE was internally using this format =
for rotations. So when I set a rotation using dBodySetRotation() I now =
convert my GL-friendly matrix into this col/row format for ODE. No =
problem yet.
The surprise came when I called "dBodyGetRotation()" subsequently to my =
dBodySetRotation()which, after much frustration, I found seems to be =
returning a gl-friendly matrix describing my object's rotation instead =
of the above modified row/col sawpped version (which I was trying to =
convert to ODE-friendly style, but my rotations were inverted still =
until I just took it rw and used it.)
So I'm confused. If I don't modify the matrix on SetRotation, a =
subsequent GetRotation call will come back with inverted values. If I =
modify code on BOTH my set and get calls, I'm still inverted.. Only if I =
send in the matrix as described in the above setTransform() call (which =
swaps row/col), and then use the matrix returned from dBodyGetXXX raw do =
I get expected and desired results.
Any help?
Ken
------=_NextPart_000_0180_01C1C08C.BD3F6F10
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4807.2300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3D"Courier New" size=3D2>Hi all -</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>I'm having a =
little difficulty=20
integrating ODE into my system.. I thought I had it all working (all =
joints are=20
working except AMotor, and my system responds to ODE's CD) until I =
began=20
trying to rotate objects maually and found that I get unexpected=20
behaviour. It seems that the rotations I send to=20
ODE work exactly opposite of what I would expect.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>The fact that I'm not very =
fluent in matrix=20
computations is hindering my debugging capabilities, I'm sure, so any =
help here=20
would be appreciated.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>After reading over =
"Drawstuff.cpp" and=20
seeing this code:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>static void setTransform (const =
float=20
pos[3], const float R[12])<BR>{<BR> GLfloat matrix[16];<BR> =20
matrix[0]=3DR[0];<BR> matrix[1]=3DR[4];<BR> =
matrix[2]=3DR[8];<BR> =20
matrix[3]=3D0;<BR> matrix[4]=3DR[1];<BR> =
matrix[5]=3DR[5];<BR> =20
matrix[6]=3DR[9];<BR> matrix[7]=3D0;<BR> =
matrix[8]=3DR[2];<BR> =20
matrix[9]=3DR[6];<BR> matrix[10]=3DR[10];<BR> =
matrix[11]=3D0;<BR> =20
matrix[12]=3Dpos[0];<BR> matrix[13]=3Dpos[1];<BR> =20
matrix[14]=3Dpos[2];<BR> matrix[15]=3D1;<BR> =
glPushMatrix();<BR> =20
glMultMatrixf (matrix);<BR>}<BR></FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>A light came on and I thought =
that ODE was=20
internally using this format for rotations. So when I set a =
rotation using=20
dBodySetRotation() I now convert my GL-friendly matrix into this col/row =
format=20
for ODE. No problem yet.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>The surprise came when I called =
"dBodyGetRotation()" subsequently to my dBodySetRotation()which, after =
much=20
frustration, I found seems to be returning a gl-friendly =
matrix describing=20
my object's rotation instead of the above modified row/col sawpped =
version=20
(which I was trying to convert to ODE-friendly style, but my rotations =
were=20
inverted still until I just took it rw and used it.)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>So I'm confused. If I =
don't modify=20
the matrix on SetRotation, a subsequent GetRotation call will come back =
with=20
inverted values. If I modify code on BOTH my set and get calls, =
I'm still=20
inverted.. Only if I send in the matrix as described in the above =
setTransform()=20
call (which swaps row/col), and then use the matrix returned from=20
dBodyGetXXX raw do I get expected and desired results.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Any help?</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Ken</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2> </DIV></FONT></BODY></HTML>
------=_NextPart_000_0180_01C1C08C.BD3F6F10--