Annwvyn::AnnPlayerBody Class Reference

class that represent the player. This is the user's "Virtual body" in the world. It's the object that you have to move and turn to explore the space. More...

#include <AnnPlayerBody.hpp>

Collaboration diagram for Annwvyn::AnnPlayerBody:

Classes

struct  PhysicalParameters
 Parameters of the user's VirtualBody. More...
 

Public Member Functions

 AnnPlayerBody ()
 Construct the player object. More...
 
void lockParameters ()
 Prevent modification of physical parameter. More...
 
bool isLocked () const
 Permit to know if parameters are locked. More...
 
void setPosition (AnnVect3 Position)
 
void setOrientation (Ogre::Euler Orientation)
 
void setOrientation (AnnQuaternion Orientation)
 
void setHeadOrientation (AnnQuaternion HeadOrientation)
 
void setEyesHeight (float eyeHeight)
 
void setWalkSpeed (float walkSpeed)
 
void setTurnSpeed (float turnSpeed)
 
void setMass (float mass)
 
void setShape (btCollisionShape *Shape)
 
void setBody (btRigidBody *Body)
 
float getEyesHeight () const
 Get the distance between foot-plane and eyes in meters. More...
 
AnnVect3 getEyeTranslation () const
 Get a vector that correspond to the translation between the feet point and the eyes. More...
 
float getWalkSpeed () const
 Get walk-speed in meter/seconds. More...
 
float getTurnSpeed () const
 Get turn-speed in rad/seconds. More...
 
float getMass () const
 Get mass in Kg. More...
 
AnnVect3 getPosition () const
 Get position vector. More...
 
Ogre::Euler getOrientation () const
 Get body orientation (Euler vector) More...
 
btRigidBody * getBody () const
 Get rigid body. More...
 
btCollisionShape * getShape () const
 Get Shape. More...
 
void applyRelativeBodyYaw (Ogre::Radian angle)
 
void applyMouseRelativeRotation (int relValue)
 
bool hasPhysics () const
 Return true if physics has been initialized once. More...
 
AnnVect3 getTranslation ()
 Get the translation vector (normalized) from the walking state. More...
 
AnnVect3 getAnalogTranslation () const
 Get the translation from analog joystick value. More...
 
void setActuator (std::unique_ptr< AnnPlayerActuator > &&actuator)
 Set the player actuator object. More...
 
template<class ActuatorType , typename... Args>
void setActuator (Args &&... args)
 
float getRunFactor () const
 Get the ratio between walking and running speed. More...
 
void resetPlayerPhysics ()
 
void teleport (AnnVect3 position, AnnRadian orientation)
 Teleport the player to the given location, and get it facing the given direction. More...
 
void teleport (AnnVect3 position)
 Teleport the player without touching it's direction. More...
 
void setMode (AnnPlayerMode playerMode)
 Set the player mode between standing and roomscale;. More...
 
void setRoomRefNode (Ogre::SceneNode *node)
 Register the room reference node. More...
 
void reground (float YvalueForGround)
 Put the reference point for the roomscale VR at Y altitude. More...
 
void reground (AnnVect3 pointOnGround)
 call reground(pointOnGround.y); More...
 
void regroundOnPhysicsBody (float lenght=1000, AnnVect3 preoffset=AnnVect3::ZERO)
 Shoot a ray form the player to relative -Y. If it hits a rigidbody, call reground() on the impact position. More...
 
void _hintRoomscaleUpdateTranslationReference ()
 Advanced : Set the flag that will update the translation reference vector from the head pose "view" direction. More...
 
void syncToTrackedPose () const
 Set the player body's pose to match what is tracked by the VR system, and cancel all velocities. More...
 

Public Attributes

bool standing
 Boolean false if the player can get orientation transformation from. More...
 
float mouseSensitivity
 
bool ignorePhysics
 Turning that off bypass the physics code. Cool for menu scene or weird manipulation of the player object. More...
 
bool walking [4] {}
 Waling state. Forward Backward Left Right. More...
 
bool run
 Running state. More...
 
float analogWalk
 
float analogStraff
 
float analogRotate
 

Static Public Attributes

static const AnnVect3 DEFAULT_STARTING_POS { 0, 1, 10 }
 
static const Ogre::Euler DEFAULT_STARTING_ORIENT { 0 }
 

Private Member Functions

void unlockParameters ()
 Give back the right to modify some parameters. More...
 
void engineUpdate (float time)
 Engine update call for each frame. More...
 
void applyAnalogYaw ()
 Apply yaw from analog value. More...
 

Private Attributes

PhysicalParameters physicsParams
 Object that keep body parameters (= legacy structure) More...
 
AnnPlayerMode mode
 
