My Project
Loading...
Searching...
No Matches
CCollisionBasics.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, 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.3.0
43*/
44//==============================================================================
45
46//------------------------------------------------------------------------------
47#ifndef CCollisionBasicsH
48#define CCollisionBasicsH
49//------------------------------------------------------------------------------
50#include "math/CVector3d.h"
51#include "math/CMatrix3d.h"
55#include "materials/CMaterial.h"
56//------------------------------------------------------------------------------
57#include <vector>
58//------------------------------------------------------------------------------
59namespace chai3d {
60//------------------------------------------------------------------------------
61
62//==============================================================================
69//==============================================================================
70
80
81
82//==============================================================================
90//==============================================================================
169
170
171//==============================================================================
184//==============================================================================
186{
187 //--------------------------------------------------------------------------
188 // CONSTRUCTOR & DESTRUCTOR:
189 //--------------------------------------------------------------------------
190
191public:
192
195
198
199
200 //--------------------------------------------------------------------------
201 // PUBLIC METHODS:
202 //--------------------------------------------------------------------------
203
204public:
205
207 void clear()
208 {
210 m_collisions.clear();
211 }
212
213
214 //--------------------------------------------------------------------------
215 // MEMBERS:
216 //--------------------------------------------------------------------------
217
218public:
219
222
224 std::vector<cCollisionEvent> m_collisions;
225};
226
227
228//==============================================================================
241//==============================================================================
277
278//------------------------------------------------------------------------------
279} // namespace chai3d
280//------------------------------------------------------------------------------
281
282//------------------------------------------------------------------------------
283#endif
284//------------------------------------------------------------------------------
Implements material properties.
Implements a 3D matrix.
Implements arrays of 3D points.
Implement arrays of 3D segments.
Implements arrays of 3D triangles.
Implements a 3D vector.
This class implements a collision detection recorder that stores all collision events that are report...
Definition CCollisionBasics.h:186
std::vector< cCollisionEvent > m_collisions
List of all detected collision events.
Definition CCollisionBasics.h:224
virtual ~cCollisionRecorder()
Destructor of cCollisionRecorder.
Definition CCollisionBasics.h:197
cCollisionEvent m_nearestCollision
Nearest collision event from the start point of the collision segment.
Definition CCollisionBasics.h:221
cCollisionRecorder()
Constructor of cCollisionRecorder.
Definition CCollisionBasics.h:194
void clear()
This method clears all collision records.
Definition CCollisionBasics.h:207
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition CGenericObject.h:113
Definition CAudioBuffer.cpp:57
std::shared_ptr< cPointArray > cPointArrayPtr
Definition CPointArray.h:72
std::shared_ptr< cSegmentArray > cSegmentArrayPtr
Definition CSegmentArray.h:66
const double C_LARGE
Biggest value for a double.
Definition CConstants.h:109
cCollisionType
Definition CCollisionBasics.h:72
@ C_COL_SEGMENT
Definition CCollisionBasics.h:76
@ C_COL_NOT_DEFINED
Definition CCollisionBasics.h:73
@ C_COL_VOXEL
Definition CCollisionBasics.h:78
@ C_COL_TRIANGLE
Definition CCollisionBasics.h:77
@ C_COL_POINT
Definition CCollisionBasics.h:75
@ C_COL_SHAPE
Definition CCollisionBasics.h:74
std::shared_ptr< cTriangleArray > cTriangleArrayPtr
Definition CTriangleArray.h:66
This structure stores the data related to a collision event.
Definition CCollisionBasics.h:92
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
cVector3d m_localPos
Position of the collision point in reference to the objects coordinate frame (local coordinates).
Definition CCollisionBasics.h:121
cVector3d m_globalPos
Position of the collision point in world coordinates (global coordinates).
Definition CCollisionBasics.h:124
double m_squareDistance
Square distance between ray origin and collision point.
Definition CCollisionBasics.h:133
void clear()
Initialize all data.
Definition CCollisionBasics.h:148
cCollisionType m_type
Collision type (triangle, voxel, line, point)
Definition CCollisionBasics.h:94
double m_posV01
Projection of collision point onto line going from Vertex0 to Vertex1 of triangle/segment/point (if a...
Definition CCollisionBasics.h:136
cPointArrayPtr m_points
Pointer to point array (if available).
Definition CCollisionBasics.h:100
cGenericObject * m_object
Pointer to the collided object.
Definition CCollisionBasics.h:97
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
cVector3d m_adjustedSegmentAPoint
Definition CCollisionBasics.h:145
cVector3d m_localNormal
Surface normal at collision point in reference to the objects coordinate frame (local coordinates).
Definition CCollisionBasics.h:127
int m_voxelIndexY
Index Y of voxel in texture image (if available).
Definition CCollisionBasics.h:115
int m_voxelIndexX
Index X of voxel in texture image (if available).
Definition CCollisionBasics.h:112
cVector3d m_globalNormal
Surface normal at collision point in world coordinates (global coordinates).
Definition CCollisionBasics.h:130
cSegmentArrayPtr m_segments
Pointer to segment array (if available).
Definition CCollisionBasics.h:103
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition CCollisionBasics.h:243
bool m_returnMinimalCollisionData
If true, return minimal amount of data about the collision.
Definition CCollisionBasics.h:260
bool m_checkForNearestCollisionOnly
If true, only return the nearest collision event.
Definition CCollisionBasics.h:257
cCollisionSettings()
Constructor of cCollisionSettings.
Definition CCollisionBasics.h:245
bool m_checkHapticObjects
If true, then collision detector shall check for collisions on haptic enabled objects (m_hapticEnable...
Definition CCollisionBasics.h:266
double m_collisionRadius
Collision radius. This value typically corresponds to the radius of the virtual tool or cursor.
Definition CCollisionBasics.h:275
bool m_adjustObjectMotion
If true, then adjust for object motion. (See dynamic proxy model).
Definition CCollisionBasics.h:269
bool m_checkVisibleObjects
If true, then collision detector shall check for collisions on visible objects (m_showEnabled == true...
Definition CCollisionBasics.h:263
bool m_ignoreShapes
If true, collision with shape objects are ignored (e.g. cShapeSphere, cShapeCylinder,...
Definition CCollisionBasics.h:272
This class implements a 3D vector.
Definition CVector3d.h:89
void zero()
This method clears all vector components with zeros.
Definition CVector3d.h:236