source: trunk/test/Physics/Include/EasyCharacterController.h @ 1795

Last change on this file since 1795 was 1795, checked in by touky, 11 years ago

Fixed Entity::TickGame log flood.
Added BulletCharacterController.cpp & BulletCharacterController.h stubs.

File size: 3.1 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 EasyCharacterController class
14// ------------------
15//
16
17//Should try to to make a btKinematicCharacterController for real.
18//
19
20#if !defined __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__
21#define __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__
22
23#ifdef HAVE_PHYS_USE_BULLET
24#include "core.h"
25#include "EasyPhysics.h"
26#include <BulletDynamics/Character/btKinematicCharacterController.h>
27#endif
28
29namespace lol
30{
31
32namespace phys
33{
34
35class EasyCharacterController : public EasyPhysic,
36                                                                public Entity
37{
38
39        friend class Simulation;
40        friend class EasyPhysic;
41
42#ifdef HAVE_PHYS_USE_BULLET
43
44public:
45        EasyCharacterController(WorldEntity* NewOwnerEntity) :
46                EasyPhysic(NewOwnerEntity),
47                m_pair_caching_object(NULL),
48                m_character(NULL),
49                m_step_height(.0f),
50                m_base_is_updating(false),
51                m_base_cached_movement(vec3(0.f)),
52                m_frame_cached_movement(vec3(0.f)),
53                m_walk_velocity(vec3(0.f)),
54                m_current_velocity(vec3(0.f))
55        {
56                m_gamegroup = GAMEGROUP_EZP_CHAR_CTRLR;
57                m_up_axis = 1;
58                m_gravity = vec3(.0f, -9.81f, .0f);
59                m_walk_velocity_damping = 0.2f;
60        }
61        ~EasyCharacterController()
62        {
63                delete m_character;
64        }
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        virtual void Jump();
72
73        virtual void SetTransform(const lol::vec3& base_location, const lol::quat& base_rotation);
74protected:
75        virtual void BaseTransformChanged(const lol::mat4& PreviousMatrix, const lol::mat4& NewMatrix);
76        virtual char const *GetName();
77public:
78        virtual void TickGame(float seconds);
79
80protected:
81
82        virtual btGhostObject* GetGhostObjectInstance();
83
84        btPairCachingGhostObject*               m_pair_caching_object;
85        btKinematicCharacterController* m_character;
86
87        float                                                   m_step_height;
88        int                                                             m_up_axis;
89        bool                                                    m_base_is_updating;
90        vec3                                                    m_base_cached_movement;
91        vec3                                                    m_frame_cached_movement;
92
93        //----
94        float                                                   m_walk_velocity_damping;
95
96        //----
97        vec3                                                    m_gravity;
98
99        //----
100        vec3                                                    m_walk_velocity;
101        vec3                                                    m_current_velocity;
102
103#else  // NO PHYSIC IMPLEMENTATION
104
105        virtual void InitBodyToRigid(bool ZeroMassIsKinematic=false) { }
106        virtual void InitBodyToGhost() { }
107        virtual void AddToSimulation(class Simulation* current_simulation) { }
108        virtual void RemoveFromSimulation(class Simulation* current_simulation) { }
109        virtual void SetMovementForFrame(vec3 const &MoveQuantity) { }
110
111#endif // PHYSIC IMPLEMENTATION
112
113};
114
115} /* namespace phys */
116
117} /* namespace lol */
118
119#endif /* __EASYCHARACTERCONTROLLER_EASYCHARACTERCONTROLLER_H__ */
120
Note: See TracBrowser for help on using the repository browser.