csgeom/obb.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2002 by Jorrit Tyberghein 00003 Copyright (C) 2002 by Daniel Duhprey 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_OBB_H__ 00021 #define __CS_OBB_H__ 00022 00029 #include "csextern.h" 00030 00031 #include "csgeom/box.h" 00032 #include "csgeom/matrix3.h" 00033 00034 class csVector3; 00035 class csReversibleTransform; 00036 00041 class CS_CSGEOM_EXPORT csOBB : public csBox3 00042 { 00043 private: 00044 csMatrix3 mMat; 00045 00046 public: 00050 csOBB () {} 00051 00055 csOBB (const csOBB &b) : csBox3 (b), mMat (b.mMat) { } 00056 00060 csOBB (const csBox3 &b) : csBox3 (b) { } 00061 00069 csOBB (const csVector3 &dir1, const csVector3 &dir2, 00070 const csVector3 &dir3); 00071 00072 void AddBoundingVertex (const csVector3 &v); 00073 csVector3 GetCorner (int corner) const; 00074 const csMatrix3 &GetMatrix () const { return mMat; } 00075 00079 float Diameter (); 00080 00084 float Volume (); 00085 00091 void FindOBB (const csVector3 *vertex_table, int num, float eps = 0.0); 00092 00098 void FindOBBAccurate (const csVector3 *vertex_table, int num); 00099 }; 00100 00104 class CS_CSGEOM_EXPORT csOBBFrozen 00105 { 00106 private: 00107 csVector3 corners[8]; 00108 00109 public: 00113 void Copy (const csOBB& obb) 00114 { 00115 for (int i = 0 ; i < 8 ; i++) 00116 { 00117 corners[i] = obb.GetCorner (i); 00118 } 00119 } 00120 00124 void Copy (const csOBB& obb, const csReversibleTransform& trans); 00125 00129 csOBBFrozen () 00130 { 00131 } 00132 00136 csOBBFrozen (const csOBB& obb) 00137 { 00138 Copy (obb); 00139 } 00140 00147 csOBBFrozen (const csOBB& obb, const csReversibleTransform& trans) 00148 { 00149 Copy (obb, trans); 00150 } 00151 00155 const csVector3& GetCorner (int corner) const 00156 { 00157 CS_ASSERT (corner >= 0 && corner < 8); 00158 return corners[corner]; 00159 } 00160 00165 bool ProjectOBB (float fov, float sx, float sy, csBox2& sbox, 00166 float& min_z, float& max_z); 00167 }; 00168 00171 #endif // __CS_OBB_H__ 00172
Generated for Crystal Space by doxygen 1.2.18