PageRenderTime 51ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llcharacter/llkeyframewalkmotion.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 174 lines | 85 code | 21 blank | 68 comment | 0 complexity | fe8de14ea542e9550bbb2272e9532a23 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llkeyframewalkmotion.h
  3. * @brief Implementation of LLKeframeWalkMotion class.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLKEYFRAMEWALKMOTION_H
  27. #define LL_LLKEYFRAMEWALKMOTION_H
  28. //-----------------------------------------------------------------------------
  29. // Header files
  30. //-----------------------------------------------------------------------------
  31. #include "llkeyframemotion.h"
  32. #include "llcharacter.h"
  33. #include "v3dmath.h"
  34. #define MIN_REQUIRED_PIXEL_AREA_WALK_ADJUST (20.f)
  35. #define MIN_REQUIRED_PIXEL_AREA_FLY_ADJUST (20.f)
  36. //-----------------------------------------------------------------------------
  37. // class LLKeyframeWalkMotion
  38. //-----------------------------------------------------------------------------
  39. class LLKeyframeWalkMotion :
  40. public LLKeyframeMotion
  41. {
  42. friend class LLWalkAdjustMotion;
  43. public:
  44. // Constructor
  45. LLKeyframeWalkMotion(const LLUUID &id);
  46. // Destructor
  47. virtual ~LLKeyframeWalkMotion();
  48. public:
  49. //-------------------------------------------------------------------------
  50. // functions to support MotionController and MotionRegistry
  51. //-------------------------------------------------------------------------
  52. // static constructor
  53. // all subclasses must implement such a function and register it
  54. static LLMotion *create(const LLUUID &id) { return new LLKeyframeWalkMotion(id); }
  55. public:
  56. //-------------------------------------------------------------------------
  57. // animation callbacks to be implemented by subclasses
  58. //-------------------------------------------------------------------------
  59. virtual LLMotionInitStatus onInitialize(LLCharacter *character);
  60. virtual BOOL onActivate();
  61. virtual void onDeactivate();
  62. virtual BOOL onUpdate(F32 time, U8* joint_mask);
  63. public:
  64. //-------------------------------------------------------------------------
  65. // Member Data
  66. //-------------------------------------------------------------------------
  67. LLCharacter *mCharacter;
  68. F32 mCyclePhase;
  69. F32 mRealTimeLast;
  70. F32 mAdjTimeLast;
  71. S32 mDownFoot;
  72. };
  73. class LLWalkAdjustMotion : public LLMotion
  74. {
  75. public:
  76. // Constructor
  77. LLWalkAdjustMotion(const LLUUID &id);
  78. public:
  79. //-------------------------------------------------------------------------
  80. // functions to support MotionController and MotionRegistry
  81. //-------------------------------------------------------------------------
  82. // static constructor
  83. // all subclasses must implement such a function and register it
  84. static LLMotion *create(const LLUUID &id) { return new LLWalkAdjustMotion(id); }
  85. public:
  86. //-------------------------------------------------------------------------
  87. // animation callbacks to be implemented by subclasses
  88. //-------------------------------------------------------------------------
  89. virtual LLMotionInitStatus onInitialize(LLCharacter *character);
  90. virtual BOOL onActivate();
  91. virtual void onDeactivate();
  92. virtual BOOL onUpdate(F32 time, U8* joint_mask);
  93. virtual LLJoint::JointPriority getPriority(){return LLJoint::HIGH_PRIORITY;}
  94. virtual BOOL getLoop() { return TRUE; }
  95. virtual F32 getDuration() { return 0.f; }
  96. virtual F32 getEaseInDuration() { return 0.f; }
  97. virtual F32 getEaseOutDuration() { return 0.f; }
  98. virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_WALK_ADJUST; }
  99. virtual LLMotionBlendType getBlendType() { return ADDITIVE_BLEND; }
  100. public:
  101. //-------------------------------------------------------------------------
  102. // Member Data
  103. //-------------------------------------------------------------------------
  104. LLCharacter *mCharacter;
  105. LLJoint* mLeftAnkleJoint;
  106. LLJoint* mRightAnkleJoint;
  107. LLPointer<LLJointState> mPelvisState;
  108. LLJoint* mPelvisJoint;
  109. LLVector3d mLastLeftFootGlobalPos;
  110. LLVector3d mLastRightFootGlobalPos;
  111. F32 mLastTime;
  112. F32 mAdjustedSpeed;
  113. F32 mAnimSpeed;
  114. F32 mRelativeDir;
  115. LLVector3 mPelvisOffset;
  116. F32 mAnkleOffset;
  117. };
  118. class LLFlyAdjustMotion : public LLMotion
  119. {
  120. public:
  121. // Constructor
  122. LLFlyAdjustMotion(const LLUUID &id);
  123. public:
  124. //-------------------------------------------------------------------------
  125. // functions to support MotionController and MotionRegistry
  126. //-------------------------------------------------------------------------
  127. // static constructor
  128. // all subclasses must implement such a function and register it
  129. static LLMotion *create(const LLUUID &id) { return new LLFlyAdjustMotion(id); }
  130. public:
  131. //-------------------------------------------------------------------------
  132. // animation callbacks to be implemented by subclasses
  133. //-------------------------------------------------------------------------
  134. virtual LLMotionInitStatus onInitialize(LLCharacter *character);
  135. virtual BOOL onActivate();
  136. virtual void onDeactivate() {};
  137. virtual BOOL onUpdate(F32 time, U8* joint_mask);
  138. virtual LLJoint::JointPriority getPriority(){return LLJoint::HIGHER_PRIORITY;}
  139. virtual BOOL getLoop() { return TRUE; }
  140. virtual F32 getDuration() { return 0.f; }
  141. virtual F32 getEaseInDuration() { return 0.f; }
  142. virtual F32 getEaseOutDuration() { return 0.f; }
  143. virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_FLY_ADJUST; }
  144. virtual LLMotionBlendType getBlendType() { return ADDITIVE_BLEND; }
  145. protected:
  146. //-------------------------------------------------------------------------
  147. // Member Data
  148. //-------------------------------------------------------------------------
  149. LLCharacter *mCharacter;
  150. LLPointer<LLJointState> mPelvisState;
  151. F32 mRoll;
  152. };
  153. #endif // LL_LLKeyframeWalkMotion_H