csColliderActor Class Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions
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.
| 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 csVector3 & | GetRotation ()
| Get current rotation in angles around every axis.
bool | HasCD () const
| Return true if collision detection is enabled.
void | InitializeColliders (iMeshWrapper *mesh, const csVector3 &legs, const csVector3 &body, const csVector3 &shift)
| Initialize the colliders.
void | InitializeColliders (iCamera *camera, 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 359 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 519 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 516 of file collider.h.

float csColliderActor::GetGravity | ( |  | ) | const`[inline]`

Get gravity.

Definition at line 488 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 526 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 548 of file collider.h.

bool csColliderActor::HasCD | ( |  | ) | const`[inline]`

Return true if collision detection is enabled.

Definition at line 503 of file collider.h.

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.

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.

bool csColliderActor::IsOnGround | ( |  | ) | const`[inline]`

Check if we are on the ground.

Definition at line 493 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 508 of file collider.h.

void csColliderActor::SetCollideSystem | ( | iCollideSystem * | cdsys | ) | `[inline]`

Set the collision detection system.

Definition at line 431 of file collider.h.

void csColliderActor::SetEngine | ( | iEngine * | engine | ) | `[inline]`

Set the engine.

Definition at line 437 of file collider.h.

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

Set gravity.

Terran default is 9.806.

Definition at line 479 of file collider.h.

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

Set the onground status.

Definition at line 498 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:

- cstool/collider.h