CrystalSpace

Public API Reference

iCollideSystem Struct Reference

This is the Collide plug-in. More...

#include <ivaria/collider.h>

Inheritance diagram for iCollideSystem:

List of all members.

Public Member Functions

virtual bool Collide (iCollider *collider1, const csReversibleTransform *trans1, iCollider *collider2, const csReversibleTransform *trans2)=0
 Test collision between two colliders.
virtual bool CollideRay (iCollider *collider, const csReversibleTransform *trans, const csVector3 &start, const csVector3 &pointOnRay)=0
 Collide a collider with a (infinite) world space ray.
virtual bool CollideSegment (iCollider *collider, const csReversibleTransform *trans, const csVector3 &start, const csVector3 &end)=0
 Collide a collider with a (finite) world space segment.
virtual csPtr< iColliderCreateCollider (iTerrainSystem *mesh)=0
 Create a Collider from a terrain.
virtual csPtr< iColliderCreateCollider (iTerraFormer *mesh)=0
 Create a Collider from a terrain.
virtual csPtr< iColliderCreateCollider (iTriangleMesh *mesh)=0
 Create a iCollider for the given mesh geometry.
virtual csStringID GetBaseDataID ()=0
 Get the ID that for the base triangle mesh model from iObjectModel.
virtual size_t GetCollisionPairCount ()=0
 Get number of collision pairs in array.
virtual csCollisionPairGetCollisionPairs ()=0
 Get pointer to current array of collision pairs.
virtual const csArray
< csIntersectingTriangle > & 
GetIntersectingTriangles () const =0
 Get the array of intersection points as returned by CollideRay().
virtual bool GetOneHitOnly ()=0
 Return true if this CD system will only return the first hit that is found.
virtual csStringID GetTriangleDataID ()=0
 Get the ID that the collision detection system prefers for getting triangle data from iObjectModel.
virtual void ResetCollisionPairs ()=0
 Reset the array with collision pairs.
virtual void SetOneHitOnly (bool o)=0
 Indicate if we are interested only in the first hit that is found.

Detailed Description

This is the Collide plug-in.

This plugin is a factory for creating iCollider entities. A collider represents an entity in the collision detection world. It uses the geometry data as given by iTriangleMesh.

Main creators of instances implementing this interface:

Main ways to get pointers to this interface:

Main users of this interface:

Definition at line 113 of file collider.h.


Member Function Documentation

virtual bool iCollideSystem::Collide ( iCollider collider1,
const csReversibleTransform trans1,
iCollider collider2,
const csReversibleTransform trans2 
) [pure virtual]

Test collision between two colliders.

This is only supported for iCollider objects created by this plugin. Returns false if no collision or else true. The collisions will be added to the collision pair array that you can query with GetCollisionPairs and reset/clear with ResetCollisionPairs (very important! Do not forget this). Every call to Collide will add to that array.

Parameters:
collider1 is the first collider as created by this same collide system (never pass in a collider created by another collide system).
trans1 is the transform for the object represented by the first collider. If the collider belongs to a mesh object then you can get the transform by calling mesh->GetMovable ()->GetFullTransform().
collider2 is the second collider.
trans2 is the second transform.
Returns:
true if there are triangles that intersect. The array with collision pairs will be updated.
virtual bool iCollideSystem::CollideRay ( iCollider collider,
const csReversibleTransform trans,
const csVector3 start,
const csVector3 pointOnRay 
) [pure virtual]

Collide a collider with a (infinite) world space ray.

Parameters:
collider is the collider to test with.
trans is the transform for the object represented by the collider. If the collider belongs to a mesh object then you can get the transform by calling mesh->GetMovable()->GetFullTransform().
start is the start of the ray.
pointOnRay A point on the ray other than start, used to compute the ray's direction.
Returns:
true if there was a collision. The array with intersecting triangles will be updated (see GetIntersectingTriangles()).
virtual bool iCollideSystem::CollideSegment ( iCollider collider,
const csReversibleTransform trans,
const csVector3 start,
const csVector3 end 
) [pure virtual]

