CrystalSpace

Public API Reference

csColliderActor Class Reference

With csColliderActor you can more easily manage collision detection of a player or character model with gravity handling. More...

#include <cstool/collider.h>

List of all members.

Public Member Functions

bool AdjustForCollisions (const csVector3 &oldpos, csVector3 &newpos, const csVector3 &vel, float delta)
 This is used by Move() but you can also call it manually.
bool CheckHitMeshes () const
 Return true if we remember the meshes we hit.
bool CheckRevertMove () const
 Check if we should revert a move (revert rotation).
 csColliderActor ()
 Construct.
void EnableHitMeshes (bool hm)
 Enable remembering of the meshes we hit.
float GetGravity () const
 Get gravity.
const csSet< csPtrKey< iMeshWrapper > > & GetHitMeshes ()
 Return the meshes that we hit in the last call to Move().
const csVector3GetRotation ()
 Get current rotation in angles around every axis.
bool HasCD () const
 Return true if collision detection is enabled.
void InitializeColliders (iCamera *camera, const csVector3 &legs, const csVector3 &body, const csVector3 &shift)
 Initialize the colliders.
void InitializeColliders (iMeshWrapper *mesh, const csVector3 &legs, const csVector3 &body, const csVector3 &shift)
 Initialize the colliders.
bool IsOnGround () const
 Check if we are on the ground.
bool Move (float delta, float speed, const csVector3 &velBody, const csVector3 &angularVelocity)
 Move the model.
void SetCamera (iCamera *camera, bool adjustRotation=true)
 Change the current camera.
void SetCD (bool c)
 Enable/disable collision detection (default enabled).
void SetCollideSystem (iCollideSystem *cdsys)
 Set the collision detection system.
void SetEngine (iEngine *engine)
 Set the engine.
void SetGravity (float g)
 Set gravity.
void SetOnGround (bool og)
 Set the onground status.
void SetRotation (const csVector3 &rot)
 Set current rotation.


Detailed Description

With csColliderActor you can more easily manage collision detection of a player or character model with gravity handling.

Definition at line 334 of file collider.h.


Constructor & Destructor Documentation

csColliderActor::csColliderActor (  ) 

Construct.


Member Function Documentation

bool csColliderActor::AdjustForCollisions ( const csVector3 oldpos,
csVector3 newpos,
const csVector3 vel,
float  delta 
)

This is used by Move() but you can also call it manually.

It will adjust the new position to match with collision detection.

bool csColliderActor::CheckHitMeshes (  )  const [inline]

Return true if we remember the meshes we hit.

Definition at line 502 of file collider.h.

bool csColliderActor::CheckRevertMove (  )  const [inline]

Check if we should revert a move (revert rotation).

Definition at line 491 of file collider.h.

void csColliderActor::EnableHitMeshes ( bool  hm  )  [inline]

Enable remembering of the meshes we hit.

By default this is disabled. If this is enabled you can call GetHitMeshes() after calling Move() to get a set of all meshes that were hit.

Definition at line 499 of file collider.h.

float csColliderActor::GetGravity (  )  const [inline]

Get gravity.

Definition at line 466 of file collider.h.

const csSet<csPtrKey<iMeshWrapper> >& csColliderActor::GetHitMeshes (  )  [inline]

Return the meshes that we hit in the last call to Move().

Calling Move() again will clear this set and calculate it again. This works only if EnableHitMeshes(true) is called.

Definition at line 509 of file collider.h.

const csVector3& csColliderActor::GetRotation (  )  [inline]

Get current rotation in angles around every axis.

This is only used if a camera is used.

Definition at line 531 of file collider.h.

bool csColliderActor::HasCD (  )  const [inline]

Return true if collision detection is enabled.

Definition at line 481 of file collider.h.

void csColliderActor::InitializeColliders ( iCamera camera,
const csVector3 legs,
const csVector3 body,
const csVector3 shift 
)

Initialize the colliders.

This version is used if you have a first person view and want collision detection to move the camera instead of a mesh.

Parameters:
camera is the camera.
legs is the size of the leg collider.
body is the size of the body collider.
shift is a shift added to the colliders. Normally the origin is assumed to be at the bottom of the model. With this shift you can adjust that.

void csColliderActor::InitializeColliders ( iMeshWrapper mesh,
const csVector3 legs,
const csVector3 body,
const csVector3 shift 
)

Initialize the colliders.

Parameters:
mesh is the mesh.
legs is the size of the leg collider.
body is the size of the body collider.
shift is a shift added to the colliders. Normally the origin is assumed to be at the bottom of the model. With this shift you can adjust that.

bool csColliderActor::IsOnGround (  )  const [inline]

Check if we are on the ground.

Definition at line 471 of file collider.h.

bool csColliderActor::Move ( float  delta,
float  speed,
const csVector3 velBody,
const csVector3 angularVelocity 
)

Move the model.

If EnableHitMeshes(true) is set then you can use GetHitMeshes() after this to detect the meshes that were hit.

Parameters:
delta is the number of seconds (floating point) elapsed time. Typically this is the elapsed time from the virtual clock divided by 1000.0f.
speed is the desired movement speed. This can be 1.0f for default speed.
velBody is the relative movement vector in object space of the model (i.e. 0,0,1 will move the model forward).
angularVelocity is the velocity of rotation.

void csColliderActor::SetCamera ( iCamera camera,
bool  adjustRotation = true 
)

Change the current camera.

Parameters:
camera New current camera
adjustRotation Whether to retrieve the current rotation from the camera.

void csColliderActor::SetCD ( bool  c  )  [inline]

Enable/disable collision detection (default enabled).

Definition at line 486 of file collider.h.

void csColliderActor::SetCollideSystem ( iCollideSystem cdsys  )  [inline]

Set the collision detection system.

Definition at line 409 of file collider.h.

void csColliderActor::SetEngine ( iEngine engine  )  [inline]

Set the engine.

Definition at line 415 of file collider.h.

void csColliderActor::SetGravity ( float  g  )  [inline]

Set gravity.

Terran default is 9.806.

Definition at line 457 of file collider.h.

void csColliderActor::SetOnGround ( bool  og  )  [inline]

Set the onground status.

Definition at line 476 of file collider.h.

void csColliderActor::SetRotation ( const csVector3 rot  ) 

Set current rotation.

This is only used if a camera is used.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.4.7