00001 #ifndef _TTABLE_H__ 00002 #define _TTABLE_H__ 00003 00004 #include "../../core/src/scenemodule.h" 00005 #include "../tracking/bodies.h" 00006 #include <vector> 00007 00009 00015 class Condition 00016 { 00017 private: 00019 00022 int pressedButtonsMask; 00024 00029 int releasedButtonsMask; 00031 00036 float control1; 00038 00040 float control2; 00041 public: 00043 00049 Condition(int pressed = 0, int released= 0, float ctrl1= 0, float ctrl2 = 0); 00051 ~Condition(); 00053 00057 bool Evaluate(int buttons, float ctr1, float ctr2); 00059 00062 void Reset(int pressed = 0, int released = 0, float ctrl1 = 0, float ctrl2 = 0); 00064 int PressedMask(); 00066 int ReleasedMask(); 00068 float Control1(); 00070 float Control2(); 00071 }; 00072 00074 class TTableEntry 00075 { 00076 public: 00078 00082 enum TransformMode 00083 { 00084 TRANSFORM_RELATIVE = 0, 00085 TRANSFORM_ABSOLUTE = 1, 00086 TRANSFORM_ROTATION = 2, 00087 TRANSFORM_TRANSLATION = 3, 00088 TRANSFORM_USE_RELATIVE = 4, 00089 TRANSFORM_USE_ROTATION = 5, 00090 TRANSFORM_USE_TRANSLATION = 6, 00091 WORLD_TRANSFORM_RELATIVE = 7, 00092 WORLD_TRANSFORM_ROTATION = 8, 00093 WORLD_TRANSFORM_TRANSLATION = 9, 00094 WORLD_TRANSFORM_USE_RELATIVE = 10, 00095 WORLD_TRANSFORM_USE_ROTATION = 11, 00096 WORLD_TRANSFORM_USE_TRANSLATION = 12 00097 00098 }; 00100 00108 TTableEntry(int BodyID, Body::BodyType type, int IDscene, int IDsceneNode,Condition condition = Condition(),TransformMode mod = TRANSFORM_RELATIVE,float scale = 1); 00110 ~TTableEntry(); 00112 00115 void SetScale(float scale); 00117 00120 void SetTransformMode(TransformMode mod); 00122 00125 void SetSceneNode(int scene, int node); 00127 00130 void SetCondition(Condition condition); 00132 float GetScale(); 00134 TTableEntry::TransformMode GetTransformationMode(); 00136 int GetSceneID(); 00138 int GetSceneNodeID(); 00140 00143 void GetSceneNode(int & scene, int & node); 00145 Condition GetCondition(); 00147 00151 bool EvaluateCondition(int buttons, float c1 = 0, float c2 = 0); 00153 00159 void generateEvent(MATRIX bodyMatrix, int buttons, float c1, float c2, VRUT::SceneModule * module); 00161 int GetBodyID(); 00163 Body::BodyType GetBodyType(); 00165 00168 MATRIX PrevMatrix(); 00170 00172 wxString GetAsString(); 00173 private: 00175 int idBody; 00177 Body::BodyType bodyType; 00179 int idScene; 00181 int idSceneNode; 00183 00186 TransformMode mode; 00188 00191 MATRIX prevMatrix; 00193 00195 Condition transformCondition; 00197 float scale; 00199 00202 bool changed; 00204 00208 void relativeMatrix(MATRIX &prev, MATRIX & curr); 00210 00213 MATRIX transformMatrix(const MATRIX * relative, const MATRIX * nodeCurrentMatrix); 00215 00221 MATRIX transformMatrixRegardWorld(const MATRIX * relative, const MATRIX * nodeLocalMatrix, const MATRIX * nodeWorldMatrix); 00222 00223 }; 00224 00231 class TrackingTable 00232 { 00233 private: 00235 std::vector<TTableEntry> table; 00237 int iterator; 00239 int idBody; 00241 Body::BodyType type; 00243 int SceneId; 00245 int SceneNodeID; 00246 public: 00248 TrackingTable(); 00250 ~TrackingTable(); 00252 00257 void AddRow(int bodyID, Body::BodyType type, int sceneId, int SceneNode, Condition condition, TTableEntry::TransformMode mode, float scale); 00259 00268 void AddRow(int bodyID, Body::BodyType type, int sceneId, int SceneNode, int pressed, int released, float ctrl1, float ctrl2, TTableEntry::TransformMode mode, float scale); 00270 00280 void UpdateRow(int bodyID, Body::BodyType type, int sceneID, int sceneNode, Condition condition, TTableEntry::TransformMode mode, float scale); 00282 00288 void UpdateRow(int row, Condition condition, TTableEntry::TransformMode mode, float scale); 00290 00296 int GetFirstRow(int idBody, Body::BodyType type, int scene, int sceneNode); 00298 00301 int GetNextRow(); 00302 int GetSceneID(int row); 00303 int GetSceneNodeID(int row); 00305 00308 void SetScale(int row, float scale); 00310 00313 void SetTransformMode(int row, TTableEntry::TransformMode mod); 00315 00318 void SetCondition(int row,Condition condition); 00320 float GetScale(int row); 00322 TTableEntry::TransformMode GetTransformationMode(int row); 00324 Condition GetCondition(int row); 00326 00329 TTableEntry * getTableEntry(int row); 00331 00338 void ProcessTable(Body::BodyType type, int bodyID, MATRIX bodyMatrix, int buttons, float ctrl1, float ctrl2, VRUT::SceneModule * module); 00340 00353 bool InsertLine(int bodyID, Body::BodyType type, int sceneID, int sceneNode, int pressed, int released, float ctrl1, float ctrl2, TTableEntry::TransformMode mode, float scale); 00355 00368 bool EraseLine(int bodyID, Body::BodyType type, int sceneID, int sceneNode, int pressed, int released, float ctrl1, float ctrl2, TTableEntry::TransformMode mode, float scale); 00370 void ClearTable(); 00372 00375 00376 wxString GetAsString(); 00377 00378 void WriteToLog(); 00379 }; 00381 00385 #endif