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

StaticSphereCollision.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_SPHERE_COLLISION_H_
00026 #define STATIC_SPHERE_COLLISION_H_
00027 
00028 #include <Collision/System/StaticCollisionLeaf.h>
00029 
00030 namespace Lamp{
00031 
00032 //------------------------------------------------------------------------------
00033 /**
00034  * 静的球コリジョン
00035  */
00036 class StaticSphereCollision : public StaticCollisionLeaf{
00037 friend class CollisionScene;
00038 public:
00039     //--------------------------------------------------------------------------
00040     // 交差
00041     //--------------------------------------------------------------------------
00042     /**
00043      * 球交差
00044      * @param result 交差結果
00045      * @param sphere 球
00046      * @param collisionMask コリジョンマスク
00047      */
00048     virtual void intersection(IntersectionResult* result, const Sphere& sphere,
00049         u_int collisionMask = 0xffffffff);
00050 
00051     /**
00052      * 球コリジョン交差
00053      * @param result 交差結果
00054      * @param sphere 球コリジョン
00055      * @param collisionMask コリジョンマスク
00056      */
00057     virtual void intersection(IntersectionResult* result,
00058         StaticSphereCollision* sphere, u_int collisionMask = 0xffffffff);
00059 
00060     //--------------------------------------------------------------------------
00061     // 球
00062     //--------------------------------------------------------------------------
00063     /**
00064      * 球の設定
00065      * @param sphere 設定する球
00066      */
00067     inline void setSphere(const Sphere& sphere){
00068         sphere_ = sphere;
00069         setChanged(true);
00070     }
00071 
00072     /**
00073      * 球の設定
00074      * @param center 設定する中心
00075      * @param radius 設定する半径
00076      */
00077     inline void setSphere(const Vector3& center, float radius){
00078         sphere_.set(center, radius);
00079         setChanged(true);
00080     }
00081 
00082     /**
00083      * 球の取得
00084      * @return ローカル座標の球
00085      */
00086     virtual const Sphere& getSphere() const{ return sphere_; }
00087 
00088     //--------------------------------------------------------------------------
00089     /**
00090      * ワールド球の取得
00091      * @return ワールド座標の球
00092      */
00093     virtual const Sphere& getWorldSphere(){
00094         Assert(isGlobalEnabled());
00095         return worldSphere_;
00096     }
00097 
00098     //--------------------------------------------------------------------------
00099     /**
00100      * 中心の設定
00101      * @param center 設定する中心
00102      */
00103     inline void setCenter(const Vector3& center){
00104         sphere_.setCenter(center);
00105         setChanged(true);
00106     }
00107 
00108     /**
00109      * 中心の取得
00110      * @return 中心
00111      */
00112     inline const Vector3& getCenter() const{ return sphere_.getCenter(); }
00113 
00114     //--------------------------------------------------------------------------
00115     /**
00116      * 半径の設定
00117      * @param radius 設定する半径
00118      */
00119     inline void setRadius(float radius){
00120         sphere_.setRadius(radius);
00121         setChanged(true);
00122     }
00123 
00124     /**
00125      * 半径の取得
00126      * @return 半径
00127      */
00128     inline float getRadius() const{ return sphere_.getRadius(); }
00129 
00130     //--------------------------------------------------------------------------
00131     // コピー
00132     //--------------------------------------------------------------------------
00133     /**
00134      * コピー
00135      * @return コピーされたコリジョンオブジェクト
00136      */
00137     virtual CollisionObject* copy() const{
00138         return copyStaticSphereCollision();
00139     }
00140 
00141     /**
00142      * コリジョンリーフのコピー
00143      * @return コピーされたコリジョンリーフ
00144      */
00145     virtual CollisionLeaf* copyCollisionLeaf() const{
00146         return copyStaticSphereCollision();
00147     }
00148 
00149     /**
00150      * 静的コリジョンリーフのコピー
00151      * @return コピーされた静的コリジョンリーフ
00152      */
00153     virtual StaticCollisionLeaf* copyStaticCollisionLeaf() const{
00154         return copyStaticSphereCollision();
00155     }
00156 
00157     /**
00158      * 静的球コリジョンのコピー
00159      * @return コピーされた静的球コリジョン
00160      */
00161     virtual StaticSphereCollision*
00162         copyStaticSphereCollision() const;
00163 
00164     //--------------------------------------------------------------------------
00165     // RTTI
00166     //--------------------------------------------------------------------------
00167     /**
00168      * 静的球コリジョンかどうか
00169      * @return 静的球コリジョンならtrue
00170      */
00171     virtual bool isStaticSphereCollision() const{ return true; }
00172 
00173 protected:
00174     //--------------------------------------------------------------------------
00175     // 生成、破棄
00176     //--------------------------------------------------------------------------
00177     /**
00178      * コンストラクタ
00179      * @param name 名前
00180      * @param scene シーン
00181      */
00182     StaticSphereCollision(const String& name, CollisionScene* scene);
00183 
00184     /**
00185      * デストラクタ
00186      */
00187     virtual ~StaticSphereCollision();
00188 
00189     //--------------------------------------------------------------------------
00190     // 走査
00191     //--------------------------------------------------------------------------
00192     /**
00193      * 走査
00194      * @param parentMatrix 親行列
00195      * @param parentEnabled 親が有効か
00196      * @param parentScaled 親がスケールを使用しているか
00197      * @param parentChanged 親に変更があったか
00198      */
00199     virtual void traverseImplement(const Matrix34& parentMatrix,
00200         bool parentEnabled, bool parentScaled, bool parentChanged);
00201 
00202 private:
00203     //--------------------------------------------------------------------------
00204     // 球
00205     Sphere sphere_;
00206     // ワールド球
00207     Sphere worldSphere_;
00208 
00209 };
00210 
00211 //------------------------------------------------------------------------------
00212 } // End of namespace Lamp
00213 #endif // End of STATIC_SPHERE_COLLISION_H_
00214 //------------------------------------------------------------------------------

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