00001 //------------------------------------------------------------------------------ 00002 // Lamp : Open source game middleware 00003 // Copyright (C) 2004 Junpei Ohtani ( Email : junpee@users.sourceforge.jp ) 00004 // 00005 // This library is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 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 // Lesser General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with this library; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 //------------------------------------------------------------------------------ 00019 00020 /** @file 00021 * 変形メッシュジオメトリヘッダ 00022 * @author Junpee 00023 */ 00024 00025 #ifndef DEFORMED_MESH_GEOMETRY_H_ 00026 #define DEFORMED_MESH_GEOMETRY_H_ 00027 00028 #include <Geometry/Mesh/MeshGeometry.h> 00029 00030 namespace Lamp{ 00031 00032 //------------------------------------------------------------------------------ 00033 /** 00034 * 変形メッシュジオメトリ 00035 */ 00036 class DeformedMeshGeometry : public MeshGeometry{ 00037 public: 00038 //-------------------------------------------------------------------------- 00039 // 生成、破棄 00040 //-------------------------------------------------------------------------- 00041 /** 00042 * コンストラクタ 00043 */ 00044 DeformedMeshGeometry(); 00045 00046 /** 00047 * コピーコンストラクタ 00048 * @param copy コピー元 00049 */ 00050 explicit DeformedMeshGeometry(const DeformedMeshGeometry& copy); 00051 00052 /** 00053 * 代入コピー 00054 * @param copy コピー元 00055 * @return コピーされた変形メッシュジオメトリ 00056 */ 00057 virtual const DeformedMeshGeometry& operator =( 00058 const DeformedMeshGeometry& copy); 00059 00060 /** 00061 * デストラクタ 00062 */ 00063 virtual ~DeformedMeshGeometry(); 00064 00065 //-------------------------------------------------------------------------- 00066 // 交差 00067 //-------------------------------------------------------------------------- 00068 /** 00069 * 球交差 00070 * @param sphere 交差判定する球 00071 * @return 交差していればtrue 00072 */ 00073 virtual bool intersect(const Sphere& sphere) const; 00074 00075 /** 00076 * 球交差 00077 * @param sphere 交差判定する球 00078 * @param result 交差結果 00079 */ 00080 virtual void intersect( 00081 IntersectionResult* result, const Sphere& sphere) const; 00082 00083 /** 00084 * 球バウンディング交差 00085 * @param sphere 交差判定する球 00086 * @return バウンディングと交差していればtrue 00087 */ 00088 virtual bool intersectBounding(const Sphere& sphere) const; 00089 00090 /** 00091 * 球メッシュ交差 00092 * @param sphere 交差判定する球 00093 * @return メッシュと交差していればtrue 00094 */ 00095 virtual bool intersectMesh(const Sphere& sphere) const; 00096 00097 /** 00098 * 球メッシュ交差 00099 * @param sphere 交差判定する球 00100 * @param result 交差結果 00101 */ 00102 virtual void intersectMesh( 00103 IntersectionResult* result, const Sphere& sphere) const; 00104 00105 //-------------------------------------------------------------------------- 00106 // トライアングル 00107 //-------------------------------------------------------------------------- 00108 /** 00109 * トライアングル数の設定 00110 * @param triangleCount トライアングル数 00111 */ 00112 virtual void setTriangleCount(int triangleCount); 00113 00114 /** 00115 * トライアングル数の取得 00116 * @return トライアングル数 00117 */ 00118 virtual int getTriangleCount() const{ return triangleCount_; } 00119 00120 //-------------------------------------------------------------------------- 00121 /** 00122 * トライアングルの設定 00123 * @param index インデックス 00124 * @param triangle トライアングル 00125 */ 00126 virtual void setTriangle(int index, const Triangle& triangle){ 00127 Assert((index >= 0) && (index < triangleCount_)); 00128 triangles_[index] = triangle; 00129 } 00130 00131 /** 00132 * トライアングルの取得 00133 * @param index インデックス 00134 * @return トライアングル 00135 */ 00136 virtual const Triangle& getTriangle(int index) const{ 00137 Assert((index >= 0) && (index < triangleCount_)); 00138 return triangles_[index]; 00139 } 00140 00141 //-------------------------------------------------------------------------- 00142 // バウンディング 00143 //-------------------------------------------------------------------------- 00144 /** 00145 * バウンディングの算出 00146 */ 00147 virtual void calculateBounding(); 00148 00149 //-------------------------------------------------------------------------- 00150 /** 00151 * バウンディングボックスの設定 00152 * @param boundingBox バウンディングボックス 00153 */ 00154 virtual void setBoundingBox(const AxisAlignedBox& boundingBox){ 00155 boundingBox_ = boundingBox; 00156 } 00157 00158 /** 00159 * バウンディングボックスの取得 00160 * @return バウンディングボックス 00161 */ 00162 virtual const AxisAlignedBox& getBoundingBox() const{ return boundingBox_; } 00163 00164 //-------------------------------------------------------------------------- 00165 /** 00166 * バウンディングスフィアの設定 00167 * @param boundingSphere バウンディングスフィア 00168 */ 00169 virtual void setBoundingSphere(const Sphere& boundingSphere){ 00170 boundingSphere_ = boundingSphere; 00171 } 00172 00173 /** 00174 * バウンディングスフィアの取得 00175 * @return バウンディングスフィア 00176 */ 00177 virtual const Sphere& getBoundingSphere() const{ 00178 return boundingSphere_; 00179 } 00180 00181 protected: 00182 //-------------------------------------------------------------------------- 00183 /** 00184 * 変形メッシュジオメトリデータのコピー 00185 * @param copy コピー元 00186 */ 00187 virtual void copyDeformedMeshGeometryData(const DeformedMeshGeometry& copy); 00188 00189 private: 00190 //-------------------------------------------------------------------------- 00191 // バウンディングボックス 00192 AxisAlignedBox boundingBox_; 00193 // バウンディングスフィア 00194 Sphere boundingSphere_; 00195 // トライアングル配列 00196 Triangle* triangles_; 00197 // トライアングル数 00198 int triangleCount_; 00199 }; 00200 00201 //------------------------------------------------------------------------------ 00202 } // End of namespace Lamp 00203 #endif // End of DEFORMED_MESH_GEOMETRY_H_ 00204 //------------------------------------------------------------------------------