00001 //=========================================================================== 00002 /* 00003 This file is part of the CHAI 3D visualization and haptics libraries. 00004 Copyright (C) 2003-2009 by CHAI 3D. All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License("GPL") version 2 00008 as published by the Free Software Foundation. 00009 00010 For using the CHAI 3D libraries with software that can not be combined 00011 with the GNU GPL, and for taking advantage of the additional benefits 00012 of our support services, please contact CHAI 3D about acquiring a 00013 Professional Edition License. 00014 00015 \author <http://www.chai3d.org> 00016 \author Francois Conti 00017 \version 2.0.0 $Rev: 250 $ 00018 */ 00019 //=========================================================================== 00020 00021 //--------------------------------------------------------------------------- 00022 #ifndef CCollisionBasicsH 00023 #define CCollisionBasicsH 00024 //--------------------------------------------------------------------------- 00025 #include "math/CVector3d.h" 00026 #include "math/CMatrix3d.h" 00027 #include "graphics/CVertex.h" 00028 #include "graphics/CMaterial.h" 00029 #include <vector> 00030 //--------------------------------------------------------------------------- 00031 using std::vector; 00032 class cGenericObject; 00033 class cTriangle; 00034 //--------------------------------------------------------------------------- 00035 00036 //=========================================================================== 00044 //=========================================================================== 00045 00046 //=========================================================================== 00055 //=========================================================================== 00056 struct cCollisionEvent 00057 { 00059 cGenericObject* m_object; 00060 00062 cTriangle* m_triangle; 00063 00065 cVector3d m_localPos; 00066 00068 cVector3d m_globalPos; 00069 00071 cVector3d m_localNormal; 00072 00074 cVector3d m_globalNormal; 00075 00077 double m_squareDistance; 00078 00081 cVector3d m_adjustedSegmentAPoint; 00082 00084 void clear() 00085 { 00086 m_object = NULL; 00087 m_triangle = NULL; 00088 m_localPos.zero(); 00089 m_globalPos.zero(); 00090 m_localNormal.zero(); 00091 m_globalNormal.zero(); 00092 m_squareDistance = CHAI_DBL_MAX; 00093 } 00094 }; 00095 00096 00097 //=========================================================================== 00105 //=========================================================================== 00106 class cCollisionRecorder 00107 { 00108 public: 00109 00110 //----------------------------------------------------------------------- 00111 // CONSTRUCTOR & DESTRUCTOR: 00112 //----------------------------------------------------------------------- 00113 00115 cCollisionRecorder() { clear(); } 00116 00118 virtual ~cCollisionRecorder() {}; 00119 00120 00121 //----------------------------------------------------------------------- 00122 // METHODS: 00123 //----------------------------------------------------------------------- 00124 00126 void clear() 00127 { 00128 m_nearestCollision.clear(); 00129 m_collisions.clear(); 00130 } 00131 00132 00133 //----------------------------------------------------------------------- 00134 // MEMBERS: 00135 //----------------------------------------------------------------------- 00136 00138 cCollisionEvent m_nearestCollision; 00139 00141 vector<cCollisionEvent> m_collisions; 00142 }; 00143 00144 00145 //=========================================================================== 00154 //=========================================================================== 00155 struct cCollisionSettings 00156 { 00158 bool m_checkForNearestCollisionOnly; 00159 00161 bool m_returnMinimalCollisionData; 00162 00164 bool m_checkVisibleObjectsOnly; 00165 00167 bool m_checkHapticObjectsOnly; 00168 00170 bool m_checkBothSidesOfTriangles; 00171 00173 bool m_adjustObjectMotion; 00174 00176 double m_collisionRadius; 00177 }; 00178 00179 //--------------------------------------------------------------------------- 00180 #endif 00181 //--------------------------------------------------------------------------- 00182