CrystalSpace

Public API Reference

Static Public Member Functions
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 <cstool/collider.h>

List of all members.

Static Public Member Functions

static 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.
static int CollidePath (iCollideSystem *colsys, iCollider *collider, const csReversibleTransform *trans, float nbrsteps, csVector3 &newpos, int num_colliders, iCollider **colliders, csReversibleTransform **transforms)
 Test if an object can move to a new position.
static csColliderWrapperInitializeCollisionWrapper (iCollideSystem *colsys, iMeshWrapper *mesh)
 Initialize collision detection for a single object.
static void InitializeCollisionWrappers (iCollideSystem *colsys, iEngine *engine, iCollection *collection=0)
 Initialize collision detection (ie create csColliderWrapper) for all objects in the engine.
static void InitializeCollisionWrappers (iCollideSystem *colsys, iSector *sector, iCollection *collection=0)
 Initialize collision detection (ie create csColliderWrapper) for all objects in a sector.
static float TraceBeam (iCollideSystem *cdsys, iSector *sector, const csVector3 &start, const csVector3 &end, bool traverse_portals, csIntersectingTriangle &closest_tri, csVector3 &closest_isect, iMeshWrapper **closest_mesh=0, iSector **end_sector=0)
 Trace a beam from 'start' to 'end' and return the first hit.
static csTraceBeamResult TraceBeam (iCollideSystem *cdsys, iSector *sector, const csVector3 &start, const csVector3 &end, bool traverse_portals)
 Trace a beam from 'start' to 'end' and return the first hit.

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 200 of file collider.h.


Member Function Documentation

static 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:
colsysis the collider system.
collideris the collider of the object that we are going to move along the path.
transis the transform of that object (see Collide()).
num_collidersis the number of colliders that we are going to use to collide with.
collidersis 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.
transformsis an array of transforms that belong with the array of colliders.
static int csColliderHelper::CollidePath ( iCollideSystem colsys,
iCollider collider,
const csReversibleTransform trans,
float  nbrsteps,
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:
colsysis the collider system.
collideris the collider of the object that we are going to move along the path.
transis the transform of that object (see Collide()).
nbrstepsis the number of steps we want to check along the path. Typically the stepsize resulting from this number of steps is set to a step size smaller then the size of the collider bbox.
newposis the new position of that object.
num_collidersis the number of colliders that we are going to use to collide with.
collidersis 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.
transformsis an array of transforms that belong with the array of colliders.

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.

Returns:
the created collider wrapper.
static void csColliderHelper::InitializeCollisionWrappers ( iCollideSystem colsys,
iEngine engine,
iCollection collection = 0 
) [static]

Initialize collision detection (ie create csColliderWrapper) for all objects in the engine.

If the optional collection is given only the objects from that collection will be initialized.

static void csColliderHelper::InitializeCollisionWrappers ( iCollideSystem colsys,
iSector sector,
iCollection collection = 0 
) [static]

Initialize collision detection (ie create csColliderWrapper) for all objects in a sector.

If the optional collection is given only the objects from that collection will be initialized.

static float csColliderHelper::TraceBeam ( iCollideSystem cdsys,
iSector sector,
const csVector3 start,
const csVector3 end,
bool  traverse_portals,
csIntersectingTriangle closest_tri,
csVector3 closest_isect,
iMeshWrapper **  closest_mesh = 0,
iSector **  end_sector = 0 
) [static]

Trace a beam from 'start' to 'end' and return the first hit.

This function will use CollideRay() from the collision detection system and is pretty fast. Note that only OPCODE plugin currently supports this! A special note about portals! Portal traversal will NOT be used on portals that have a collider! The idea there is that the portal itself is a surface that cannot be penetrated.

Parameters:
cdsysThe collider system.
sectorThe starting sector for the beam.
startThe start of the beam.
endThe end of the beam.
traverse_portalsSet it to true in case you want the beam to traverse portals.
closest_triWill be set to the closest triangle that is hit. The triangle will be specified in world space.
closest_isectWill be set to the closest intersection point (in world space).
closest_meshWill be set to the closest mesh that is hit.
end_sector[optional] Will be set to the sector containing the closest_mesh.
Returns:
The squared distance between 'start' and the closest hit or else a negative number if there was no hit.
static csTraceBeamResult csColliderHelper::TraceBeam ( iCollideSystem cdsys,
iSector sector,
const csVector3 start,
const csVector3 end,
bool  traverse_portals 
) [static]

Trace a beam from 'start' to 'end' and return the first hit.

This function will use CollideRay() from the collision detection system and is pretty fast. Note that only OPCODE plugin currently supports this! A special note about portals! Portal traversal will NOT be used on portals that have a collider! The idea there is that the portal itself is a surface that cannot be penetrated.

Parameters:
cdsysis the collider system.
sectoris the starting sector for the beam.
startis the start of the beam.
endis the end of the beam.
traverse_portalsset to true in case you want the beam to traverse portals.
Returns:
a result instance of csTraceBeamResult.
See also:
csTraceBeamResult

The documentation for this class was generated from the following file:

Generated for Crystal Space 2.0 by doxygen 1.7.6.1