cCollisionAABB Class Reference

cCollisionAABB provides methods to create an Axis-Aligned Bounding Box collision detection tree, and to use this tree to check for the intersection of a line segment with a mesh. More...

#include <CCollisionAABB.h>

Inheritance diagram for cCollisionAABB:

cGenericCollision List of all members.

Public Member Functions

 cCollisionAABB (vector< cTriangle > *a_triangles, bool a_useNeighbors)
 Constructor of cAABBTree.
virtual ~cCollisionAABB ()
 Destructor of cAABBTree.
void initialize ()
 Build the AABB Tree for the first time.
void render ()
 Draw the bounding boxes in OpenGL.
bool computeCollision (cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cGenericObject *&a_colObject, cTriangle *&a_colTriangle, cVector3d &a_colPoint, double &a_colSquareDistance, int a_proxyCall=-1)
 Return the nearest triangle intersected by the given segment, if any.
cCollisionAABBNodegetRoot ()
 Return the root node of the collision tree.

Protected Attributes

vector< cTriangle > * m_triangles
 Pointer to the list of triangles in the mesh.
cCollisionAABBLeafm_leaves
 Pointer to an array of leaf nodes for the AABB Tree.
cCollisionAABBNodem_root
 Pointer to the root of the AABB Tree.
unsigned int m_numTriangles
 The number of triangles in the mesh.
cTrianglem_lastCollision
bool m_useNeighbors
 Use list of triangles' neighbors to speed up collision detection?

Detailed Description

cCollisionAABB provides methods to create an Axis-Aligned Bounding Box collision detection tree, and to use this tree to check for the intersection of a line segment with a mesh.


Constructor & Destructor Documentation

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

Constructor of cAABBTree.

Constructor of cCollisionAABB.

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

cCollisionAABB::~cCollisionAABB (  )  [virtual]

Destructor of cAABBTree.

Destructor of cCollisionAABB.


Member Function Documentation

void cCollisionAABB::initialize (  )  [virtual]

Build the AABB Tree for the first time.

Build the Axis-Aligned Bounding Box collision-detection tree. Each leaf is associated with one triangle and with a bounding box of minimal dimensions such that it fully encloses the triangle and is aligned with the coordinate axes (no rotations). Each internal node is associated with a bounding box of minimal dimensions such that it fully encloses the bounding boxes of its two children and is aligned with the axes.

Reimplemented from cGenericCollision.

void cCollisionAABB::render (  )  [virtual]

Draw the bounding boxes in OpenGL.

Render the bounding boxes of the collision tree in OpenGL.

Reimplemented from cGenericCollision.

bool cCollisionAABB::computeCollision ( cVector3d a_segmentPointA,
cVector3d a_segmentPointB,
cGenericObject *&  a_colObject,
cTriangle *&  a_colTriangle,
cVector3d a_colPoint,
double &  a_colSquareDistance,
int  a_proxyCall = -1 
) [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 AABB boxes, starting at the root and recursing through the tree, breaking the recursion along any path in which the bounding box of the line segment does not intersect the bounding box 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_colObject Returns pointer to nearest collided object.
a_colTriangle Returns pointer to nearest collided triangle.
a_colPoint Returns position of nearest collision.
a_colSquareDistance Returns distance between ray origin and collision point.
a_proxyCall If this is > 0, this is a call from a proxy, and the value of a_proxyCall specifies which call this is. When checking for the second and third constraint planes, only the neighbors of the triangle intersected in the first call need be checked, not the whole tree. Call with a_proxyCall = -1 for non-proxy calls.
Returns:
Return true if the line segment intersects a triangle.

Reimplemented from cGenericCollision.


Member Data Documentation

cTriangle* cCollisionAABB::m_lastCollision [protected]

Triangle returned by last successful collision test.

This is only modified by _proxy_ collision tests.


The documentation for this class was generated from the following files:
Generated on Mon Jun 11 09:41:46 2007 for CHAI 3D by  doxygen 1.5.2