00001 #ifndef PHWARP_H 00002 #define PHWARP_H 00003 00004 #include <Collision/CDFramePair.h> 00005 #include <Collision/CDCollisionEngine.h> 00006 #include "PHSolid.h" 00007 00008 namespace Spr{; 00009 00010 /** 指定した剛体(複数指定可)がワープゾーンに衝突したときワープさせる. 00011 例えば,ワープゾーンフレームを床の下にひろーく作っておけば, 00012 床から落ちたオブジェクトを床の上方にワープさせるということが可能. 00013 PHWarpEngine が持つ. */ 00014 class PHWarp:public SGObject{ 00015 SGOBJECTDEF(PHWarp); 00016 protected: 00017 00018 public: 00019 Vec3f position; ///< ワープ先の位置 00020 Vec3f velocity; ///< ワープ先での速度 00021 Vec3f angVel; ///< ワープ先での角速度 00022 UTRef<SGFrame> warpZoneFrame; ///< ワープゾーン 00023 PHSolids solids; ///< ワープさせる剛体たち 00024 00025 /// クリア 00026 void Clear(); 00027 /// 00028 bool AddChildObject(SGObject* o, SGScene* s); 00029 00030 }; 00031 00032 /// PHWarpの配列 00033 class PHWarps:public std::vector< UTRef<PHWarp> >{ 00034 }; 00035 00036 00037 /** ワープエンジン */ 00038 class PHWarpEngine:public SGBehaviorEngine, CDCollisionListener { 00039 SGOBJECTDEF(PHWarpEngine); 00040 00041 public: 00042 /// フレーム対ごとのワープデータ 00043 class FramePairRecord:public CDUserRecord{ 00044 public: 00045 Vec3f position; ///< ワープ先の位置 00046 Vec3f velocity; ///< ワープ先での速度 00047 Vec3f angVel; ///< ワープ先での角速度 00048 UTRef<PHSolid> solid[2]; ///< ワープさせる剛体 00049 int frameID[2]; ///< フレーム対のID 00050 }; 00051 00052 00053 public: 00054 /// PHWarpEngine の呼ばれる優先順位 00055 int GetPriority() const { return SGBP_WARPENGINE; } 00056 /// 00057 bool AddChildObject(SGObject* o, SGScene* s); 00058 /// 接触時に呼ばれるコールバック.ワープをさせる処理を行う. 00059 void After(SGScene* scene, CDFramePairWithRecord* fr); 00060 /// 時間を dt 進める(何もしない,Listener の Collide がすべての処理をする) 00061 virtual void Step(SGScene* s){} 00062 /// クリア 00063 virtual void Clear(SGScene* s); 00064 /// ロード完了時の処理,CollisionEngine にコールバックを登録する.CollisionEngine がなければ作る. 00065 virtual void Loaded(SGScene* scene); 00066 /// FramePairRecord の登録 00067 void AddFramePairRecord(PHWarp* w, int f1, int f2, PHSolid* s1, PHSolid* s2=NULL); 00068 00069 PHWarps warps; ///< ワープの情報 00070 protected: 00071 int listenerPos; ///< リスナの位置 00072 int framePairRecordPos; ///< ワープエンジン用の FramePairRecord の位置 00073 std::vector< UTRef<FramePairRecord> > framePairRecords; ///< フレーム対ごとのワープデータ 00074 }; 00075 00076 00077 }; 00078 #endif