source: trunk/test/Physics/EasyPhysics.h @ 1597

Last change on this file since 1597 was 1597, checked in by touky, 10 years ago

Added sphere in EasyPhysics

File size: 1.9 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2012 Sam Hocevar <sam@hocevar.net>
5//            (c) 2009-2012 Benjamin Huet <huet.benjamin@gmail.com>
6//   This program is free software; you can redistribute it and/or
7//   modify it under the terms of the Do What The Fuck You Want To
8//   Public License, Version 2, as published by Sam Hocevar. See
9//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
10//
11
12//
13// The EasyPhysics class
14// ------------------
15//
16
17#if !defined __EASYPHYSICS_EASYPHYSICS_H__
18#define __EASYPHYSICS_EASYPHYSICS_H__
19
20#ifdef HAVE_PHYS_USE_BULLET
21#include "core.h"
22#include <bullet/btBulletDynamicsCommon.h>
23#include <bullet/btBulletCollisionCommon.h>
24#endif
25
26namespace lol
27{
28
29namespace phys
30{
31
32class EasyPhysics
33{
34#ifdef HAVE_PHYS_USE_BULLET
35public:
36        EasyPhysics();
37
38        void SetShapeToBox(lol::vec3& box_size);
39        void SetShapeToSphere(float radius);
40        void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f)));
41        void SetMass(float mass);
42        void InitBodyToRigid();
43        void AddToSimulation(class Simulation* current_simulation);
44        mat4 GetTransform();
45
46protected:
47        void SetLocalInertia(float mass);
48        void SetShapeTo(btCollisionShape* collision_shape);
49
50        btCollisionObject*                                                      m_collision_object;
51
52        btRigidBody*                                                            m_rigid_body;
53        btScalar                                                                        m_mass;
54        btVector3                                                                       m_local_inertia;
55
56        btCollisionShape*                                                       m_collision_shape;
57        btMotionState*                                                          m_motion_state;
58
59        lol::mat4                                                                       m_local_to_world;
60#else
61public:
62        EasyPhysics() { }
63
64        void SetShapeToBox(lol::vec3& BoxSize) { }
65        void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { }
66        void SetMass(float mass) { }
67        void InitBodyToRigid() { }
68        void AddToSimulation(class Simulation* current_simulation) { }
69        mat4 GetTransform() { return mat4(1.0f); }
70#endif
71};
72
73} /* namespace phys */
74
75} /* namespace lol */
76
77#endif /* __EASYPHYSICS_EASYPHYSICS_H__ */
78
Note: See TracBrowser for help on using the repository browser.