chai3d::cCollisionAABB Class Reference

This class implements an axis-aligned bounding box collision detector. More...

#include <CCollisionAABB.h>

Inheritance diagram for chai3d::cCollisionAABB:

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< cCollisionAABBNodem_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...
 

Detailed Description

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.

Constructor & Destructor Documentation

chai3d::cCollisionAABB::cCollisionAABB ( )

Constructor of cCollisionAABB.

chai3d::cCollisionAABB::~cCollisionAABB ( )
virtual

Destructor of cCollisionAABB.

Member Function Documentation

void chai3d::cCollisionAABB::update ( )
virtual

This methods updates the collision detector and should be called if the 3D model it represents is modified.

Reimplemented from chai3d::cGenericCollision.

bool chai3d::cCollisionAABB::computeCollision ( cGenericObject a_object,
cVector3d a_segmentPointA,
cVector3d a_segmentPointB,
cCollisionRecorder a_recorder,
cCollisionSettings a_settings 
)
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.

Parameters
a_objectObject for which collision detector is being used.
a_segmentPointAInitial point of segment.
a_segmentPointBEnd point of segment.
a_recorderRecorder which stores all collision events.
a_settingsContains collision settings information.
Returns
true if a collision event has occurred, __false__otherwise.

Reimplemented from chai3d::cGenericCollision.

void chai3d::cCollisionAABB::render ( cRenderOptions a_options)
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.

Parameters
a_elementsPointer to element array.
a_radiusBounding radius to add around each elements.
int chai3d::cCollisionAABB::buildTree ( const int  a_indexFirstNode,
const int  a_indexLastNode,
const int  a_depth 
)
protected

Given a start and end index value of leaf nodes, this method creates a collision tree.

Parameters
a_indexFirstNodeLower index value of leaf node.
a_indexLastNodeUpper index value of leaf node
a_depthCurrent depth of the tree. Root starts at 0.

Member Data Documentation

double chai3d::cCollisionAABB::m_radius
protected
int chai3d::cCollisionAABB::m_numElements
protected
cGenericArrayPtr chai3d::cCollisionAABB::m_elements
protected
std::vector<cCollisionAABBNode> chai3d::cCollisionAABB::m_nodes
protected
int chai3d::cCollisionAABB::m_rootIndex
protected
int chai3d::cCollisionAABB::m_maxDepth
protected

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