Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/SuperOrxoBros_HS18/src/libraries/tools/OgreBulletUtils.h @ 12177

Last change on this file since 12177 was 12177, checked in by siramesh, 5 years ago

Super Orxo Bros Final (Sidharth Ramesh, Nisa Balta, Jeff Ren)

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