cCollisionSpheres Class Reference
[Collision Detection]

cCollisionSpheres provides methods to create a sphere tree for collision detection, and to use this tree to check for the intersection of a line with a mesh. More...

#include <CCollisionSpheres.h>

Inheritance diagram for cCollisionSpheres:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 cCollisionSpheres (vector< cTriangle > *a_triangles, bool a_useNeighbors)
 Constructor of cCollisionSpheres.
virtual ~cCollisionSpheres ()
 Destructor of cCollisionSpheres.
void initialize (double a_radius=0)
 Build the sphere tree based on the given triangles.
void render ()
 Draw the collision spheres in OpenGL.
bool computeCollision (cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cCollisionRecorder &a_recorder, cCollisionSettings &a_settings)
 Return the nearest triangle intersected by the given segment, if any.

Public Attributes

cCollisionSpheresSpherem_root
 Pointer to the sphere at the root of the sphere tree.
vector< cTriangle > * m_trigs
 Pointer to the list of triangles in the mesh.
cTrianglem_lastCollision
 Triangle returned by last successful collision test.
bool m_useNeighbors
 Use neighbor list to speed up collision detection?
cCollisionSpheresLeafm_firstLeaf
 Pointer to the beginning of list of leaf nodes.
cTrianglesecret
 For internal and debug usage.


Detailed Description

cCollisionSpheres provides methods to create a sphere tree for collision detection, and to use this tree to check for the intersection of a line with a mesh.

Constructor & Destructor Documentation

cCollisionSpheres::cCollisionSpheres ( vector< cTriangle > *  a_triangles,
bool  a_useNeighbors 
)

Constructor of cCollisionSpheres.

Constructor of cCollisionSpheres.

Parameters:
a_triangles Pointer to array of triangles.
a_useNeighbors Use neighbor lists to speed up collision detection?


Member Function Documentation

bool cCollisionSpheres::computeCollision ( cVector3d a_segmentPointA,
cVector3d a_segmentPointB,
cCollisionRecorder a_recorder,
cCollisionSettings a_settings 
) [virtual]

Return the nearest triangle intersected by the given segment, if any.

Check if the given line segment intersects any triangle of the mesh. If so, return true, as well as (through the output parameters) pointers to the intersected triangle, the mesh of which this triangle is a part, the point of intersection, and the distance from the origin of the segment to the collision point. If more than one triangle is intersected, return the one closest to the origin of the segment. The method uses the pre-computed sphere tree, starting at the root and recursing through the tree, breaking the recursion along any path in which the sphere bounding the line segment does not intersect the sphere of the node. At the leafs, triangle-segment intersection testing is called.

Parameters:
a_segmentPointA Initial point of segment.
a_segmentPointB End point of segment.
a_recorder Stores all collision events
a_settings Contains collision settings information.
Returns:
Return true if a collision event has occurred.

Reimplemented from cGenericCollision.

void cCollisionSpheres::initialize ( double  a_radius = 0  )  [virtual]

Build the sphere tree based on the given triangles.

Build the Sphere Tree collision-detection tree. Each leaf is associated with one triangle and with a bounding sphere of minimal radius such that it fully encloses the triangle. Each internal node is associated with a bounding sphere of minimal radius such that it fully encloses the bounding spheres of its two children.

Parameters:
a_radius radius to add around the triangles.

Reimplemented from cGenericCollision.

void cCollisionSpheres::render (  )  [virtual]

Draw the collision spheres in OpenGL.

Draw the collision spheres at the given level.

Reimplemented from cGenericCollision.


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


CHAI3D 2.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2009 - CHAI 3D
All Rights Reserved.