VTrack.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_VTRACK_H_
  24. #define _VT_VTRACK_H_
  25. #ifndef _VT_VCONTROLLER_H_
  26. #include "Verve/Core/VController.h"
  27. #endif
  28. #ifndef _VT_VEVENT_H_
  29. #include "Verve/Core/VEvent.h"
  30. #endif
  31. #ifndef _VT_TORQUE_SCENEOBJECT_H_
  32. #include "Verve/Torque/TSceneObject.h"
  33. #endif
  34. //-----------------------------------------------------------------------------
  35. class VGroup;
  36. //-----------------------------------------------------------------------------
  37. class VTrack : public VObject
  38. {
  39. typedef VObject Parent;
  40. public:
  41. // Controller Members.
  42. VEvent *mNextEvent;
  43. public:
  44. VTrack();
  45. // Tree Methods.
  46. virtual void onAttach( void );
  47. virtual void onDetach( void );
  48. // Controller Methods.
  49. virtual void onControllerUpdate( const S32 &pTime, const S32 &pDelta );
  50. virtual bool onControllerEvent( VController::eControllerEventType pEvent );
  51. virtual void onControllerReset( const S32 &pTime, const bool &pForward );
  52. // Reference Methods.
  53. void sort( void );
  54. bool updateNextEvent( void );
  55. // Console Declaration.
  56. DECLARE_CONOBJECT( VTrack );
  57. public:
  58. // Property Methods.
  59. VGroup *getGroup( void );
  60. template <class T> inline bool getGroup( T *&pGroup )
  61. {
  62. // Reference Group.
  63. pGroup = dynamic_cast<T*>( getGroup() );
  64. // Validate.
  65. return ( pGroup != NULL );
  66. }
  67. VEvent *getNextEvent( void );
  68. template <class T> inline bool getNextEvent( T *&pEvent )
  69. {
  70. // Reference Object.
  71. pEvent = dynamic_cast<T*>( getNextEvent() );
  72. // Validate.
  73. return ( pEvent != NULL );
  74. }
  75. VEvent *getCurrentEvent( void );
  76. template <class T> inline bool getCurrentEvent( T *&pEvent )
  77. {
  78. // Reference Object.
  79. pEvent = dynamic_cast<T*>( getCurrentEvent() );
  80. // Validate.
  81. return ( pEvent != NULL );
  82. }
  83. VEvent *getPreviousEvent( void );
  84. template <class T> inline bool getPreviousEvent( T *&pEvent )
  85. {
  86. // Reference Object.
  87. pEvent = dynamic_cast<T*>( getPreviousEvent() );
  88. // Validate.
  89. return ( pEvent != NULL );
  90. }
  91. F32 calculateInterp( S32 pTime );
  92. F32 _calculateInterp( S32 pTime );
  93. };
  94. //-----------------------------------------------------------------------------
  95. #endif // _VT_VTRACK_H_