bool locked
 The famous boolean that permit to prevent YOU for breaking my work! :D. More...
 
bool contactWithGround
 If there is contact with ground. More...
 
float updateTime
 time length of the frame More...
 
bool physics
 Player body physics enabled. More...
 
std::unique_ptr< AnnPlayerActuatoractuator
 PlayerActuator to use. More...
 
Ogre::SceneNode * RoomReferenceNode
 Room reference node. More...
 
bool needNewRoomTranslateReference
 If true, will extract the yaw angle from the last head pose, and store it in roomTranslateQuatReference. More...
 
AnnQuaternion roomTranslateQuatReference
 Reference for the translation of the room. More...
 

Friends

class AnnEngine
 Give Annwvyn::AnnEngine the right to access private members. More...
 
class AnnPhysicsEngine
 

Detailed Description

class that represent the player. This is the user's "Virtual body" in the world. It's the object that you have to move and turn to explore the space.

Definition at line 32 of file AnnPlayerBody.hpp.

Constructor & Destructor Documentation

◆ AnnPlayerBody()

AnnPlayerBody::AnnPlayerBody ( )

Construct the player object.

Definition at line 28 of file AnnPlayerBody.cpp.

Member Function Documentation

◆ _hintRoomscaleUpdateTranslationReference()

void AnnPlayerBody::_hintRoomscaleUpdateTranslationReference ( )

Advanced : Set the flag that will update the translation reference vector from the head pose "view" direction.

Definition at line 379 of file AnnPlayerBody.cpp.

◆ applyAnalogYaw()

void AnnPlayerBody::applyAnalogYaw ( )
private

Apply yaw from analog value.

Definition at line 238 of file AnnPlayerBody.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyMouseRelativeRotation()

void AnnPlayerBody::applyMouseRelativeRotation ( int  relValue)

Apply the rotation from the mouse relative value

Parameters
relValueRelative value in pixels of the mouse linear movement

Definition at line 207 of file AnnPlayerBody.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ applyRelativeBodyYaw()

void AnnPlayerBody::applyRelativeBodyYaw ( Ogre::Radian  angle)

Apply a relative yaw transform to the player. Useful to bind it to the mouse X axis for FPS-like gameplay.

Parameters
angleRadian angle of the transformation.

Definition at line 182 of file AnnPlayerBody.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ engineUpdate()

void AnnPlayerBody::engineUpdate ( float  time)
private

Engine update call for each frame.

Definition at line 282 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ getAnalogTranslation()

AnnVect3 AnnPlayerBody::getAnalogTranslation ( ) const

Get the translation from analog joystick value.

Definition at line 228 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ getBody()

btRigidBody * AnnPlayerBody::getBody ( ) const

Get rigid body.

Definition at line 162 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ getEyesHeight()

float AnnPlayerBody::getEyesHeight ( ) const

Get the distance between foot-plane and eyes in meters.

Definition at line 142 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ getEyeTranslation()

AnnVect3 AnnPlayerBody::getEyeTranslation ( ) const

Get a vector that correspond to the translation between the feet point and the eyes.

Definition at line 147 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ getMass()

float AnnPlayerBody::getMass ( ) const

Get mass in Kg.

Definition at line 157 of file AnnPlayerBody.cpp.

◆ getOrientation()

Ogre::Euler AnnPlayerBody::getOrientation ( ) const

Get body orientation (Euler vector)

Definition at line 177 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ getPosition()

AnnVect3 AnnPlayerBody::getPosition ( ) const

Get position vector.

Definition at line 172 of file AnnPlayerBody.cpp.

◆ getRunFactor()

float AnnPlayerBody::getRunFactor ( ) const

Get the ratio between walking and running speed.

Definition at line 245 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ getShape()

btCollisionShape * AnnPlayerBody::getShape ( ) const

Get Shape.

Definition at line 167 of file AnnPlayerBody.cpp.

◆ getTranslation()

AnnVect3 AnnPlayerBody::getTranslation ( )

Get the translation vector (normalized) from the walking state.

Definition at line 213 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ getTurnSpeed()

float AnnPlayerBody::getTurnSpeed ( ) const

Get turn-speed in rad/seconds.

Definition at line 152 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ getWalkSpeed()

float AnnPlayerBody::getWalkSpeed ( ) const

Get walk-speed in meter/seconds.

Definition at line 137 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ hasPhysics()

bool AnnPlayerBody::hasPhysics ( ) const

Return true if physics has been initialized once.

Definition at line 334 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ isLocked()

bool AnnPlayerBody::isLocked ( ) const

Permit to know if parameters are locked.

Definition at line 64 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ lockParameters()

void AnnPlayerBody::lockParameters ( )

Prevent modification of physical parameter.

