Player Class Reference

#include <player.h>

Inheritance diagram for Player:

Inheritance graph
[legend]
List of all members.

Animation threads & data

Player::ActionAnimation mActionAnimation
Player::ArmAnimation mArmAnimation
TSThreadmArmThread
TSThreadmHeadVThread
TSThreadmHeadHThread
TSThreadmRecoilThread
static Range mArmRange
static Range mHeadVRange
static Range mHeadHRange

Public Member Functions

 DECLARE_CONOBJECT (Player)
 Player ()
 ~Player ()
Point3F getVelocity () const
 Gets the velocity of the object.
void setVelocity (const VectorF &vel)
 Sets the velocity of this object.
void applyImpulse (const Point3F &pos, const VectorF &vec)
 Apply an impulse at the given point, with magnitude/direction of vec.
const Point3FgetRotation ()
 Get the rotation of the player.
const Point3FgetHeadRotation ()
 Get the rotation of the head of the player.
void getDamageLocation (const Point3F &in_rPos, const char *&out_rpVert, const char *&out_rpQuad)
bool canJump ()
 Can the player jump?
bool canJetJump ()
 Can the player jet?
bool haveContact ()
 Is it in contact with something.
void getMuzzlePointAI (U32 imageSlot, Point3F *point)
float getMaxForwardVelocity ()
 duh
virtual bool isDisplacable () const
 Returns true if this object allows itself to be displaced.
virtual Point3F getMomentum () const
 Returns the momentum of this object.
virtual void setMomentum (const Point3F &momentum)
 Sets the momentum of this object.
virtual F32 getMass () const
 Returns the mass of this object.
virtual bool displaceObject (const Point3F &displaceVector)
 Displaces this object by a vector.
virtual bool getAIMove (Move *)
bool checkDismountPosition (const MatrixF &oldPos, const MatrixF &newPos)
 Is it safe to dismount here?
bool onAdd ()
 Called when the object is added to the sim.
void onRemove ()
 Called when the object is removed from the sim.
bool onNewDataBlock (GameBaseData *dptr)
 Called when a new datablock is set.
void onScaleChanged ()
 Called when the size of the object changes.
const char * getStateName ()
bool setActionThread (const char *sequence, bool hold, bool wait, bool fsp=false)
bool setArmThread (const char *sequence)
void setControlObject (ShapeBase *obj)
 sets the object this is controling
ShapeBasegetControlObject ()
 Returns the object this is controling.
void updateWorkingCollisionSet ()
void processTick (const Move *move)
 Processes a move event and updates object state once every 32 milliseconds.
void interpolateTick (F32 delta)
 Interpolates between tick events.
void advanceTime (F32 dt)
 Advances simulation time for animations.
bool castRay (const Point3F &start, const Point3F &end, RayInfo *info)
 Casts a ray from start to end, stores gathered information in 'info' returns true if successful.
bool buildPolyList (AbstractPolyList *polyList, const Box3F &box, const SphereF &sphere)
 Builds a polylist of the polygons in this object returns true if successful.
void buildConvex (const Box3F &box, Convex *convex)
 Builds a convex hull for this object.
bool isControlObject ()
void onCameraScopeQuery (NetConnection *cr, CameraScopeQuery *)
 Control object scoping.
void writePacketData (GameConnection *conn, BitStream *stream)
 Write state information necessary to perform client side prediction of an object.
void readPacketData (GameConnection *conn, BitStream *stream)
 Read data written with writePacketData() and update the object state.
U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream)
 Instructs this object to pack its state for transfer over the network.
void unpackUpdate (NetConnection *conn, BitStream *stream)
 Instructs this object to read state data previously packed with packUpdate.
virtual bool prepRenderImage (SceneState *state, const U32 stateKey, const U32 startZone, const bool modifyBaseZoneState)
 Called when the SceneGraph is ready for the registration of RenderImages.
Transforms
Transforms are all in object space

