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

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

EasyMesh : Fixed normals on disc when one of the radius == 0
EasyPhysics : Added Cone primitive.

File size: 2.0 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 SetShapeToCone(float radius, float height);
41        void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f)));
42        void SetMass(float mass);
43        void InitBodyToRigid();
44        void AddToSimulation(class Simulation* current_simulation);
45        mat4 GetTransform();
46
47protected:
48        void SetLocalInertia(float mass);
49        void SetShapeTo(btCollisionShape* collision_shape);
50
51        btCollisionObject*                                                      m_collision_object;
52
53        btRigidBody*                                                            m_rigid_body;
54        btScalar                                                                        m_mass;
55        btVector3                                                                       m_local_inertia;
56
57        btCollisionShape*                                                       m_collision_shape;
58        btMotionState*                                                          m_motion_state;
59
60        lol::mat4                                                                       m_local_to_world;
61#else
62public:
63        EasyPhysics() { }
64
65        void SetShapeToBox(lol::vec3& BoxSize) { }
66        void SetShapeToSphere(float radius) { }
67        void SetBaseTransform(const lol::vec3& base_location, const lol::quat& base_rotation=lol::quat(lol::mat4(1.0f))) { }
68        void SetMass(float mass) { }
69        void InitBodyToRigid() { }
70        void AddToSimulation(class Simulation* current_simulation) { }
71        mat4 GetTransform() { return mat4(1.0f); }
72#endif
73};
74
75} /* namespace phys */
76
77} /* namespace lol */
78
79#endif /* __EASYPHYSICS_EASYPHYSICS_H__ */
80
Note: See TracBrowser for help on using the repository browser.