Collide a collider with a (finite) world space segment.

This will not return collisions with triangles behind the end of the segment.

Parameters:
collider is the collider to test with.
trans is the transform for the object represented by the collider. If the collider belongs to a mesh object then you can get the transform by calling mesh->GetMovable()->GetFullTransform().
start is the start of the ray.
end is the end of the ray.
Returns:
true if there was a collision. The array with intersecting triangles will be updated (see GetIntersectingTriangles()).
virtual csPtr<iCollider> iCollideSystem::CreateCollider ( iTerrainSystem mesh  )  [pure virtual]

Create a Collider from a terrain.

virtual csPtr<iCollider> iCollideSystem::CreateCollider ( iTerraFormer mesh  )  [pure virtual]

Create a Collider from a terrain.

This should be used instead of the iTriangleMesh version in case you have a landscape because this is a more optimal way to do.

virtual csPtr<iCollider> iCollideSystem::CreateCollider ( iTriangleMesh mesh  )  [pure virtual]

Create a iCollider for the given mesh geometry.

Parameters:
mesh is a structure describing the geometry from which the collider will be made. You can get such a mesh either by making your own subclass of iTriangleMesh, by getting a mesh from iMeshObject->GetObjectModel()->GetTriangleData(), or else by using csTriangleMesh, or csTriangleMeshBox. Note that the collision detection system usually uses triangle meshes with the id equal to 'colldet'.
Returns:
a reference to a collider that you have to store.
virtual csStringID iCollideSystem::GetBaseDataID (  )  [pure virtual]

Get the ID that for the base triangle mesh model from iObjectModel.

This corresponds with the ID you would get from doing strings->Request ("base") where 'strings' is a reference to the standard string set.

virtual size_t iCollideSystem::GetCollisionPairCount (  )  [pure virtual]

Get number of collision pairs in array.

Returns:
the number of collision pairs.
virtual csCollisionPair* iCollideSystem::GetCollisionPairs (  )  [pure virtual]

Get pointer to current array of collision pairs.

This array will grow with every call to Collide until you clear it using 'ResetCollisionPairs'. Note that the triangles are in object space and not world space!

Returns:
an array of collision pairs for all Collide() calls that occured between now and the call to ResetCollisionPairs().
virtual const csArray<csIntersectingTriangle>& iCollideSystem::GetIntersectingTriangles (  )  const [pure virtual]

Get the array of intersection points as returned by CollideRay().

Note that the coordinates in the array of triangles is in object space of the collider object and not world space!

virtual bool iCollideSystem::GetOneHitOnly (  )  [pure virtual]

Return true if this CD system will only return the first hit that is found.

For CD systems that support multiple hits this will return the value set by the SetOneHitOnly() function. For CD systems that support one hit only this will always return true.

Returns:
true if there is only one hit recorder for every call to Collide().
virtual csStringID iCollideSystem::GetTriangleDataID (  )  [pure virtual]

Get the ID that the collision detection system prefers for getting triangle data from iObjectModel.

This corresponds with the ID you would get from doing strings->Request ("colldet") where 'strings' is a reference to the standard string set.

virtual void iCollideSystem::ResetCollisionPairs (  )  [pure virtual]

Reset the array with collision pairs.

It is very important to call this before collision detection. Otherwise the internal table of collision pairs will grow forever.

virtual void iCollideSystem::SetOneHitOnly ( bool  o  )  [pure virtual]

Indicate if we are interested only in the first hit that is found.

This is only valid for CD algorithms that actually allow the detection of multiple CD hit points.

Parameters:
o is true if you are only interested in one colliding triangle per call to Collide. By default this is 'false' unless the CD system only supports single hits.

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

Generated for Crystal Space 2.0 by doxygen 1.6.1