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 "csgeom/box.h" 00030 #include "csgeom/matrix3.h" 00031 00032 class csVector3; 00033 class csReversibleTransform; 00034 00039 class csOBB : public csBox3 00040 { 00041 private: 00042 csMatrix3 mMat; 00043 00044 public: 00048 csOBB () {} 00049 00053 csOBB (const csOBB &b) : csBox3 (b), mMat (b.mMat) { } 00054 00058 csOBB (const csBox3 &b) : csBox3 (b) { } 00059 00067 csOBB (const csVector3 &dir1, const csVector3 &dir2, 00068 const csVector3 &dir3); 00069 00070 void AddBoundingVertex (const csVector3 &v); 00071 csVector3 GetCorner (int corner) const; 00072 const csMatrix3 &GetMatrix () const { return mMat; } 00073 00077 float Diameter (); 00078 00082 float Volume (); 00083 00089 void FindOBB (const csVector3 *vertex_table, int num, float eps = 0.0); 00090 00096 void FindOBBAccurate (const csVector3 *vertex_table, int num); 00097 }; 00098 00102 class csOBBFrozen 00103 { 00104 private: 00105 csVector3 corners[8]; 00106 00107 public: 00111 void Copy (const csOBB& obb) 00112 { 00113 for (int i = 0 ; i < 8 ; i++) 00114 { 00115 corners[i] = obb.GetCorner (i); 00116 } 00117 } 00118 00122 void Copy (const csOBB& obb, const csReversibleTransform& trans); 00123 00127 csOBBFrozen () 00128 { 00129 } 00130 00134 csOBBFrozen (const csOBB& obb) 00135 { 00136 Copy (obb); 00137 } 00138 00145 csOBBFrozen (const csOBB& obb, const csReversibleTransform& trans) 00146 { 00147 Copy (obb, trans); 00148 } 00149 00153 const csVector3& GetCorner (int corner) const 00154 { 00155 CS_ASSERT (corner >= 0 && corner < 8); 00156 return corners[corner]; 00157 } 00158 00163 bool ProjectOBB (float fov, float sx, float sy, csBox2& sbox, 00164 float& min_z, float& max_z); 00165 }; 00166 00169 #endif // __CS_OBB_H__ 00170
Generated for Crystal Space by doxygen 1.2.18