AnnPlayerBody.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "systemMacro.h"
10 #include "AnnVect3.hpp"
11 #include "AnnQuaternion.hpp"
12 #include "AnnPlayerActuator.hpp"
13 
14 #include "euler.h"
15 #include <btBulletCollisionCommon.h>
16 #include <btBulletDynamicsCommon.h>
17 
18 namespace Annwvyn
19 {
23  class AnnEngine; //pre-declaration of AnnEngine
24 
29  right };
30 
33  {
34  public:
37 
39  AnnPlayerBody();
40 
42  void lockParameters();
43 
45  bool isLocked() const;
46 
49  void setPosition(AnnVect3 Position);
50 
53  void setOrientation(Ogre::Euler Orientation);
54  void setOrientation(AnnQuaternion Orientation);
55 
58  void setHeadOrientation(AnnQuaternion HeadOrientation);
59 
62  void setEyesHeight(float eyeHeight);
63 
66  void setWalkSpeed(float walkSpeed);
67 
70  void setTurnSpeed(float turnSpeed);
71 
74  void setMass(float mass);
75 
78  void setShape(btCollisionShape* Shape);
79 
82  void setBody(btRigidBody* Body);
83 
85  float getEyesHeight() const;
86 
88  AnnVect3 getEyeTranslation() const;
89 
91  float getWalkSpeed() const;
92 
94  float getTurnSpeed() const;
95 
97  float getMass() const;
98 
100  AnnVect3 getPosition() const;
101 
103  Ogre::Euler getOrientation() const;
104 
106  btRigidBody* getBody() const;
107 
109  btCollisionShape* getShape() const;
110 
113  void applyRelativeBodyYaw(Ogre::Radian angle);
114 
117  void applyMouseRelativeRotation(int relValue);
118 
120  bool hasPhysics() const;
121 
123  AnnVect3 getTranslation();
124 
126  AnnVect3 getAnalogTranslation() const;
127 
129  void setActuator(std::unique_ptr<AnnPlayerActuator>&& actuator);
130 
131  template <class ActuatorType, typename... Args>
132  void setActuator(Args&&... args)
133  {
134  auto act = std::make_unique<ActuatorType>(args...);
135  setActuator(std::move(act));
136  }
137 
139  bool standing;
142  float getRunFactor() const;
143 
147  void resetPlayerPhysics();
148 
150  void teleport(AnnVect3 position, AnnRadian orientation);
151 
153  void teleport(AnnVect3 position);
154 
156  void setMode(AnnPlayerMode playerMode);
157 
159  void setRoomRefNode(Ogre::SceneNode* node);
160 
162  void reground(float YvalueForGround);
163 
165  void reground(AnnVect3 pointOnGround);
166 
168  void regroundOnPhysicsBody(float lenght = 1000, AnnVect3 preoffset = AnnVect3::ZERO);
169 
171  void _hintRoomscaleUpdateTranslationReference();
172 
174  void syncToTrackedPose() const;
175 
176  private:
179  {
182 
183  float eyeHeight;
184  float walkSpeed;
185  float runFactor;
186  float turnSpeed;
187  float mass;
192 
193  //bullet
194  btCollisionShape* Shape;
195  btRigidBody* Body;
196 
197  AnnVect3 getHeadPosition() const { return FeetPosition + eyeHeight * AnnVect3::UNIT_Y; }
198  };
199 
202 
204 
206  void unlockParameters();
207 
209  friend class AnnEngine;
210  friend class AnnPhysicsEngine;
211 
213  void engineUpdate(float time);
214 
216  bool locked;
217 
220 
222  void applyAnalogYaw();
223 
225  float updateTime;
226 
228  bool physics;
229 
232 
234  Ogre::SceneNode* RoomReferenceNode;
235 
238 
241 
242  public:
245 
247  bool walking[4]{};
248 
250  bool run;
251 
252  //Analog values between -1 and 1
253  float analogWalk;
256  };
257 
259 }
bool contactWithGround
If there is contact with ground.
file for defining macros used for symbol export regarding the way the OS does things.
Ogre::SceneNode * RoomReferenceNode
Room reference node.
PhysicalParameters physicsParams
Object that keep body parameters (= legacy structure)
Main engine class. Creating an instance of this class make the engine start.
Definition: AnnEngine.hpp:70
Class that abstract the physics engine initialization and collision information queries for Annwvyn...
A 3D Vector.
Definition: AnnVect3.hpp:16
void setActuator(Args &&... args)
A 3D Vector.
bool run
Running state.
Namespace containing the totality of Annwvyn components.
Definition: AnnGetter.cpp:8
bool locked
The famous boolean that permit to prevent YOU for breaking my work! :D.
AnnQuaternion roomTranslateQuatReference
Reference for the translation of the room.
class that represent the player. This is the user&#39;s "Virtual body" in the world. It&#39;s the object that...
An angle in Radian.
Definition: AnnAngle.hpp:22
bool ignorePhysics
Turning that off bypass the physics code. Cool for menu scene or weird manipulation of the player obj...
static const AnnVect3 DEFAULT_STARTING_POS
std::unique_ptr< AnnPlayerActuator > actuator
PlayerActuator to use.
Represent a Quaternion.
T move(T... args)
A Quaternion.
Parameters of the user&#39;s VirtualBody.
Player Actuator permit to change the code run by the player class when updating player (position/rota...
bool physics
Player body physics enabled.
bool needNewRoomTranslateReference
If true, will extract the yaw angle from the last head pose, and store it in roomTranslateQuatReferen...
#define AnnDllExport
Definition: systemMacro.h:24
float updateTime
time length of the frame
Euler class for Ogre
bool standing
Boolean false if the player can get orientation transformation from.
Class for Euler rotations.
Definition: euler.h:25
static const Ogre::Euler DEFAULT_STARTING_ORIENT
walkDirection
Correspondence between array position and walk direction for the "walking" array. ...