Definition at line 127 of file AnnPlayerBody.cpp.

◆ reground() [1/2]

void AnnPlayerBody::reground ( float  YvalueForGround)

Put the reference point for the roomscale VR at Y altitude.

Definition at line 349 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ reground() [2/2]

void AnnPlayerBody::reground ( AnnVect3  pointOnGround)

call reground(pointOnGround.y);

Definition at line 357 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ regroundOnPhysicsBody()

void AnnPlayerBody::regroundOnPhysicsBody ( float  lenght = 1000,
AnnVect3  preoffset = AnnVect3::ZERO 
)

Shoot a ray form the player to relative -Y. If it hits a rigidbody, call reground() on the impact position.

Definition at line 362 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ resetPlayerPhysics()

void AnnPlayerBody::resetPlayerPhysics ( )

If the player is handled through the physics engine, this method will detach the rigid-body from the camera, remove it from the dynamics world, de-allocate it from the memory and recreate it from scratch. This is useful for "teleporting" the player, for example if you need to reset his position.

Definition at line 250 of file AnnPlayerBody.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setActuator() [1/2]

void AnnPlayerBody::setActuator ( std::unique_ptr< AnnPlayerActuator > &&  actuator)

Set the player actuator object.

Definition at line 59 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ setActuator() [2/2]

template<class ActuatorType , typename... Args>
void Annwvyn::AnnPlayerBody::setActuator ( Args &&...  args)
inline

Definition at line 132 of file AnnPlayerBody.hpp.

Here is the call graph for this function:

◆ setBody()

void AnnPlayerBody::setBody ( btRigidBody *  Body)

Bullet RIGID body

Parameters
BodyThe bullet rigid body used for simulating player's physics

Definition at line 121 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ setEyesHeight()

void AnnPlayerBody::setEyesHeight ( float  eyeHeight)

distance between foot-plane and eyes

Parameters
eyeHeightfloating point number in meter

Definition at line 91 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ setHeadOrientation()

void AnnPlayerBody::setHeadOrientation ( AnnQuaternion  HeadOrientation)

Set the head orientation

Parameters
HeadOrientationA quaternion representing the orientation of the head

Definition at line 86 of file AnnPlayerBody.cpp.

◆ setMass()

void AnnPlayerBody::setMass ( float  mass)

Mass in Kg

Parameters
massMass of the player in Kg

Definition at line 109 of file AnnPlayerBody.cpp.

◆ setMode()

void AnnPlayerBody::setMode ( AnnPlayerMode  playerMode)

Set the player mode between standing and roomscale;.

Definition at line 339 of file AnnPlayerBody.cpp.

◆ setOrientation() [1/2]

void AnnPlayerBody::setOrientation ( Ogre::Euler  Orientation)

Set body orientation

Parameters
OrientationEuler angle that represent the orientation of the player's BODY. That orientation is used as a "zero point" for the head orientation.

Definition at line 74 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ setOrientation() [2/2]

void AnnPlayerBody::setOrientation ( AnnQuaternion  Orientation)

Definition at line 79 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ setPosition()

void AnnPlayerBody::setPosition ( AnnVect3  Position)

Set the position of the player. If physics is enabled you need to call AnnEngine::resetPlayerPhysics() to recreate player's body.

Parameters
Position3D vector representing the position of the player (referenced by the point between his eyes)

Definition at line 69 of file AnnPlayerBody.cpp.

Here is the caller graph for this function:

◆ setRoomRefNode()

void AnnPlayerBody::setRoomRefNode ( Ogre::SceneNode *  node)

Register the room reference node.

Definition at line 344 of file AnnPlayerBody.cpp.

◆ setShape()

void AnnPlayerBody::setShape ( btCollisionShape *  Shape)

Bullet shape

Parameters
Shapethe Bullet collision shape used to simulate player physics

Definition at line 114 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ setTurnSpeed()

void AnnPlayerBody::setTurnSpeed ( float  turnSpeed)

Turn-speed

Parameters
turnSpeedAngular speed that the user can turn his body

Definition at line 103 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ setWalkSpeed()

void AnnPlayerBody::setWalkSpeed ( float  walkSpeed)

WalkSpeed, meters by second

Parameters
walkSpeedThe speed a the user is walking

Definition at line 97 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ syncToTrackedPose()

void AnnPlayerBody::syncToTrackedPose ( ) const

Set the player body's pose to match what is tracked by the VR system, and cancel all velocities.

Definition at line 384 of file AnnPlayerBody.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ teleport() [1/2]

void AnnPlayerBody::teleport ( AnnVect3  position,
AnnRadian  orientation 
)

Teleport the player to the given location, and get it facing the given direction.

