CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csColliderHelper Class Reference

This is a class containing a few static member functions to help work with csColliderWrapper and collision detection in general. More...

#include <collider.h>

List of all members.

Static Public Methods

void InitializeCollisionWrapper (iCollideSystem *colsys, iMeshWrapper *mesh)
 Initialize collision detection for a single object.

void InitializeCollisionWrappers (iCollideSystem *colsys, iEngine *engine, iRegion *region=0)
 Initialize collision detection (i.e.

bool CollideArray (iCollideSystem *colsys, iCollider *collider, const csReversibleTransform *trans, int num_colliders, iCollider **colliders, csReversibleTransform **transforms)
 Test collision between one collider and an array of colliders.

int CollidePath (iCollideSystem *colsys, iCollider *collider, const csReversibleTransform *trans, float stepsize, csVector3 &newpos, int num_colliders, iCollider **colliders, csReversibleTransform **transforms)
 Test if an object can move to a new position.


Detailed Description

This is a class containing a few static member functions to help work with csColliderWrapper and collision detection in general.

Definition at line 129 of file collider.h.


Member Function Documentation

bool csColliderHelper::CollideArray iCollideSystem   colsys,
iCollider   collider,
const csReversibleTransform   trans,
int    num_colliders,
iCollider **    colliders,
csReversibleTransform **    transforms
[static]
 

Test collision between one collider and an array of colliders.

This function is mainly used by CollidePath() below.

Parameters:
colsys  is the collider system.
collider  is the collider of the object that we are going to move along the path.
trans  is the transform of that object (see Collide()).
newpos  is the new position of that object.
num_colliders  is the number of colliders that we are going to use to collide with.
colliders  is an array of colliders. Typically you can obtain such a list by doing iEngine->GetNearbyMeshes() and then getting the colliders from all meshes you get (possibly using csColliderWrapper). Note that it is safe to have 'collider' sitting in this list. This function will ignore that collider.
transforms  is an array of transforms that belong with the array of colliders.

int csColliderHelper::CollidePath iCollideSystem   colsys,
iCollider   collider,
const csReversibleTransform   trans,
float    stepsize,
csVector3   newpos,
int    num_colliders,
iCollider **    colliders,
csReversibleTransform **    transforms
[static]
 

Test if an object can move to a new position.

The new position vector will be modified to reflect the maximum new position that the object could move to without colliding with something. This function will return:

  • -1 if the object could not move at all (i.e. stuck at start position).
  • 0 if the object could not move fully to the desired position.
  • 1 if the object can move unhindered to the end position.

This function will reset the collision pair array. If there was a collision along the way the array will contain the information for the first collision preventing movement.

The given transform should be the transform of the object corresponding with the old position. 'colliders' and 'transforms' should be arrays with 'num_colliders' elements for all the objects that we should test against.

Parameters:
colsys  is the collider system.
collider  is the collider of the object that we are going to move along the path.
trans  is the transform of that object (see Collide()).
stepsize  is the distance we want to recheck CD along the path. Typically this is set to a step size smaller then the size of the collider bbox.
newpos  is the new position of that object.
num_colliders  is the number of colliders that we are going to use to collide with.
colliders  is an array of colliders. Typically you can obtain such a list by doing iEngine->GetNearbyMeshes() and then getting the colliders from all meshes you get (possibly using csColliderWrapper). Note that it is safe to have 'collider' sitting in this list. This function will ignore that collider.
transforms  is an array of transforms that belong with the array of colliders.

void csColliderHelper::InitializeCollisionWrapper iCollideSystem   colsys,
iMeshWrapper   mesh
[static]
 

Initialize collision detection for a single object.

This function will first check if the parent factory has a collider. If so it will use that for the object too. Otherwise it will create a new collider and attaches it to the object. The new collider will also be attached to the parent factory if it supports iObjectModel.

This function will also initialize colliders for the children of the mesh.

void csColliderHelper::InitializeCollisionWrappers iCollideSystem   colsys,
iEngine   engine,
iRegion   region = 0
[static]
 

Initialize collision detection (i.e.

create csColliderWrapper) for all objects in the engine. If the optional region is given only the objects from that region will be initialized.


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