Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/tools/OgreBulletUtils.h @ 10262

Last change on this file since 10262 was 10262, checked in by landauf, 9 years ago

eol-style native. no changes in code.

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
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"
12
13namespace orxonox
14{
15    inline btVector3 vector3(const Ogre::Vector3& V)
16    {
17        return btVector3(V.x, V.y, V.z);
18    }
19
20    inline Ogre::Vector3 vector3(const btVector3& V)
21    {
22        return Ogre::Vector3(V.x(), V.y(), V.z());
23    }
24
25    inline btQuaternion quaternion(const Ogre::Quaternion& Q)
26    {
27        return btQuaternion(Q.x, Q.y, Q.z, Q.w);
28    }
29
30    inline Ogre::Quaternion quaternion(const btQuaternion& Q)
31    {
32        return Ogre::Quaternion(Q.w(), Q.x(), Q.y(), Q.z());
33    }
34
35    inline Ogre::ColourValue colour(const btVector3& color, btScalar alpha)
36    {
37        Ogre::ColourValue c(color.getX(), color.getY(), color.getZ(), alpha);
38        c.saturate();
39        return c;
40    }
41
42    inline Ogre::Matrix3 matrix3(const btMatrix3x3& matrix)
43    {
44        return Matrix3(
45                matrix[0][0], matrix[0][1], matrix[0][2],
46                matrix[1][0], matrix[1][1], matrix[1][2],
47                matrix[2][0], matrix[2][1], matrix[2][2]
48            );
49    }
50
51    inline Ogre::Matrix4 matrix4(const btTransform& transform)
52    {
53        const btMatrix3x3& rotation = transform.getBasis();
54        const btVector3& translation = transform.getOrigin();
55
56        Ogre::Matrix4 matrix4 = Ogre::Matrix4(matrix3(rotation));
57        matrix4.setTrans(vector3(translation));
58        return matrix4;
59    }
60}
61
62#endif /* _OgreBulletUtils_H__ */
Note: See TracBrowser for help on using the repository browser.