dtCore::FPSCollider Class Reference

This class uses ode to simulate fps movement on collision meshes note: this is a simplified physical model and has a few caveats listed below. More...

#include <fpscollider.h>

List of all members.

Public Types

enum  eMode { WALKING = 0, FALLING, SLIDING }

Public Member Functions

 FPSCollider (float pHeight, float pRadius, float k, float theta, dtCore::Scene *pScene)
 Constructor.
 FPSCollider (float pHeight, float pRadius, float k, float theta, dSpaceID pSpaceToCollideWith, const osg::Vec3 &pGravity)
virtual ~FPSCollider ()
osg::Vec3 Update (const osg::Vec3 &p0, const osg::Vec3 &v0, float deltaFrameTime, bool pJump)
 
Parameters:
p0 is the current position of the camera which is our position plus our height above the ground

dSpaceID GetSpaceID () const
 
Returns:
returns the space id used for the FPSCollider this can be useful for resolving collisions between the collider and other objects (perhaps another collider)

eMode GetMode () const
 
Returns:
our current mode, WALKING, FALLING, or SLIDING

float GetSlideThreshold () const
void SetSlideThreshold (float pSlide)
float GetSlideSpeed () const
 
Returns:
the slide speed is the speed we will travel perpendicular to the normal

void SetSlideSpeed (float pSpeed)
float GetJumpSpeed () const
 Jump speed is the force we apply to our body when jumping in meters per second.
void SetJumpSpeed (float pSpeed)
float GetHeightAboveTerrain () const
 
Returns:
height above the terrain is the camera height and the top of our bv

void SetDimensions (float pHeight, float pRadius, float k, float theta)
 
Parameters:
pHeight is the height of our camera and the top of our bv


Detailed Description

This class uses ode to simulate fps movement on collision meshes note: this is a simplified physical model and has a few caveats listed below.

-We currently only support collision meshes -There is a maximum slope that we can go up (SlideThreshold), when on a poly with normal dotted with Up (0,0,1) < SlideThreshold we begin sliding, the user has no control until sliding is resolved and we are on a "good" poly again -Because user has no control during Sliding we can get stuck where two polys come together where each one is too steep to climb up, typical ravine like so \/ -Also when sliding we will continue sliding even if our momentum should carry us over the edge of a cliff


Member Enumeration Documentation

enum dtCore::FPSCollider::eMode

Enumerator:
WALKING 
FALLING 
SLIDING 


Constructor & Destructor Documentation

dtCore::FPSCollider::FPSCollider ( float  pHeight,
float  pRadius,
float  k,
float  theta,
dtCore::Scene pScene 
)

Constructor.

Parameters:
height,the height of the character and camera, in meters
radius,the width of our character
k the distance from the bottom of the knees to the ground, this represents the maximum step up height
theta the collision amount to maintain below the ground (note: this should be less then half of k, something small like 0.1 is recommended)
Scene is used to get the gravity and the ode space

dtCore::FPSCollider::FPSCollider ( float  pHeight,
float  pRadius,
float  k,
float  theta,
dSpaceID  pSpaceToCollideWith,
const osg::Vec3 &  pGravity 
)

dtCore::FPSCollider::~FPSCollider (  )  [virtual]


Member Function Documentation

osg::Vec3 dtCore::FPSCollider::Update ( const osg::Vec3 &  p0,
const osg::Vec3 &  v0,
float  deltaFrameTime,
bool  pJump 
)

Parameters:
p0 is the current position of the camera which is our position plus our height above the ground

Parameters:
v0 is our instantaneous velocity, or the direction we want to go as a note the last velocity is saved for adjusting falling speed so if you want to warp you may need to set velocity to 0 for one frame
deltaFrameTime is the elapsed time in seconds since the last frame
pJump specifies whether or not we want to jump
Returns:
our new position in world coordinates, whatever this is controlling should be set to this pos

dSpaceID dtCore::FPSCollider::GetSpaceID (  )  const

Returns:
returns the space id used for the FPSCollider this can be useful for resolving collisions between the collider and other objects (perhaps another collider)

FPSCollider::eMode dtCore::FPSCollider::GetMode (  )  const

Returns:
our current mode, WALKING, FALLING, or SLIDING

Note:
we start in the FALLING state

float dtCore::FPSCollider::GetSlideThreshold (  )  const

void dtCore::FPSCollider::SetSlideThreshold ( float  pSlide  ) 

float dtCore::FPSCollider::GetSlideSpeed (  )  const

Returns:
the slide speed is the speed we will travel perpendicular to the normal

void dtCore::FPSCollider::SetSlideSpeed ( float  pSpeed  ) 

float dtCore::FPSCollider::GetJumpSpeed (  )  const

Jump speed is the force we apply to our body when jumping in meters per second.

void dtCore::FPSCollider::SetJumpSpeed ( float  pSpeed  ) 

float dtCore::FPSCollider::GetHeightAboveTerrain (  )  const

Returns:
height above the terrain is the camera height and the top of our bv

void dtCore::FPSCollider::SetDimensions ( float  pHeight,
float  pRadius,
float  k,
float  theta 
)

Parameters:
pHeight is the height of our camera and the top of our bv

Parameters:
pRadius is the width of our character
k is the max distance we can step up and the size of our feet bv
theta is the distance we maintain below the surface (should be less then half of k)


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