VActorData.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //-----------------------------------------------------------------------------
  2. // Verve
  3. // Copyright (C) 2014 - Violent Tulip
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to
  7. // deal in the Software without restriction, including without limitation the
  8. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9. // sell copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. // IN THE SOFTWARE.
  22. //-----------------------------------------------------------------------------
  23. #ifndef _VT_VACTORDATA_H_
  24. #define _VT_VACTORDATA_H_
  25. #ifndef _SHAPEBASE_H_
  26. #include "T3D/shapeBase.h"
  27. #endif
  28. //-----------------------------------------------------------------------------
  29. class VActor;
  30. class VActorStateTable;
  31. class VActorAnimationState;
  32. class VActorPhysicsState;
  33. //-----------------------------------------------------------------------------
  34. struct VActorData : public ShapeBaseData
  35. {
  36. private:
  37. typedef ShapeBaseData Parent;
  38. friend class VActor;
  39. public:
  40. // Animation Data.
  41. enum eAnimationList
  42. {
  43. k_NextAnimation = 0,
  44. };
  45. struct sAnimationSequence
  46. {
  47. U32 Index;
  48. const char *Name;
  49. F32 Priority;
  50. VActorAnimationState *State;
  51. S32 Sequence;
  52. };
  53. struct sAnimationTransition
  54. {
  55. U32 FromIndex;
  56. U32 ToIndex;
  57. F32 Duration;
  58. bool Ordered;
  59. U32 Sequence;
  60. };
  61. typedef Vector<sAnimationSequence> tAnimationSequenceVector;
  62. typedef Vector<sAnimationTransition> tAnimationTransitionVector;
  63. // Physics Data.
  64. enum ePhysicsStateList
  65. {
  66. k_NextPhysicsState = 0,
  67. };
  68. struct sPhysicsState
  69. {
  70. U32 Index;
  71. F32 Priority;
  72. VActorPhysicsState *State;
  73. };
  74. typedef Vector<sPhysicsState> tPhysicsStateVector;
  75. protected:
  76. tAnimationSequenceVector mAnimationSequenceList;
  77. tAnimationTransitionVector mAnimationTransitionList;
  78. tPhysicsStateVector mPhysicsList;
  79. F32 mMaxStepHeight;
  80. F32 mRunSpeed;
  81. F32 mSubmergeCoverage;
  82. public:
  83. VActorData( void );
  84. ~VActorData( void );
  85. static void initPersistFields( void );
  86. virtual bool initAnimationSequenceList( const S32 &pSize, const sAnimationSequence *pTable );
  87. virtual bool initAnimationTransitionList( const S32 &pSize, const sAnimationTransition *pTable );
  88. virtual bool initPhysicsStateList( const S32 &pSize, const sPhysicsState *pTable );
  89. virtual void packData( BitStream *pStream );
  90. virtual void unpackData( BitStream *pStream );
  91. DECLARE_CONOBJECT( VActorData );
  92. public:
  93. tAnimationSequenceVector *getAnimationList( void ) { return &mAnimationSequenceList; };
  94. S32 getAnimationSequence( const U32 &pIndex );
  95. tPhysicsStateVector *getPhysicsStateList( void ) { return &mPhysicsList; };
  96. inline const F32 &getMaxStepHeight( void ) const { return mMaxStepHeight; };
  97. inline const F32 &getRunSpeed( void ) const { return mRunSpeed; };
  98. inline const F32 &getSumbergeCoverage( void ) const { return mSubmergeCoverage; };
  99. };
  100. #endif // _VT_VACTORDATA_H_