CCollisionAABBTree.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2016, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Chris Sewell
40  \author Charity Lu
41  \author Francois Conti
42  \version 3.2.0 $Rev: 1869 $
43 */
44 //==============================================================================
45 
46 //------------------------------------------------------------------------------
47 #ifndef CCollisionAABBTreeH
48 #define CCollisionAABBTreeH
49 //------------------------------------------------------------------------------
53 //------------------------------------------------------------------------------
54 namespace chai3d {
55 //------------------------------------------------------------------------------
56 
57 //==============================================================================
64 //==============================================================================
65 
66 //------------------------------------------------------------------------------
68 typedef enum
69 {
74 
75 //------------------------------------------------------------------------------
76 
77 //==============================================================================
85 //==============================================================================
87 {
88  //--------------------------------------------------------------------------
89  // CONSTRUCTOR & DESTRUCTOR:
90  //--------------------------------------------------------------------------
91 
92 public:
93 
96 
98  virtual ~cCollisionAABBNode() {}
99 
100 
101  //--------------------------------------------------------------------------
102  // PUBLIC METHODS:
103  //--------------------------------------------------------------------------
104 
105 public:
106 
108  void fitBBox(double a_radius,
109  cVector3d& a_vertex0);
110 
112  void fitBBox(double a_radius,
113  cVector3d& a_vertex0,
114  cVector3d& a_vertex1);
115 
117  void fitBBox(double a_radius,
118  cVector3d& a_vertex0,
119  cVector3d& a_vertex1,
120  cVector3d& a_vertex2);
121 
123  void render(int a_depth = -1);
124 
126  bool computeCollision(cGenericObject* a_owner,
127  cVector3d& a_segmentPointA,
128  cVector3d& a_segmentDirection,
129  cCollisionAABBBox& a_lineBox,
130  cCollisionRecorder& a_recorder,
131  cCollisionSettings& a_settings);
132 
133 
134  //--------------------------------------------------------------------------
135  // PUBLIC MEMBERS:
136  //--------------------------------------------------------------------------
137 
138 public:
139 
142 
144  int m_depth;
145 
147  cAABBNodeType m_nodeType;
148 
151 
154 };
155 
156 
157 //------------------------------------------------------------------------------
158 } // namespace chai3d
159 //------------------------------------------------------------------------------
160 
161 //------------------------------------------------------------------------------
162 #endif
163 //------------------------------------------------------------------------------
164 
This class implements a 3D vector.
Definition: CVector3d.h:88
cAABBNodeType
Internal AABB Node Types.
Definition: CCollisionAABBTree.h:68
int m_rightSubTree
Right child node index.
Definition: CCollisionAABBTree.h:153
Definition: CCollisionAABBTree.h:71
void render(int a_depth=-1)
This method draws the edges of the boundary box for this node, if at the given depth.
Definition: CCollisionAABBTree.cpp:182
cCollisionAABBBox m_bbox
Bounding box for this node.
Definition: CCollisionAABBTree.h:141
This structure implements a tree node inside an AABB collision tree.
Definition: CCollisionAABBTree.h:86
int m_depth
Depth of this node in the collision tree.
Definition: CCollisionAABBTree.h:144
Definition: CCollisionAABBTree.h:72
Definition: CCollisionAABBTree.h:70
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition: CGenericObject.h:112
This class implements a collision detection recorder that stores all collision events that are report...
Definition: CCollisionBasics.h:185
cCollisionAABBNode()
Constructor of cCollisionAABBNode.
Definition: CCollisionAABBTree.cpp:60
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition: CCollisionBasics.h:242
virtual ~cCollisionAABBNode()
Destructor of cCollisionAABBNode.
Definition: CCollisionAABBTree.h:98
Implements an axis-aligned bounding box collision tree (AABB)
void fitBBox(double a_radius, cVector3d &a_vertex0)
This method creates a boundary box for a point.
Definition: CCollisionAABBTree.cpp:79
Implements basic data structures for storing collision events.
Implements an axis-aligned bounding box collision tree (AABB)
This structure implements the boundary nodes of an axis-aligned bounding box.
Definition: CCollisionAABBBox.h:84
cAABBNodeType m_nodeType
Node type.
Definition: CCollisionAABBTree.h:147
Definition: CAudioBuffer.cpp:56
int m_leftSubTree
Left child node index.
Definition: CCollisionAABBTree.h:150
bool computeCollision(cGenericObject *a_owner, cVector3d &a_segmentPointA, cVector3d &a_segmentDirection, cCollisionAABBBox &a_lineBox, cCollisionRecorder &a_recorder, cCollisionSettings &a_settings)
This method determines whether a line segment intersects any elements covered by this node...