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 EasyPhysic class |
---|
14 | // ------------------ |
---|
15 | // |
---|
16 | |
---|
17 | #if !defined __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__ |
---|
18 | #define __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__ |
---|
19 | |
---|
20 | #ifdef HAVE_PHYS_USE_BULLET
|
---|
21 | #include <BulletDynamics/Character/btKinematicCharacterController.h>
|
---|
22 | #include "EasyPhysics.h" |
---|
23 | #endif
|
---|
24 |
|
---|
25 | namespace lol |
---|
26 | { |
---|
27 | |
---|
28 | namespace phys |
---|
29 | { |
---|
30 | |
---|
31 | class EasyCharacterController : public EasyPhysic |
---|
32 | { |
---|
33 | |
---|
34 | #ifdef HAVE_PHYS_USE_BULLET
|
---|
35 |
|
---|
36 | public:
|
---|
37 | EasyCharacterController() : |
---|
38 | EasyPhysic(), |
---|
39 | m_character(NULL) |
---|
40 | { |
---|
41 | m_up_axis = 1; |
---|
42 | } |
---|
43 | ~EasyCharacterController() |
---|
44 | { |
---|
45 | delete m_character; |
---|
46 | } |
---|
47 | |
---|
48 | virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false); |
---|
49 | virtual void InitBodyToGhost(); |
---|
50 | virtual void AddToSimulation(class Simulation* current_simulation);
|
---|
51 | virtual void RemoveFromSimulation(class Simulation* current_simulation);
|
---|
52 | virtual void SetMovementForFrame(vec3 const &MoveQuantity);
|
---|
53 |
|
---|
54 | protected:
|
---|
55 | |
---|
56 | virtual btGhostObject* GetGhostObject(); |
---|
57 |
|
---|
58 | btPairCachingGhostObject* m_pair_caching_object;
|
---|
59 | btKinematicCharacterController* m_character;
|
---|
60 |
|
---|
61 | float m_step_height;
|
---|
62 | int m_up_axis;
|
---|
63 |
|
---|
64 | #else // NO PHYSIC IMPLEMENTATION
|
---|
65 | |
---|
66 | virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false) { } |
---|
67 | virtual void InitBodyToGhost() { } |
---|
68 | virtual void AddToSimulation(class Simulation* current_simulation) { }
|
---|
69 | virtual void RemoveFromSimulation(class Simulation* current_simulation) { }
|
---|
70 | virtual void SetMovementForFrame(vec3 const &MoveQuantity) { }
|
---|
71 | |
---|
72 | #endif // PHYSIC IMPLEMENTATION |
---|
73 |
|
---|
74 | }; |
---|
75 | |
---|
76 | } /* namespace phys */ |
---|
77 | |
---|
78 | } /* namespace lol */ |
---|
79 | |
---|
80 | #endif /* __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__ */ |
---|
81 | |
---|