void setTransform (const MatrixF &mat)
 Sets the Object -> World transform.
void getEyeTransform (MatrixF *mat)
 Returns the eye transform of this shape, IE the eyes of a player.
void getRenderEyeTransform (MatrixF *mat)
void getCameraParameters (F32 *min, F32 *max, Point3F *offset, MatrixF *rot)
 Gets the minimum viewing distance, maximum viewing distance, camera offsetand rotation for this object, if the world were to be viewed through its eyes.
void getMuzzleTransform (U32 imageSlot, MatrixF *mat)
 Muzzle transform of mounted object in world space.
void getRenderMuzzleTransform (U32 imageSlot, MatrixF *mat)

Static Public Member Functions

static void consoleInit ()
 Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.

Public Attributes

OrthoBoxConvex mConvex
Box3F mWorkingQueryBox
Box3F mScaledBox

Protected Member Functions

void setState (ActionState state, U32 ticks=0)
void updateState ()
void updateMove (const Move *move)
 Update the movement.
bool updatePos (const F32 travelTime=TickSec)
 Interpolate movement.
void updateLookAnimation (F32 dT=0.f)
 Update head animation.
void updateAnimation (F32 dt)
 Update other animations.
void updateAnimationTree (bool firstPerson)
bool step (Point3F *pos, F32 *maxStep, F32 time)
void checkMissionArea ()
 See if the player is still in the mission area.
virtual bool setArmThread (U32 action)
virtual void setActionThread (U32 action, bool forward, bool hold=false, bool wait=false, bool fsp=false, bool forceSet=false)
virtual void updateActionThread ()
virtual void pickActionAnimation ()
void onUnmount (ShapeBase *obj, S32 node)
void setPosition (const Point3F &pos, const Point3F &viewRot)
void setRenderPosition (const Point3F &pos, const Point3F &viewRot, F32 dt=-1)
void findContact (bool *run, bool *jump, VectorF *contactNormal)
virtual void onImageRecoil (U32 imageSlot, ShapeBaseImageData::StateData::RecoilState)
virtual void updateDamageLevel ()
virtual void updateDamageState ()
void setControllingClient (GameConnection *client)
 Set which client is controlling this player.
void calcClassRenderData ()
 Preprender logic.
void playFootstepSound (bool triggeredLeft, S32 sound)
 Play a footstep sound.
void playImpactSound ()
 Play an impact sound.
bool inDeathAnim ()
 Are we in the process of dying?
F32 deathDelta (Point3F &delta)
void updateDeathOffsets ()
bool inSittingAnim ()
Water
void updateSplash ()
 Update the splash effect.
void updateFroth (F32 dt)
 Update any froth.
void updateWaterSounds (F32 dt)
 Update water sounds.
bool pointInWater (Point3F &point)
 Tests to see if a point is in water.
void createSplash (Point3F &pos, F32 speed)
 Creates a splash.
bool collidingWithWater (Point3F &waterHeight)
 Are we collising with water?

Protected Attributes

bool mJetting

Private Types

typedef ShapeBase Parent
 ActionMask = Parent::NextFreeMask << 0
 MoveMask = Parent::NextFreeMask << 1
 ImpactMask = Parent::NextFreeMask << 2
 NextFreeMask = Parent::NextFreeMask << 3
 NullState
 MoveState
 RecoverState
 NumStateBits = 3
enum  MaskBits {
  ActionMask = Parent::NextFreeMask << 0,
  MoveMask = Parent::NextFreeMask << 1,
  ImpactMask = Parent::NextFreeMask << 2,
  NextFreeMask = Parent::NextFreeMask << 3
}
 Bit masks for different types of events. More...
enum  ActionState {
  NullState,
  MoveState,
  RecoverState,
  NumStateBits = 3
}
 Main player state. More...

Private Attributes

