メインページ | ネームスペース一覧 | クラス階層 | 構成 | Directories | ファイル一覧 | ネームスペースメンバ | 構成メンバ | ファイルメンバ | 関連ページ

PHConstraint.h

00001 #ifndef PH_CONSTRAINT_H
00002 #define PH_CONSTRAINT_H
00003 
00004 #include <vector>
00005 #include <Base/BaseUtility.h>
00006 #include <Base/TinyVec.h>
00007 #include <Base/TinyMat.h>
00008 #include <FileIO/FIDocScene.h>
00009 #include <SceneGraph/SGScene.h>
00010 #include <Physics/PHSolid.h>
00011 
00012 namespace Spr{
00013 
00014     //////////////////////////////////////////////////////////////////////
00015     //PHConstrainedState
00016     
00017     class PHConstrainedState{
00018     public:
00019         class DesiredPosture{
00020         public:
00021             double      weight;
00022             Vec3d       position;
00023             Quaterniond orientation;
00024         };
00025         UTRef<PHSolid> solid;
00026         std::vector<DesiredPosture> desired;
00027         int nConstraints;
00028 
00029         PHConstrainedState():nConstraints(0){};
00030     };
00031 
00032     //////////////////////////////////////////////////////////////////////
00033     //PHConstraint
00034     
00035     class PHConstraint : public SGObject{
00036     public:
00037         UTRef<PHSolid>  solid[2];
00038         UTRef<PHConstrainedState> state[2];
00039         size_t idx[2];  //ConstrainedStateのdesired配列での自分のインデックス
00040 
00041         /// 所有しているオブジェクトの数
00042         virtual size_t NChildObjects();
00043         /// 所有しているオブジェクト
00044         virtual SGObject* ChildObject(size_t i);
00045         /// 子オブジェクトの追加
00046         virtual bool AddChildObject(SGObject* o, SGScene* s);
00047         /// 子オブジェクトの削除
00048         virtual bool DelChildObject(SGObject* o, SGScene* s);
00049         /// 子になりえるオブジェクトの型情報の配列
00050         virtual const UTTypeInfo** ChildCandidates();
00051     };
00052 
00053     class PHPointConstraint : public PHConstraint{
00054     public:
00055         class Info{
00056             Vec3f pos_l, pos_r;
00057         };
00058         Info info;
00059     };
00060     /*
00061         template PointConstraint{
00062             Vector  positionL;
00063             Vector  positionR;
00064             [Solid]
00065         }
00066     */
00067 
00068     class PHLineConstraint : public PHConstraint{
00069         Vec3f pos_l, pos_r;
00070         Vec3f dir_l, dir_r;
00071     };
00072 
00073     class PHPlaneConstraint : public PHConstraint{
00074         Vec3f pos_l, pos_r;
00075         Vec3f nor_l, nor_r;
00076     };
00077 
00078     class PHPararrelConstraint : public PHConstraint{
00079         Vec3f dir_l, dir_r;
00080     };
00081 
00082     class PHFixConstraint : public PHConstraint{
00083         Vec3f pos;
00084         Matrix3f rotation;
00085     };
00086 
00087     class PHMagnetConstraint : public PHConstraint{
00088         
00089     };
00090 
00091     class PHContactConstraint : public PHConstraint{
00092 
00093     };
00094 
00095     //////////////////////////////////////////////////////////////////////
00096     //PHConstraintEngine
00097 
00098     typedef std::vector<UTRef<PHConstrainedState> > PHConstrainedStates;
00099     typedef std::vector<UTRef<PHConstraint> > PHConstraints;
00100     
00101     class PHConstraintEngine : public SGBehaviorEngine
00102     {
00103         PHConstrainedStates states;
00104         PHConstraints cons;
00105     public:
00106         SGOBJECTDEF(PHConstraintEngine);
00107         int GetPriority() const {return SG_CONSTRAINT;}
00108         void Loaded(SGScene* scene);
00109         void Clear(SGScene* s){}
00110         PHConstraintEngine::PHConstraintEngine(){}
00111 
00112         virtual void Step(SGScene* s);
00113         void SolveConstraint();
00114 
00115         /// 所有しているオブジェクトの数
00116         virtual size_t NChildObjects();
00117         /// 所有しているオブジェクト
00118         virtual SGObject* ChildObject(size_t i);
00119         /// 子オブジェクトの追加
00120         virtual bool AddChildObject(SGObject* o, SGScene* s);
00121         /// 子オブジェクトの削除
00122         virtual bool DelChildObject(SGObject* o, SGScene* s);
00123         /// 子になりえるオブジェクトの型情報の配列
00124         virtual const UTTypeInfo** ChildCandidates();
00125     };
00126 
00127 }
00128 
00129 #endif

Springheadに対してSun Apr 16 01:57:53 2006に生成されました。  doxygen 1.4.1