[10262] | 1 | /** |
---|
| 2 | * Copy-pasted from http://www.ogre3d.org/tikiwiki/BulletDebugDrawer&structure=Cookbook |
---|
| 3 | * This source code is released into the Public Domain. |
---|
| 4 | * |
---|
| 5 | * Modified by Fabian 'x3n' Landau |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #ifndef _OgreBulletUtils_H__ |
---|
| 9 | #define _OgreBulletUtils_H__ |
---|
| 10 | |
---|
| 11 | #include "tools/ToolsPrereqs.h" |
---|
[11071] | 12 | #include <OgreVector3.h> |
---|
| 13 | #include <OgreQuaternion.h> |
---|
| 14 | #include <OgreColourValue.h> |
---|
| 15 | #include <OgreMatrix3.h> |
---|
| 16 | #include <OgreMatrix4.h> |
---|
[10262] | 17 | |
---|
| 18 | namespace orxonox |
---|
| 19 | { |
---|
| 20 | inline btVector3 vector3(const Ogre::Vector3& V) |
---|
| 21 | { |
---|
| 22 | return btVector3(V.x, V.y, V.z); |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | inline Ogre::Vector3 vector3(const btVector3& V) |
---|
| 26 | { |
---|
| 27 | return Ogre::Vector3(V.x(), V.y(), V.z()); |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | inline btQuaternion quaternion(const Ogre::Quaternion& Q) |
---|
| 31 | { |
---|
| 32 | return btQuaternion(Q.x, Q.y, Q.z, Q.w); |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | inline Ogre::Quaternion quaternion(const btQuaternion& Q) |
---|
| 36 | { |
---|
| 37 | return Ogre::Quaternion(Q.w(), Q.x(), Q.y(), Q.z()); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | inline Ogre::ColourValue colour(const btVector3& color, btScalar alpha) |
---|
| 41 | { |
---|
| 42 | Ogre::ColourValue c(color.getX(), color.getY(), color.getZ(), alpha); |
---|
| 43 | c.saturate(); |
---|
| 44 | return c; |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | inline Ogre::Matrix3 matrix3(const btMatrix3x3& matrix) |
---|
| 48 | { |
---|
[11071] | 49 | return Ogre::Matrix3( |
---|
[10262] | 50 | matrix[0][0], matrix[0][1], matrix[0][2], |
---|
| 51 | matrix[1][0], matrix[1][1], matrix[1][2], |
---|
| 52 | matrix[2][0], matrix[2][1], matrix[2][2] |
---|
| 53 | ); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | inline Ogre::Matrix4 matrix4(const btTransform& transform) |
---|
| 57 | { |
---|
| 58 | const btMatrix3x3& rotation = transform.getBasis(); |
---|
| 59 | const btVector3& translation = transform.getOrigin(); |
---|
| 60 | |
---|
| 61 | Ogre::Matrix4 matrix4 = Ogre::Matrix4(matrix3(rotation)); |
---|
| 62 | matrix4.setTrans(vector3(translation)); |
---|
| 63 | return matrix4; |
---|
| 64 | } |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | #endif /* _OgreBulletUtils_H__ */ |
---|