[ODE] MathEngine's TransformationMatrix
Aras Pranckevicius
nearaz at interamotion.com
Thu Jul 3 02:23:01 2003
> Could you suggest me please the ODE equivalent of MathEngine's
> "TransformationMatrix". I would like to determine the position and
orientation
> of the objects to be rendered.
You can get position (vector) and orientation (quaternion or 3x3 matrix) of
the bodies/geoms (that's described in user's guide, section 6.2) - and use
that for rendering.
4x4 matrix is just a composition of 3x3 rotation matrix, position vector and
a column/row containing (0,0,0,1). Depending on graphics API you use
(opengl/d3d), matrices are laid out in column-major or row-major order.
For OpenGL, a 4x4 transformation matrix is:
Xx Yx Zx Ox
Xy Yy Zy Oy
Xz Yz Zz Oz
0 0 0 1
Here, upper-left 3x3 part is a rotation matrix (with X,Y,Z being axis
vectors, and x,y,z being their components) - you get that directly from ODE,
or convert quaternion into it. The Ox,Oy,Oz part is the position vector.
For D3D, the matrix is transposed (flipped along main diagonal):
Xx Xy Xz 0
Yx Yy Yz 0
Zx Zy Zz 0
Ox Oy Oz 1
Thus you have to transpose the rotation matrix obtained from ODE as well
(ODE uses OpenGL-style matrices). I believe there's a code for this in ODE's
Wiki.
Aras Pranckevicius aka NeARAZ
http://www.gim.ktu.lt/nesnausk/nearaz/