Definition at line 270 of file AnnPlayerBody.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ teleport() [2/2]

void AnnPlayerBody::teleport ( AnnVect3  position)

Teleport the player without touching it's direction.

Definition at line 277 of file AnnPlayerBody.cpp.

Here is the call graph for this function:

◆ unlockParameters()

void AnnPlayerBody::unlockParameters ( )
private

Give back the right to modify some parameters.

Definition at line 132 of file AnnPlayerBody.cpp.

Friends And Related Function Documentation

◆ AnnEngine

friend class AnnEngine
friend

Give Annwvyn::AnnEngine the right to access private members.

Definition at line 209 of file AnnPlayerBody.hpp.

◆ AnnPhysicsEngine

friend class AnnPhysicsEngine
friend

Definition at line 210 of file AnnPlayerBody.hpp.

Member Data Documentation

◆ actuator

std::unique_ptr<AnnPlayerActuator> Annwvyn::AnnPlayerBody::actuator
private

PlayerActuator to use.

Definition at line 231 of file AnnPlayerBody.hpp.

◆ analogRotate

float Annwvyn::AnnPlayerBody::analogRotate

Definition at line 255 of file AnnPlayerBody.hpp.

◆ analogStraff

float Annwvyn::AnnPlayerBody::analogStraff

Definition at line 254 of file AnnPlayerBody.hpp.

◆ analogWalk

float Annwvyn::AnnPlayerBody::analogWalk

Definition at line 253 of file AnnPlayerBody.hpp.

◆ contactWithGround

bool Annwvyn::AnnPlayerBody::contactWithGround
private

If there is contact with ground.

Definition at line 219 of file AnnPlayerBody.hpp.

◆ DEFAULT_STARTING_ORIENT

const Ogre::Euler AnnPlayerBody::DEFAULT_STARTING_ORIENT { 0 }
static

Definition at line 36 of file AnnPlayerBody.hpp.

◆ DEFAULT_STARTING_POS

const AnnVect3 AnnPlayerBody::DEFAULT_STARTING_POS { 0, 1, 10 }
static

Definition at line 35 of file AnnPlayerBody.hpp.

◆ ignorePhysics

bool Annwvyn::AnnPlayerBody::ignorePhysics

Turning that off bypass the physics code. Cool for menu scene or weird manipulation of the player object.

Definition at line 244 of file AnnPlayerBody.hpp.

◆ locked

bool Annwvyn::AnnPlayerBody::locked
private

The famous boolean that permit to prevent YOU for breaking my work! :D.

Definition at line 216 of file AnnPlayerBody.hpp.

◆ mode

AnnPlayerMode Annwvyn::AnnPlayerBody::mode
private

Definition at line 203 of file AnnPlayerBody.hpp.

◆ mouseSensitivity

float Annwvyn::AnnPlayerBody::mouseSensitivity

Definition at line 140 of file AnnPlayerBody.hpp.

◆ needNewRoomTranslateReference

bool Annwvyn::AnnPlayerBody::needNewRoomTranslateReference
private

If true, will extract the yaw angle from the last head pose, and store it in roomTranslateQuatReference.

Definition at line 237 of file AnnPlayerBody.hpp.

◆ physics

bool Annwvyn::AnnPlayerBody::physics
private

Player body physics enabled.

Definition at line 228 of file AnnPlayerBody.hpp.

◆ physicsParams

PhysicalParameters Annwvyn::AnnPlayerBody::physicsParams
private

Object that keep body parameters (= legacy structure)

Definition at line 201 of file AnnPlayerBody.hpp.

◆ RoomReferenceNode

Ogre::SceneNode* Annwvyn::AnnPlayerBody::RoomReferenceNode
private

Room reference node.

Definition at line 234 of file AnnPlayerBody.hpp.

◆ roomTranslateQuatReference

AnnQuaternion Annwvyn::AnnPlayerBody::roomTranslateQuatReference
private

Reference for the translation of the room.

Definition at line 240 of file AnnPlayerBody.hpp.

◆ run

bool Annwvyn::AnnPlayerBody::run

Running state.

Definition at line 250 of file AnnPlayerBody.hpp.

◆ standing

bool Annwvyn::AnnPlayerBody::standing

Boolean false if the player can get orientation transformation from.

Definition at line 139 of file AnnPlayerBody.hpp.

◆ updateTime

float Annwvyn::AnnPlayerBody::updateTime
private

time length of the frame

Definition at line 225 of file AnnPlayerBody.hpp.

◆ walking

bool Annwvyn::AnnPlayerBody::walking[4] {}

Waling state. Forward Backward Left Right.

Definition at line 247 of file AnnPlayerBody.hpp.


The documentation for this class was generated from the following files: