dtCore::FPSMotionModel Class Reference

A motion model used for typical First Person Shooter motion. More...

#include <fpsmotionmodel.h>

Inheritance diagram for dtCore::FPSMotionModel:

dtCore::MotionModel dtCore::Base dtCore::CollisionMotionModel

List of all members.

Public Member Functions

 FPSMotionModel (Keyboard *keyboard=0, Mouse *mouse=0, float maxWalkSpeed=5.0f, float maxTurnSpeed=100.0f, float maxSidestepSpeed=5.0f, float height=2.0f, float maxStepUpDist=1.0f)
 Constructor.
void SetScene (Scene *scene)
 Sets the active Scene, which is used for ground following.
SceneGetScene ()
 Returns the active Scene.
virtual void SetEnabled (bool enabled)
 Enables or disables this motion model.
void SetDefaultMappings (Keyboard *keyboard, Mouse *mouse)
 Sets the input axes to a set of default mappings for mouse and keyboard.
void SetWalkForwardBackwardAxis (Axis *walkForwardBackwardAxis)
 Sets the axis that moves the target forwards (for positive values) or backwards (for negative values).
AxisGetWalkForwardBackwardAxis ()
 Returns the axis that moves the target forwards (for positive values) or backwards (for negative values).
void SetTurnLeftRightAxis (Axis *turnLeftRightAxis)
 Sets the axis that turns the target left (for negative values) or right (for positive values).
AxisGetTurnLeftRightAxis ()
 Returns the axis that turns the target left (for negative values) or right (for positive values).
void SetLookUpDownAxis (Axis *lookUpDownAxis)
 Sets the axis looks down (for negative values) or up (for positive values).
AxisGetLookUpDownAxis ()
 Returns the axis that looks down (for negative values) or up (for positive values).
void SetSidestepLeftRightAxis (Axis *sidestepLeftRightAxis)
 Sets the axis that sidesteps the target left (for negative values) or right (for positive values).
AxisGetSidestepLeftRightAxis ()
 Returns the axis that sidesteps the target left (for negative values) or right (for positive values).
void SetMaximumWalkSpeed (float maximumWalkSpeed)
 Sets the maximum walk speed (meters per second).
float GetMaximumWalkSpeed ()
 Returns the maximum walk speed (meters per second).
void SetMaximumTurnSpeed (float maximumTurnSpeed)
 Sets the maximum turn speed (degrees per second).
float GetMaximumTurnSpeed ()
 Returns the maximum turn speed (degrees per second).
void SetMaximumSidestepSpeed (float maximumSidestepSpeed)
 Sets the maximum sidestep speed (meters per second).
float GetMaximumSidestepSpeed ()
 Returns the maximum sidestep speed (meters per second).
void SetHeightAboveTerrain (float heightAboveTerrain)
 Sets the height to maintain above the terrain (meters).
float GetHeightAboveTerrain ()
 Returns the height to maintain above the terrain (meters).
void SetMaximumStepUpDistance (float maximumStepUpDistance)
 Sets the maximum step-up distance.
float GetMaximumStepUpDistance ()
 Returns the current maximum step-up distance.
void SetFallingHeight (float fallingHeight)
 Set the height distance at which point we're falling.
float GetFallingHeight () const
 Get the distance above terrain at which point we're falling.
virtual void OnMessage (MessageData *data)
 Message handler callback.
void SetUseMouseButtons (bool use)
 Sets having to use the mouse buttons to move the camera.
void InvertMouse (bool b)
 Inverts the mouse movement in pitch.
bool GetInvertMouse ()
 
Returns:
whether or not the mouse movement in pitch has been inverted


Protected Member Functions

virtual ~FPSMotionModel ()
 Destructor.
virtual void UpdateMouse (const double deltaTime)
 This method can be overriden in subclasses to produce desired mouse behavior.
virtual void PerformTranslation (const double deltaTime)
 This method can be overriden in subclasses to produce desired translation behavior Note: Any collision detection/response and other physical constraints should be applied here.
float GetSidestepFactor () const
 Returns the factor [-1.0, 1.0] to side-step by.
float GetForwardBackFactor () const
 Returns the factor [-1.0, 1.0] to walk by.
MouseGetMouse () const
 Returns the mouse.
KeyboardGetKeyboard () const
 Returns the keyboard.

Classes

class  FPSAxisListener
 internal class, used by FPSMotionModel for InputDevice listening More...


Detailed Description

A motion model used for typical First Person Shooter motion.

Constructor & Destructor Documentation

dtCore::FPSMotionModel::FPSMotionModel ( Keyboard keyboard = 0,
Mouse mouse = 0,
float  maxWalkSpeed = 5.0f,
float  maxTurnSpeed = 100.0f,
float  maxSidestepSpeed = 5.0f,
float  height = 2.0f,
float  maxStepUpDist = 1.0f 
)

Constructor.

Parameters:
keyboard the keyboard instance, or 0 to avoid creating default input mappings
mouse the mouse instance, or 0 to avoid creating default input mappings
maxWalkSpeed the maximum walking speed
maxTurnSpeed the maximum turning speed
maxSidestepSpeed the maximum sidestep speed
height the height above the terrain at which we stand
maxStepUpDist the maximum distance we can step up to higher terrain
keyboard the keyboard instance, or 0 to avoid creating default input mappings
mouse the mouse instance, or 0 to avoid creating default input mappings

dtCore::FPSMotionModel::~FPSMotionModel (  )  [protected, virtual]

Destructor.


Member Function Documentation

void dtCore::FPSMotionModel::UpdateMouse ( const double  deltaTime  )  [protected, virtual]

This method can be overriden in subclasses to produce desired mouse behavior.

Parameters:
deltaTime The time change

void dtCore::FPSMotionModel::PerformTranslation ( const double  deltaTime  )  [protected, virtual]

This method can be overriden in subclasses to produce desired translation behavior Note: Any collision detection/response and other physical constraints should be applied here.

Parameters:
deltaTime The time change

Reimplemented in dtCore::CollisionMotionModel.

float dtCore::FPSMotionModel::GetSidestepFactor (  )  const [inline, protected]

Returns the factor [-1.0, 1.0] to side-step by.

Returns:
the current sidestep factor

float dtCore::FPSMotionModel::GetForwardBackFactor (  )  const [inline, protected]

Returns the factor [-1.0, 1.0] to walk by.

Returns:
the current walk factor

Mouse* dtCore::FPSMotionModel::GetMouse (  )  const [inline, protected]

Returns the mouse.

Returns:
the mouse

Keyboard* dtCore::FPSMotionModel::GetKeyboard (  )  const [inline, protected]

Returns the keyboard.

Returns:
the keyboard

void dtCore::FPSMotionModel::SetScene ( Scene scene  ) 

Sets the active Scene, which is used for ground following.

Parameters:
scene the active scene

Scene * dtCore::FPSMotionModel::GetScene (  ) 

Returns the active Scene.

Returns:
the active Scene

void dtCore::FPSMotionModel::SetEnabled ( bool  enabled  )  [virtual]

Enables or disables this motion model.

Parameters:
enabled true to enable this motion model, false to disable it

Reimplemented from dtCore::MotionModel.

void dtCore::FPSMotionModel::SetDefaultMappings ( Keyboard keyboard,
Mouse mouse 
)

Sets the input axes to a set of default mappings for mouse and keyboard.

Parameters:
keyboard the keyboard instance
mouse the mouse instance

void dtCore::FPSMotionModel::SetWalkForwardBackwardAxis ( Axis walkForwardBackwardAxis  ) 

Sets the axis that moves the target forwards (for positive values) or backwards (for negative values).

Parameters:
walkForwardBackwardAxis the new forward/backward axis

Axis * dtCore::FPSMotionModel::GetWalkForwardBackwardAxis (  ) 

Returns the axis that moves the target forwards (for positive values) or backwards (for negative values).

Returns:
the current forward/backward axis

void dtCore::FPSMotionModel::SetTurnLeftRightAxis ( Axis turnLeftRightAxis  ) 

Sets the axis that turns the target left (for negative values) or right (for positive values).

Parameters:
turnLeftRightAxis the new turn left/right axis

Axis * dtCore::FPSMotionModel::GetTurnLeftRightAxis (  ) 

Returns the axis that turns the target left (for negative values) or right (for positive values).

Returns:
the current turn left/right axis

void dtCore::FPSMotionModel::SetLookUpDownAxis ( Axis lookUpDownAxis  ) 

Sets the axis looks down (for negative values) or up (for positive values).

Sets the axis that looks down (for negative values) or up (for positive values).

Parameters:
lookUpDownAxis the new look up/down axis

Axis * dtCore::FPSMotionModel::GetLookUpDownAxis (  ) 

Returns the axis that looks down (for negative values) or up (for positive values).

Returns:
the current look up/down axis

void dtCore::FPSMotionModel::SetSidestepLeftRightAxis ( Axis sidestepLeftRightAxis  ) 

Sets the axis that sidesteps the target left (for negative values) or right (for positive values).

Parameters:
sidestepLeftRightAxis the new sidestep left/right axis

Axis * dtCore::FPSMotionModel::GetSidestepLeftRightAxis (  ) 

Returns the axis that sidesteps the target left (for negative values) or right (for positive values).

Returns:
the current sidestep left/right axis

void dtCore::FPSMotionModel::SetMaximumWalkSpeed ( float  maximumWalkSpeed  ) 

Sets the maximum walk speed (meters per second).

Parameters:
maximumWalkSpeed the new maximum walk speed

float dtCore::FPSMotionModel::GetMaximumWalkSpeed (  ) 

Returns the maximum walk speed (meters per second).

Returns:
the current maximum walk speed

void dtCore::FPSMotionModel::SetMaximumTurnSpeed ( float  maximumTurnSpeed  ) 

Sets the maximum turn speed (degrees per second).

Parameters:
maximumTurnSpeed the new maximum turn speed

float dtCore::FPSMotionModel::GetMaximumTurnSpeed (  ) 

Returns the maximum turn speed (degrees per second).

Returns:
the current maximum turn speed

void dtCore::FPSMotionModel::SetMaximumSidestepSpeed ( float  maximumSidestepSpeed  ) 

Sets the maximum sidestep speed (meters per second).

Parameters:
maximumSidestepSpeed the new maximum sidestep speed

float dtCore::FPSMotionModel::GetMaximumSidestepSpeed (  ) 

Returns the maximum sidestep speed (meters per second).

Returns:
the current maximum sidestep speed

void dtCore::FPSMotionModel::SetHeightAboveTerrain ( float  heightAboveTerrain  ) 

Sets the height to maintain above the terrain (meters).

Parameters:
heightAboveTerrain the height to maintain above the terrain

float dtCore::FPSMotionModel::GetHeightAboveTerrain (  ) 

Returns the height to maintain above the terrain (meters).

Returns:
the height to maintain above the terrain

void dtCore::FPSMotionModel::SetMaximumStepUpDistance ( float  maximumStepUpDistance  ) 

Sets the maximum step-up distance.

When clamping to the ground, the maximum step-up distance determines whether to rise to a new level (as when the model climbs a staircase) or to stay at the current level (as when the model passes under a roof). The default is 1.0.

Parameters:
maximumStepUpDistance the new maximum step-up distance

float dtCore::FPSMotionModel::GetMaximumStepUpDistance (  ) 

Returns the current maximum step-up distance.

Returns:
the maximum step-up distance

void dtCore::FPSMotionModel::SetFallingHeight ( float  fallingHeight  ) 

Set the height distance at which point we're falling.

If the MotionModel elevation is higher than fallingHeight plus the height of terrain, than we'll let gravity take over. (defaults to 1.0 meter)

Parameters:
fallingHeight,: The distance above terrain at which point we're falling (meters)

float dtCore::FPSMotionModel::GetFallingHeight (  )  const

Get the distance above terrain at which point we're falling.

void dtCore::FPSMotionModel::OnMessage ( MessageData data  )  [virtual]

Message handler callback.

Parameters:
data the message data

Reimplemented from dtCore::Base.

void dtCore::FPSMotionModel::SetUseMouseButtons ( bool  use  )  [inline]

Sets having to use the mouse buttons to move the camera.

Parameters:
use True to use

void dtCore::FPSMotionModel::InvertMouse ( bool  b  )  [inline]

Inverts the mouse movement in pitch.

bool dtCore::FPSMotionModel::GetInvertMouse (  )  [inline]

Returns:
whether or not the mouse movement in pitch has been inverted


http://www.delta3d.org
2.0.0 generated 14 Feb 2008