Main Page | Namespace List | Class List | File List | Class Members | File Members

odeutils.h

Go to the documentation of this file.
00001 #ifndef _ODEUTILS_H
00002 #define _ODEUTILS_H
00003 
00004 #include <ode/ode.h>
00005 #include <gfx/mat4.h>
00006 #include <gfx/quat.h>
00007 
00008 // since ODE likes to return dReal *'s and since C++ doesn't like to return
00009 // arrays we have all these nice conversion functions, the first argument is
00010 // always the target and the second argument is always the source (note that
00011 // the float *'s should probably be dReal *'s)
00012 
00013 // NOTE: ODE stores quaternions with scalar first, then vector
00014 // NOTE: ODE stores matrices in row-major order (dmat[4*i + j] = row i,
00015 // col j)
00016 
00017 void Mat4TodMatrix3( dMatrix3 dmat3, const Mat4 mat4 );
00018 
00019 void dMatrix3ToMat4( Mat4& mat4, const dMatrix3 dmat3 );
00020 void dMatrix3TodMatrix3( dMatrix3 dmat3_1, const dMatrix3 dmat3_2 );
00021 
00022 // useful for pushing an object's rotation onto the modelview_matrix stack
00023 void dMatrix3ToOpenGL( dReal oglMat[ 16 ], const dMatrix3 dMat3 );
00024 
00025 void dRealPtrTodMatrix4( dMatrix4 dmat4, const dReal* fltPtr );
00026 void dRealPtrTodMatrix3( dMatrix3 dmat3, const dReal* fltPtr );
00027 
00028 inline void dRealPtrToVec3( Vec3& v, const dReal* ptr )
00029     { v = Vec3( ptr ); }
00030 
00031 inline void Vec3TodVector3( dVector3 dv, const Vec3 &v )
00032     { dv[0] = v[0]; dv[1] = v[1]; dv[2] = v[2]; }
00033 
00034 inline void dRealPtrTodQuaternion( dQuaternion dq, const dReal* q )
00035     { dq[0] = q[0]; dq[1] = q[1]; dq[2] = q[2]; dq[3] = q[3]; }
00036 
00037 inline void dQuaternion_to_quat( Quat& q, const dQuaternion dq )
00038     { q = Quat( dq[1], dq[2], dq[3], dq[0] ); }
00039 
00040 inline void quat_to_dQuaternion( dQuaternion dq, const Quat& q )
00041     { dq[1] = q.vector()[0]; dq[2] = q.vector()[1]; dq[3] = q.vector()[2]; dq[0] = q.scalar(); }
00042 
00043 #endif // header guard

Generated on Sat Mar 13 14:58:32 2004 for Ars Physica by doxygen 1.3.5