Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

StaticDeformedMeshCollision.h

Go to the documentation of this file.
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 STATIC_DEFORMED_MESH_COLLISION_H_
00026 #define STATIC_DEFORMED_MESH_COLLISION_H_
00027 
00028 #include <Collision/System/StaticCollisionLeaf.h>
00029 #include <Geometry/Mesh/DeformedMeshGeometry.h>
00030 
00031 namespace Lamp{
00032 
00033 //------------------------------------------------------------------------------
00034 /**
00035  * 静的変形メッシュコリジョン
00036  */
00037 class StaticDeformedMeshCollision : public StaticCollisionLeaf{
00038 friend class CollisionScene;
00039 public:
00040     //--------------------------------------------------------------------------
00041     // 交差
00042     //--------------------------------------------------------------------------
00043     /**
00044      * 球交差
00045      * @param result 交差結果
00046      * @param sphere 球
00047      * @param collisionMask コリジョンマスク
00048      */
00049     virtual void intersection(IntersectionResult* result, const Sphere& sphere,
00050         u_int collisionMask = 0xffffffff);
00051 
00052     /**
00053      * 球コリジョン交差
00054      * @param result 交差結果
00055      * @param sphere 球コリジョン
00056      * @param collisionMask コリジョンマスク
00057      */
00058     virtual void intersection(IntersectionResult* result,
00059         StaticSphereCollision* sphere, u_int collisionMask = 0xffffffff);
00060 
00061     //--------------------------------------------------------------------------
00062     // メッシュ
00063     //--------------------------------------------------------------------------
00064     /**
00065      * メッシュの取得
00066      * @return ローカル座標のメッシュ
00067      */
00068     virtual const DeformedMeshGeometry& getMesh() const{ return mesh_; }
00069 
00070     /**
00071      * ワールドメッシュの取得
00072      *
00073      * ワールドメッシュの取得を行った時点でメッシュがワールド座標に変換される
00074      * @return ワールド座標のメッシュ
00075      */
00076     virtual const DeformedMeshGeometry& getWorldMesh();
00077 
00078     //--------------------------------------------------------------------------
00079     // トライアングル
00080     //--------------------------------------------------------------------------
00081     /**
00082      * トライアングル数の設定
00083      * @param triangleCount トライアングル数
00084      */
00085     virtual void setTriangleCount(int triangleCount){
00086         mesh_.setTriangleCount(triangleCount);
00087         worldMesh_.setTriangleCount(triangleCount);
00088         setChanged(true);
00089     }
00090 
00091     /**
00092      * トライアングル数の取得
00093      * @return トライアングル数
00094      */
00095     virtual int getTriangleCount() const{ return mesh_.getTriangleCount(); }
00096 
00097     //--------------------------------------------------------------------------
00098     /**
00099      * トライアングルの設定
00100      * @param index インデックス
00101      * @param triangle トライアングル
00102      */
00103     virtual void setTriangle(int index, const Triangle& triangle){
00104         mesh_.setTriangle(index, triangle);
00105         setChanged(true);
00106     }
00107 
00108     /**
00109      * トライアングルの取得
00110      * @param index インデックス
00111      * @return トライアングル
00112      */
00113     virtual const Triangle& getTriangle(int index) const{
00114         return mesh_.getTriangle(index);
00115     }
00116 
00117     //--------------------------------------------------------------------------
00118     // バウンディング
00119     //--------------------------------------------------------------------------
00120     /**
00121      * バウンディングの算出
00122      */
00123     virtual void calculateBounding(){
00124         mesh_.calculateBounding();
00125         setChanged(true);
00126     }
00127 
00128     //--------------------------------------------------------------------------
00129     /**
00130      * バウンディングボックスの設定
00131      * @param boundingBox バウンディングボックス
00132      */
00133     virtual void setBoundingBox(const AxisAlignedBox& boundingBox){
00134         mesh_.setBoundingBox(boundingBox);
00135         setChanged(true);
00136     }
00137 
00138     /**
00139      * バウンディングボックスの取得
00140      * @return バウンディングボックス
00141      */
00142     virtual const AxisAlignedBox& getBoundingBox() const{
00143         return mesh_.getBoundingBox();
00144     }
00145 
00146     //--------------------------------------------------------------------------
00147     /**
00148      * バウンディングスフィアの設定
00149      * @param boundingSphere バウンディングスフィア
00150      */
00151     virtual void setBoundingSphere(const Sphere& boundingSphere){
00152         mesh_.setBoundingSphere(boundingSphere);
00153         setChanged(true);
00154     }
00155 
00156     /**
00157      * バウンディングスフィアの取得
00158      * @return バウンディングスフィア
00159      */
00160     virtual const Sphere& getBoundingSphere() const{
00161         return mesh_.getBoundingSphere();
00162     }
00163 
00164     //--------------------------------------------------------------------------
00165     // コピー
00166     //--------------------------------------------------------------------------
00167     /**
00168      * コピー
00169      * @return コピーされたコリジョンオブジェクト
00170      */
00171     virtual CollisionObject* copy() const{
00172         return copyStaticDeformedMeshCollision();
00173     }
00174 
00175     /**
00176      * コリジョンリーフのコピー
00177      * @return コピーされたコリジョンリーフ
00178      */
00179     virtual CollisionLeaf* copyCollisionLeaf() const{
00180         return copyStaticDeformedMeshCollision();
00181     }
00182 
00183     /**
00184      * 静的コリジョンリーフのコピー
00185      * @return コピーされた静的コリジョンリーフ
00186      */
00187     virtual StaticCollisionLeaf* copyStaticCollisionLeaf() const{
00188         return copyStaticDeformedMeshCollision();
00189     }
00190 
00191     /**
00192      * 静的変形メッシュコリジョンのコピー
00193      * @return コピーされた静的変形メッシュコリジョン
00194      */
00195     virtual StaticDeformedMeshCollision*
00196         copyStaticDeformedMeshCollision() const;
00197 
00198     //--------------------------------------------------------------------------
00199     // RTTI
00200     //--------------------------------------------------------------------------
00201     /**
00202      * 静的変形メッシュコリジョンかどうか
00203      * @return 静的変形メッシュコリジョンならtrue
00204      */
00205     virtual bool isStaticDeformedMeshCollision() const{ return true; }
00206 
00207 protected:
00208     //--------------------------------------------------------------------------
00209     // 生成、破棄
00210     //--------------------------------------------------------------------------
00211     /**
00212      * コンストラクタ
00213      * @param name 名前
00214      * @param scene シーン
00215      */
00216     StaticDeformedMeshCollision(const String& name, CollisionScene* scene);
00217 
00218     /**
00219      * デストラクタ
00220      */
00221     virtual ~StaticDeformedMeshCollision();
00222 
00223     //--------------------------------------------------------------------------
00224     // 走査
00225     //--------------------------------------------------------------------------
00226     /**
00227      * 走査
00228      * @param parentMatrix 親行列
00229      * @param parentEnabled 親が有効か
00230      * @param parentScaled 親がスケールを使用しているか
00231      * @param parentChanged 親に変更があったか
00232      */
00233     virtual void traverseImplement(const Matrix34& parentMatrix,
00234         bool parentEnabled, bool parentScaled, bool parentChanged);
00235 
00236 private:
00237     //--------------------------------------------------------------------------
00238     // メッシュ
00239     DeformedMeshGeometry mesh_;
00240     // ワールドメッシュ
00241     DeformedMeshGeometry worldMesh_;
00242     // ワールドメッシュ変更フラグ
00243     bool worldMeshChanged_;
00244 
00245 };
00246 
00247 //------------------------------------------------------------------------------
00248 } // End of namespace Lamp
00249 #endif // End of STATIC_DEFORMED_MESH_COLLISION_H_
00250 //------------------------------------------------------------------------------

Generated on Wed Mar 16 10:29:36 2005 for Lamp by doxygen 1.3.2