CCollisionBasics.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 CCollisionBasicsH
48 #define CCollisionBasicsH
49 //------------------------------------------------------------------------------
50 #include "math/CVector3d.h"
51 #include "math/CMatrix3d.h"
52 #include "graphics/CPointArray.h"
53 #include "graphics/CSegmentArray.h"
55 #include "materials/CMaterial.h"
56 //------------------------------------------------------------------------------
57 #include <vector>
58 //------------------------------------------------------------------------------
59 namespace chai3d {
60 //------------------------------------------------------------------------------
61 
62 //==============================================================================
69 //==============================================================================
70 
72 {
79 };
80 
81 
82 //==============================================================================
90 //==============================================================================
92 {
95 
98 
101 
104 
107 
109  int m_index;
110 
113 
116 
119 
122 
125 
128 
131 
134 
136  double m_posV01;
137 
139  double m_posV02;
140 
146 
148  void clear()
149  {
150  m_type = C_COL_NOT_DEFINED;
151  m_object = NULL;
152  m_points = nullptr;
153  m_segments = nullptr;
154  m_triangles = nullptr;
155  m_index = -1;
156  m_voxelIndexX = -1;
157  m_voxelIndexY = -1;
158  m_voxelIndexZ = -1;
159  m_localPos.zero();
160  m_globalPos.zero();
161  m_localNormal.zero();
162  m_globalNormal.zero();
163  m_squareDistance = C_LARGE;
164  m_squareDistance = C_LARGE;
165  m_posV01 = 0.0;
166  m_posV02 = 0.0;
167  }
168 };
169 
170 
171 //==============================================================================
184 //==============================================================================
186 {
187  //--------------------------------------------------------------------------
188  // CONSTRUCTOR & DESTRUCTOR:
189  //--------------------------------------------------------------------------
190 
191 public:
192 
195 
197  virtual ~cCollisionRecorder() {};
198 
199 
200  //--------------------------------------------------------------------------
201  // PUBLIC METHODS:
202  //--------------------------------------------------------------------------
203 
204 public:
205 
207  void clear()
208  {
209  m_nearestCollision.clear();
210  m_collisions.clear();
211  }
212 
213 
214  //--------------------------------------------------------------------------
215  // MEMBERS:
216  //--------------------------------------------------------------------------
217 
218 public:
219 
222 
224  std::vector<cCollisionEvent> m_collisions;
225 };
226 
227 
228 //==============================================================================
241 //==============================================================================
243 {
246  {
247  m_checkForNearestCollisionOnly = true;
248  m_returnMinimalCollisionData = false;
249  m_checkVisibleObjects = true;
250  m_checkHapticObjects = true;
251  m_adjustObjectMotion = false;
252  m_ignoreShapes = false;
253  m_collisionRadius = 0.0;
254  }
255 
258 
261 
264 
267 
270 
273 
276 };
277 
278 //------------------------------------------------------------------------------
279 } // namespace chai3d
280 //------------------------------------------------------------------------------
281 
282 //------------------------------------------------------------------------------
283 #endif
284 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:88
bool m_checkHapticObjects
If true, then collision detector shall check for collisions on haptic enabled objects (m_hapticEnable...
Definition: CCollisionBasics.h:266
Implements arrays of 3D triangles.
cCollisionEvent m_nearestCollision
Nearest collision event from the start point of the collision segment.
Definition: CCollisionBasics.h:221
bool m_ignoreShapes
If true, collision with shape objects are ignored (e.g. cShapeSphere, cShapeCylinder, cShapeBox, etc...)
Definition: CCollisionBasics.h:272
std::shared_ptr< cPointArray > cPointArrayPtr
Definition: CPointArray.h:71
cPointArrayPtr m_points
Pointer to point array (if available).
Definition: CCollisionBasics.h:100
Implement arrays of 3D segments.
void clear()
Initialize all data.
Definition: CCollisionBasics.h:148
Definition: CCollisionBasics.h:75
void zero()
This method clears all vector components with zeros.
Definition: CVector3d.h:256
Definition: CCollisionBasics.h:74
std::shared_ptr< cSegmentArray > cSegmentArrayPtr
Definition: CSegmentArray.h:65
bool m_adjustObjectMotion
If true, then adjust for object motion. (See dynamic proxy model).
Definition: CCollisionBasics.h:269
Definition: CCollisionBasics.h:78
virtual ~cCollisionRecorder()
Destructor of cCollisionRecorder.
Definition: CCollisionBasics.h:197
This structure stores the data related to a collision event.
Definition: CCollisionBasics.h:91
cCollisionRecorder()
Constructor of cCollisionRecorder.
Definition: CCollisionBasics.h:194
cCollisionType
Definition: CCollisionBasics.h:71
double m_squareDistance
Square distance between ray origin and collision point.
Definition: CCollisionBasics.h:133
bool m_checkVisibleObjects
If true, then collision detector shall check for collisions on visible objects (m_showEnabled == true...
Definition: CCollisionBasics.h:263
double m_posV01
Projection of collision point onto line going from Vertex0 to Vertex1 of triangle/segment/point (if a...
Definition: CCollisionBasics.h:136
void clear()
This method clears all collision records.
Definition: CCollisionBasics.h:207
int m_index
Index to collided point, segment, or triangle. This pointer may be NULL for collisions with non trian...
Definition: CCollisionBasics.h:109
double m_posV02
Projection of collision point onto line going from Vertex0 to Vertex2 of triangle/segment/point (if a...
Definition: CCollisionBasics.h:139
cGenericObject * m_object
Pointer to the collided object.
Definition: CCollisionBasics.h:97
cVector3d m_localNormal
Surface normal at collision point in reference to the objects coordinate frame (local coordinates)...
Definition: CCollisionBasics.h:127
cVector3d m_adjustedSegmentAPoint
Definition: CCollisionBasics.h:145
cVector3d m_localPos
Position of the collision point in reference to the objects coordinate frame (local coordinates)...
Definition: CCollisionBasics.h:121
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition: CGenericObject.h:112
cTriangleArrayPtr m_triangles
Pointer to triangle array (if available).
Definition: CCollisionBasics.h:106
int m_voxelIndexZ
Index Z of voxel in texture image (if available).
Definition: CCollisionBasics.h:118
This class implements a collision detection recorder that stores all collision events that are report...
Definition: CCollisionBasics.h:185
bool m_returnMinimalCollisionData
If true, return minimal amount of data about the collision.
Definition: CCollisionBasics.h:260
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition: CCollisionBasics.h:242
bool m_checkForNearestCollisionOnly
If true, only return the nearest collision event.
Definition: CCollisionBasics.h:257
cVector3d m_globalPos
Position of the collision point in world coordinates (global coordinates).
Definition: CCollisionBasics.h:124
Definition: CCollisionBasics.h:77
Implements a 3D matrix.
cCollisionSettings()
Constructor of cCollisionSettings.
Definition: CCollisionBasics.h:245
Definition: CCollisionBasics.h:73
cVector3d m_globalNormal
Surface normal at collision point in world coordinates (global coordinates).
Definition: CCollisionBasics.h:130
Implements a 3D vector.
Implements arrays of 3D points.
int m_voxelIndexY
Index Y of voxel in texture image (if available).
Definition: CCollisionBasics.h:115
const double C_LARGE
Biggest value for a double.
Definition: CConstants.h:109
cCollisionType m_type
Collision type (triangle, voxel, line, point)
Definition: CCollisionBasics.h:94
Implements material properties.
Definition: CAudioBuffer.cpp:56
Definition: CCollisionBasics.h:76
double m_collisionRadius
Collision radius. This value typically corresponds to the radius of the virtual tool or cursor...
Definition: CCollisionBasics.h:275
std::shared_ptr< cTriangleArray > cTriangleArrayPtr
Definition: CTriangleArray.h:65
std::vector< cCollisionEvent > m_collisions
List of all detected collision events.
Definition: CCollisionBasics.h:224
cSegmentArrayPtr m_segments
Pointer to segment array (if available).
Definition: CCollisionBasics.h:103
int m_voxelIndexX
Index X of voxel in texture image (if available).
Definition: CCollisionBasics.h:112