pathShape.h

Engine/source/T3D/pathShape.h

More...

Classes:

Detailed Description

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