pathShape.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //-----------------------------------------------------------------------------
  2. // Torque Game Engine
  3. // Copyright (C) GarageGames.com, Inc.
  4. //-----------------------------------------------------------------------------
  5. #ifndef _PATHSHAPE_H_
  6. #define _PATHSHAPE_H_
  7. #ifndef _STATICSHAPE_H_
  8. #include "T3D/staticShape.h"
  9. #endif
  10. #ifndef _CAMERASPLINE_H_
  11. #include "T3D/cameraSpline.h"
  12. #endif
  13. #ifndef _SIMPATH_H_
  14. #include "scene/simPath.h"
  15. #endif
  16. //----------------------------------------------------------------------------
  17. struct PathShapeData: public StaticShapeData {
  18. typedef StaticShapeData Parent;
  19. PathShapeData();
  20. static void consoleInit();
  21. DECLARE_CONOBJECT(PathShapeData);
  22. bool preload(bool server, String &errorStr);
  23. static void initPersistFields();
  24. virtual void packData(BitStream* stream);
  25. virtual void unpackData(BitStream* stream);
  26. };
  27. //----------------------------------------------------------------------------
  28. class PathShape: public StaticShape
  29. {
  30. public:
  31. enum State {
  32. Forward,
  33. Backward,
  34. Stop,
  35. StateBits = 3
  36. };
  37. private:
  38. typedef StaticShape Parent;
  39. enum MaskBits {
  40. WindowMask = Parent::NextFreeMask,
  41. PositionMask = WindowMask << 1,
  42. TargetMask = PositionMask << 1,
  43. StateMask = TargetMask << 1,
  44. NextFreeMask = StateMask << 1
  45. };
  46. struct StateDelta {
  47. F32 time;
  48. F32 timeVec;
  49. };
  50. StateDelta delta;
  51. enum Constants {
  52. NodeWindow = 20 // Maximum number of active nodes
  53. };
  54. PathShapeData* mDataBlock;
  55. CameraSpline mSpline;
  56. S32 mNodeBase;
  57. S32 mNodeCount;
  58. F32 mPosition;
  59. S32 mState;
  60. F32 mTarget;
  61. bool mTargetSet;
  62. void interpolateMat(F32 pos,MatrixF* mat);
  63. void advancePosition(S32 ms);
  64. public:
  65. DECLARE_CONOBJECT(PathShape);
  66. PathShape();
  67. ~PathShape();
  68. StringTableEntry mControl[4];
  69. static void initPersistFields();
  70. static void consoleInit();
  71. bool onAdd();
  72. void onRemove();
  73. bool onNewDataBlock(GameBaseData* dptr, bool reload);
  74. void onNode(S32 node);
  75. void processTick(const Move*);
  76. void interpolateTick(F32 dt);
  77. U32 packUpdate(NetConnection *, U32 mask, BitStream *stream);
  78. void unpackUpdate(NetConnection *, BitStream *stream);
  79. void reset(F32 speed = 1);
  80. void pushFront(CameraSpline::Knot *knot);
  81. void pushBack(CameraSpline::Knot *knot);
  82. void popFront();
  83. void setPosition(F32 pos);
  84. void setTarget(F32 pos);
  85. void setState(State s);
  86. S32 getState();
  87. SimObjectRef< SimPath::Path > mSimPath;
  88. };
  89. #endif