This class implements an axis-aligned bounding box collision detector. More...
#include <CCollisionAABB.h>
Public Member Functions | |
cCollisionAABB () | |
Constructor of cCollisionAABB. More... | |
virtual | ~cCollisionAABB () |
Destructor of cCollisionAABB. More... | |
virtual void | update () |
This methods updates the collision detector and should be called if the 3D model it represents is modified. More... | |
virtual bool | computeCollision (cGenericObject *a_object, cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cCollisionRecorder &a_recorder, cCollisionSettings &a_settings) |
This method computes all collisions between a segment passed as argument and the attributed 3D object. More... | |
virtual void | render (cRenderOptions &a_options) |
This method renders a visual representation of the collision tree. More... | |
void | initialize (const cGenericArrayPtr a_elements, const double a_radius=0.0) |
This method initializes and builds the AABB collision tree. More... | |
Public Member Functions inherited from chai3d::cGenericCollision | |
cGenericCollision () | |
Constructor of cGenericCollision. More... | |
virtual | ~cGenericCollision () |
Destructor of cGenericCollision. More... | |
double | getBoundaryRadius () const |
This method returns the radius of the boundary shell that covers every triangles. More... | |
void | setDisplayDepth (const int a_depth) |
This method sets the level of the collision tree to display. More... | |
double | getDisplayDepth () const |
This method returns the level inside the collision tree being displayed. (root = 0). More... | |
Protected Member Functions | |
int | buildTree (const int a_indexFirstNode, const int a_indexLastNode, const int a_depth) |
Protected Attributes | |
double | m_radius |
Collision shell radius around elements. More... | |
int | m_numElements |
Number of elements inside tree. More... | |
cGenericArrayPtr | m_elements |
Pointer to the list of elements in the object. More... | |
std::vector< cCollisionAABBNode > | m_nodes |
List of nodes. More... | |
int | m_rootIndex |
Index number of root node. More... | |
int | m_maxDepth |
Maximum depth of tree. More... | |
Protected Attributes inherited from chai3d::cGenericCollision | |
int | m_displayDepth |
double | m_radiusAroundElements |
Additional Inherited Members | |
Public Attributes inherited from chai3d::cGenericCollision | |
cColorf | m_color |
Color property used to render the collision detector graphically. More... | |
This class implements an axis-aligned bounding box collision detection tree to efficiently detect for any collision between a line segment and a collection of elements (point, segment, triangle) that compose an object.
chai3d::cCollisionAABB::cCollisionAABB | ( | ) |
Constructor of cCollisionAABB.
|
virtual |
Destructor of cCollisionAABB.
|
virtual |
This methods updates the collision detector and should be called if the 3D model it represents is modified.
Reimplemented from chai3d::cGenericCollision.
|
virtual |
This method checks if the given line segment intersects any element of the mesh.
If a collision occurs, the method returns true, and the collision events are reported through the collision recorder. Each collision event reports pointers to the intersected element, the mesh of which this element is a part, the point of intersection, and the distance from the origin of the segment to the collision point.
a_object | Object for which collision detector is being used. |
a_segmentPointA | Initial point of segment. |
a_segmentPointB | End point of segment. |
a_recorder | Recorder which stores all collision events. |
a_settings | Contains collision settings information. |
Reimplemented from chai3d::cGenericCollision.
|
virtual |
This method graphically renders the boundary boxes of the collision tree using OpenGL.
Reimplemented from chai3d::cGenericCollision.
void chai3d::cCollisionAABB::initialize | ( | const cGenericArrayPtr | a_elements, |
const double | a_radius = 0.0 |
||
) |
This method builds an axis-aligned bounding box collision-detection tree for a collection of elements passed as argument.
Each leaf is associated with one element and with a boundary box of minimal dimensions such that it fully encloses the element and is aligned with the coordinate axes (no rotations). Each internal node is associated with a boundary box of minimal dimensions such that it fully encloses the boundary boxes of its two children and is aligned with the axes.
a_elements | Pointer to element array. |
a_radius | Bounding radius to add around each elements. |
|
protected |
Given a start and end index value of leaf nodes, this method creates a collision tree.
a_indexFirstNode | Lower index value of leaf node. |
a_indexLastNode | Upper index value of leaf node |
a_depth | Current depth of the tree. Root starts at 0. |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |