pathShape.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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) override;
  23. static void initPersistFields();
  24. void packData(BitStream* stream) override;
  25. void unpackData(BitStream* stream) override;
  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. DECLARE_CATEGORY("Cinematic");
  67. PathShape();
  68. ~PathShape();
  69. StringTableEntry mControl[4];
  70. static void initPersistFields();
  71. static void consoleInit();
  72. bool onAdd() override;
  73. void onRemove() override;
  74. bool onNewDataBlock(GameBaseData* dptr, bool reload) override;
  75. void onNode(S32 node);
  76. void processTick(const Move*) override;
  77. void interpolateTick(F32 dt) override;
  78. U32 packUpdate(NetConnection *, U32 mask, BitStream *stream) override;
  79. void unpackUpdate(NetConnection *, BitStream *stream) override;
  80. void reset(F32 speed = 1);
  81. void pushFront(CameraSpline::Knot *knot);
  82. void pushBack(CameraSpline::Knot *knot);
  83. void popFront();
  84. void setPosition(F32 pos);
  85. void setTarget(F32 pos);
  86. void setState(State s);
  87. S32 getState();
  88. SimObjectRef< SimPath::Path > mSimPath;
  89. };
  90. #endif