SimObjectPtr< ParticleEmittermSplashEmitter [PlayerData::NUM_SPLASH_EMITTERS]
F32 mBubbleEmitterTime
StateDelta delta
 Used for interpolation on the client.
S32 mPredictionCount
 Number of ticks to predict.
Point3F mHead
 Head rotation, uses only x & z.
Point3F mRot
 Body rotation, uses only z.
VectorF mVelocity
 Velocity.
Point3F mAnchorPoint
 Pos compression anchor.
S32 mImpactSound
S32 mMountPending
 mMountPending suppresses tickDelay countdown so players will sit until their mount, or another animation, comes through (or 13 seconds elapses).
ActionState mState
 What is the player doing?
bool mFalling
 Falling in mid-air?
S32 mJumpDelay
 Delay till next jump.
S32 mContactTimer
 Ticks since last contact.
Point3F mJumpSurfaceNormal
 Normal of the surface the player last jumped on.
U32 mJumpSurfaceLastContact
 How long it's been since the player landed (ticks).
F32 mWeaponBackFraction
 Amount to slide the weapon back (if it's up against something).
SFXSourcemMoveBubbleSound
 Sound for moving bubbles.
SFXSourcemWaterBreathSound
 Sound for underwater breath.
SimObjectPtr< ShapeBasemControlObject
 Controlling object.
bool mInMissionArea
 Are we in the mission area?
S32 mRecoverTicks
 same as recoverTicks in the player datablock
U32 mReversePending
bool inLiquid
 Are we in liquid?
PlayerDatamDataBlock
 MMmmmmm...datablock...
Point3F mLastPos
 Holds the last position for physics updates.
Point3F mLastWaterPos
 Same as mLastPos, but for water.
Player::ContactInfo mContactInfo
Player::Death mDeath

Static Private Attributes

static F32 mGravity
 Gravity.

Classes

struct  ActionAnimation
struct  ArmAnimation
struct  ContactInfo
struct  Death
struct  Range
struct  StateDelta
 Client interpolation/warp data. More...

Member Typedef Documentation

typedef ShapeBase Player::Parent [private]

Reimplemented from ShapeBase.

Reimplemented in AIPlayer.


Member Enumeration Documentation

enum Player::MaskBits [private]

Bit masks for different types of events.

Enumerator:
ActionMask 
MoveMask 
ImpactMask 
NextFreeMask 

enum Player::ActionState [private]

Main player state.

Enumerator:
NullState 
MoveState 
RecoverState 
NumStateBits 


Constructor & Destructor Documentation

Player::Player (  ) 

Player::~Player (  ) 


Member Function Documentation

void Player::setState ( ActionState  state,
U32  ticks = 0 
) [protected]

void Player::updateState (  )  [protected]

void Player::updateMove ( const Move move  )  [protected]

Update the movement.

bool Player::updatePos ( const F32  travelTime = TickSec  )  [protected]

Interpolate movement.

void Player::updateLookAnimation ( F32  dT = 0.f  )  [protected]

Update head animation.

void Player::updateAnimation ( F32  dt  )  [protected]

Update other animations.

void Player::updateAnimationTree ( bool  firstPerson  )  [protected]

bool Player::step ( Point3F pos,
F32 maxStep,
F32  time 
) [protected]

void Player::checkMissionArea (  )  [protected]

See if the player is still in the mission area.

virtual bool Player::setArmThread ( U32  action  )  [protected, virtual]

virtual void Player::setActionThread ( U32  action,
bool  forward,
bool  hold = false,
bool  wait = false,
bool  fsp = false,
bool  forceSet = false 
) [protected, virtual]

virtual void Player::updateActionThread (  )  [protected, virtual]

virtual void Player::pickActionAnimation (  )  [protected, virtual]

void Player::onUnmount ( ShapeBase obj,
S32  node 
) [protected, virtual]

Reimplemented from ShapeBase.

void Player::setPosition ( const Point3F pos,
const Point3F viewRot 
) [protected]

void Player::setRenderPosition ( const Point3F pos,
const Point3F viewRot,
F32  dt = -1 
) [protected]

void Player::findContact ( bool run,
bool jump,
VectorF contactNormal 
) [protected]

virtual void Player::onImageRecoil ( U32  imageSlot,
ShapeBaseImageData::StateData::RecoilState   
) [protected, virtual]

Reimplemented from ShapeBase.

virtual void Player::updateDamageLevel (  )  [protected, virtual]

Reimplemented from ShapeBase.

virtual void Player::updateDamageState (  )  [protected, virtual]

Reimplemented from ShapeBase.

void Player::setControllingClient ( GameConnection client  )  [protected, virtual]

Set which client is controlling this player.

Reimplemented from GameBase.

void Player::calcClassRenderData (  )  [protected, virtual]

Preprender logic.

Reimplemented from ShapeBase.

void Player::playFootstepSound ( bool  triggeredLeft,
S32  sound 
) [protected]

Play a footstep sound.

void Player::playImpactSound (  )  [protected]

Play an impact sound.

bool Player::inDeathAnim (  )  [protected]

Are we in the process of dying?

F32 Player::deathDelta ( Point3F delta  )  [protected]

void Player::updateDeathOffsets (  )  [protected]

bool Player::inSittingAnim (  )  [protected]

void Player::updateSplash (  )  [protected]

Update the splash effect.

void Player::updateFroth ( F32  dt  )  [protected]

Update any froth.

void Player::updateWaterSounds ( F32  dt  )  [protected]

Update water sounds.

bool Player::pointInWater ( Point3F point  )  [protected]

Tests to see if a point is in water.

Reimplemented from ShapeBase.

void Player::createSplash ( Point3F pos,
F32  speed 
) [protected]

Creates a splash.

bool Player::collidingWithWater ( Point3F waterHeight  )  [protected]

Are we collising with water?

Player::DECLARE_CONOBJECT ( Player   ) 

static void Player::consoleInit (  )  [static]

Register global constant variables and do other one-time initialization tasks in a subclass of ConsoleObject.

See also:
console

Reimplemented from ShapeBase.

void Player::setTransform ( const MatrixF mat  )  [virtual]

Sets the Object -> World transform.

Parameters:
mat New transform matrix

Reimplemented from SceneObject.

void Player::getEyeTransform ( MatrixF mat  )  [virtual]

Returns the eye transform of this shape, IE the eyes of a player.

Parameters:
mat Eye transform (out)

Reimplemented from ShapeBase.

void Player::getRenderEyeTransform ( MatrixF mat  )  [virtual]

Reimplemented from ShapeBase.

void Player::getCameraParameters ( F32 min,
F32 max,
Point3F offset,
MatrixF rot 
) [virtual]

Gets the minimum viewing distance, maximum viewing distance, camera offsetand rotation for this object, if the world were to be viewed through its eyes.

Parameters:
min Minimum viewing distance
max Maximum viewing distance
offset Offset of the camera from the origin in local space
rot Rotation matrix

Reimplemented from ShapeBase.

void Player::getMuzzleTransform ( U32  imageSlot,
MatrixF mat 
) [virtual]

Muzzle transform of mounted object in world space.

Parameters:
imageSlot Image slot
mat Muzzle transform (out)

Reimplemented from ShapeBase.

void Player::getRenderMuzzleTransform ( U32  imageSlot,
MatrixF mat 
) [virtual]

Reimplemented from ShapeBase.

Point3F Player::getVelocity (  )  const [virtual]

Gets the velocity of the object.

Reimplemented from SceneObject.

void Player::setVelocity ( const VectorF vel  )  [virtual]

Sets the velocity of this object.

Parameters:
vel Velocity vector

Reimplemented from ShapeBase.

void Player::applyImpulse ( const Point3F pos,
const VectorF vec 
) [virtual]

Apply an impulse at the given point, with magnitude/direction of vec.

Reimplemented from ShapeBase.

const Point3F& Player::getRotation (  )  [inline]

Get the rotation of the player.

const Point3F& Player::getHeadRotation (  )  [inline]

Get the rotation of the head of the player.

void Player::getDamageLocation ( const Point3F in_rPos,
const char *&  out_rpVert,
const char *&  out_rpQuad 
)

bool Player::canJump (  ) 

Can the player jump?

bool Player::canJetJump (  ) 

Can the player jet?

bool Player::haveContact (  )  [inline]

Is it in contact with something.

void Player::getMuzzlePointAI ( U32  imageSlot,
Point3F point 
)

float Player::getMaxForwardVelocity (  )  [inline]

duh

virtual bool Player::isDisplacable (  )  const [virtual]

Returns true if this object allows itself to be displaced.

See also:
displaceObject

Reimplemented from SceneObject.

virtual Point3F Player::getMomentum (  )  const [virtual]

Returns the momentum of this object.

Reimplemented from SceneObject.

virtual void Player::setMomentum ( const Point3F momentum  )  [virtual]

Sets the momentum of this object.

Parameters:
momentum Momentum

Reimplemented from SceneObject.

virtual F32 Player::getMass (  )  const [virtual]

Returns the mass of this object.

Reimplemented from SceneObject.

virtual bool Player::displaceObject ( const Point3F displaceVector  )  [virtual]

Displaces this object by a vector.

Parameters:
displaceVector Displacement vector

Reimplemented from SceneObject.

virtual bool Player::getAIMove ( Move  )  [virtual]

Reimplemented in AIPlayer.

bool Player::checkDismountPosition ( const MatrixF oldPos,
const MatrixF newPos 
)

Is it safe to dismount here?

bool Player::onAdd (  )  [virtual]

Called when the object is added to the sim.

Reimplemented from ShapeBase.

void Player::onRemove (  )  [virtual]

Called when the object is removed from the sim.

Reimplemented from ShapeBase.

bool Player::onNewDataBlock ( GameBaseData dptr  )  [virtual]

Called when a new datablock is set.

This allows subclasses to appropriately handle new datablocks.

See also:
setDataBlock()
Parameters:
dptr New datablock

Reimplemented from ShapeBase.

void Player::onScaleChanged (  )  [virtual]

Called when the size of the object changes.

Reimplemented from SceneObject.

const char* Player::getStateName (  ) 

bool Player::setActionThread ( const char *  sequence,
bool  hold,
bool  wait,
bool  fsp = false 
)

bool Player::setArmThread ( const char *  sequence  ) 

void Player::setControlObject ( ShapeBase obj  )  [virtual]

sets the object this is controling

Parameters:
obj New controlled object

Reimplemented from ShapeBase.

ShapeBase* Player::getControlObject (  )  [virtual]

Returns the object this is controling.

Reimplemented from ShapeBase.

void Player::updateWorkingCollisionSet (  ) 

void Player::processTick ( const Move move  )  [virtual]

Processes a move event and updates object state once every 32 milliseconds.

This takes place both on the client and server, every 32 milliseconds (1 tick).

See also:
ProcessList
Parameters:
move Move event corresponding to this tick, or NULL.

Reimplemented from ShapeBase.

void Player::interpolateTick ( F32  delta  )  [virtual]

Interpolates between tick events.

This takes place on the CLIENT ONLY.

Parameters:
delta Time since last call to interpolate

Reimplemented from GameBase.

void Player::advanceTime ( F32  dt  )  [virtual]

Advances simulation time for animations.

This is called every frame.

Parameters:
dt Time since last advance call

Reimplemented from ShapeBase.

bool Player::castRay ( const Point3F start,
const Point3F end,
RayInfo info 
) [virtual]

Casts a ray from start to end, stores gathered information in 'info' returns true if successful.

Parameters:
start Start point for ray
end End point for ray
info Information from raycast (out)

Reimplemented from ShapeBase.

bool Player::buildPolyList ( AbstractPolyList polyList,
const Box3F box,
const SphereF sphere 
) [virtual]

Builds a polylist of the polygons in this object returns true if successful.

Parameters:
polyList Returned polylist (out)
box Not used
sphere Not used

Reimplemented from ShapeBase.

void Player::buildConvex ( const Box3F box,
Convex convex 
) [virtual]

Builds a convex hull for this object.

See also:
Convex
Parameters:
box Bounding box
convex New convex hull (out)

Reimplemented from ShapeBase.

bool Player::isControlObject (  ) 

void Player::onCameraScopeQuery ( NetConnection cr,
CameraScopeQuery  
) [virtual]

Control object scoping.

Reimplemented from ShapeBase.

void Player::writePacketData ( GameConnection conn,
BitStream stream 
) [virtual]

Write state information necessary to perform client side prediction of an object.

This information is sent only to the controling object. For example, if you are a client controlling a Player, the server uses writePacketData() instead of packUpdate() to generate the data you receive.

Parameters:
conn Connection for which we're generating this data.
stream Bitstream for output.

Reimplemented from ShapeBase.

void Player::readPacketData ( GameConnection conn,
BitStream stream 
) [virtual]

Read data written with writePacketData() and update the object state.

Parameters:
conn Connection for which we're generating this data.
stream Bitstream to read.

Reimplemented from ShapeBase.

U32 Player::packUpdate ( NetConnection conn,
U32  mask,
BitStream stream 
) [virtual]

Instructs this object to pack its state for transfer over the network.

Parameters:
conn Net connection being used
mask Mask indicating fields to transmit.
stream Bitstream to pack data to
Returns:
Any bits which were not dealt with. The value is stored by the networking system. Don't set bits you weren't passed.

Reimplemented from ShapeBase.

void Player::unpackUpdate ( NetConnection conn,
BitStream stream 
) [virtual]

Instructs this object to read state data previously packed with packUpdate.

Parameters:
conn Net connection being used
stream stream to read from

Reimplemented from ShapeBase.

virtual bool Player::prepRenderImage ( SceneState state,
const U32  stateKey,
const U32  startZone,
const bool  modifyBaseZoneState 
) [virtual]

Called when the SceneGraph is ready for the registration of RenderImages.

See also:
SceneState
Parameters:
state SceneState
stateKey State key of the current SceneState
startZone Base zone index
modifyBaseZoneState If true, the object needs to modify the zone state.

Reimplemented from ShapeBase.


Member Data Documentation

SimObjectPtr<ParticleEmitter> Player::mSplashEmitter[PlayerData::NUM_SPLASH_EMITTERS] [private]

Used for interpolation on the client.

See also:
StateDelta

Number of ticks to predict.

Head rotation, uses only x & z.

Point3F Player::mRot [private]

Body rotation, uses only z.

Velocity.

Pos compression anchor.

F32 Player::mGravity [static, private]

Gravity.

mMountPending suppresses tickDelay countdown so players will sit until their mount, or another animation, comes through (or 13 seconds elapses).

What is the player doing?

See also:
ActionState

Falling in mid-air?

Delay till next jump.

Ticks since last contact.

Normal of the surface the player last jumped on.

How long it's been since the player landed (ticks).

Amount to slide the weapon back (if it's up against something).

Sound for moving bubbles.

Sound for underwater breath.

Controlling object.

Range Player::mArmRange [static, private]

Range Player::mHeadVRange [static, private]

Range Player::mHeadHRange [static, private]

Are we in the mission area?

same as recoverTicks in the player datablock

Are we in liquid?

MMmmmmm...datablock...

Reimplemented from ShapeBase.

Holds the last position for physics updates.

Same as mLastPos, but for water.

struct Player::Death Player::mDeath [private]

bool Player::mJetting [protected]