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