/indra/llcharacter/llkeyframemotionparam.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 170 lines · 74 code · 31 blank · 65 comment · 2 complexity · fbbb03b81fcafab41780468c406a07e3 MD5 · raw file

  1. /**
  2. * @file llkeyframemotionparam.h
  3. * @brief Implementation of LLKeframeMotionParam class.
  4. *
  5. * $LicenseInfo:firstyear=2002&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_LLKEYFRAMEMOTIONPARAM_H
  27. #define LL_LLKEYFRAMEMOTIONPARAM_H
  28. //-----------------------------------------------------------------------------
  29. // Header files
  30. //-----------------------------------------------------------------------------
  31. #include <string>
  32. #include "llmotion.h"
  33. #include "lljointstate.h"
  34. #include "v3math.h"
  35. #include "llquaternion.h"
  36. #include "linked_lists.h"
  37. #include "llkeyframemotion.h"
  38. //-----------------------------------------------------------------------------
  39. // class LLKeyframeMotionParam
  40. //-----------------------------------------------------------------------------
  41. class LLKeyframeMotionParam :
  42. public LLMotion
  43. {
  44. public:
  45. // Constructor
  46. LLKeyframeMotionParam(const LLUUID &id);
  47. // Destructor
  48. virtual ~LLKeyframeMotionParam();
  49. public:
  50. //-------------------------------------------------------------------------
  51. // functions to support MotionController and MotionRegistry
  52. //-------------------------------------------------------------------------
  53. // static constructor
  54. // all subclasses must implement such a function and register it
  55. static LLMotion *create(const LLUUID &id) { return new LLKeyframeMotionParam(id); }
  56. public:
  57. //-------------------------------------------------------------------------
  58. // animation callbacks to be implemented by subclasses
  59. //-------------------------------------------------------------------------
  60. // motions must specify whether or not they loop
  61. virtual BOOL getLoop() {
  62. return TRUE;
  63. }
  64. // motions must report their total duration
  65. virtual F32 getDuration() {
  66. return mDuration;
  67. }
  68. // motions must report their "ease in" duration
  69. virtual F32 getEaseInDuration() {
  70. return mEaseInDuration;
  71. }
  72. // motions must report their "ease out" duration.
  73. virtual F32 getEaseOutDuration() {
  74. return mEaseOutDuration;
  75. }
  76. // motions must report their priority
  77. virtual LLJoint::JointPriority getPriority() {
  78. return mPriority;
  79. }
  80. virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
  81. // called to determine when a motion should be activated/deactivated based on avatar pixel coverage
  82. virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_KEYFRAME; }
  83. // run-time (post constructor) initialization,
  84. // called after parameters have been set
  85. // must return true to indicate success and be available for activation
  86. virtual LLMotionInitStatus onInitialize(LLCharacter *character);
  87. // called when a motion is activated
  88. // must return TRUE to indicate success, or else
  89. // it will be deactivated
  90. virtual BOOL onActivate();
  91. // called per time step
  92. // must return TRUE while it is active, and
  93. // must return FALSE when the motion is completed.
  94. virtual BOOL onUpdate(F32 time, U8* joint_mask);
  95. // called when a motion is deactivated
  96. virtual void onDeactivate();
  97. virtual LLPose* getPose() { return mPoseBlender.getBlendedPose();}
  98. protected:
  99. //-------------------------------------------------------------------------
  100. // new functions defined by this subclass
  101. //-------------------------------------------------------------------------
  102. struct ParameterizedMotion
  103. {
  104. ParameterizedMotion(LLMotion* motion, F32 param) : mMotion(motion), mParam(param) {}
  105. LLMotion* mMotion;
  106. F32 mParam;
  107. };
  108. // add a motion and associated parameter triplet
  109. BOOL addKeyframeMotion(char *name, const LLUUID &id, char *param, F32 value);
  110. // set default motion for LOD and retrieving blend constants
  111. void setDefaultKeyframeMotion(char *);
  112. BOOL loadMotions();
  113. protected:
  114. //-------------------------------------------------------------------------
  115. // Member Data
  116. //-------------------------------------------------------------------------
  117. struct compare_motions
  118. {
  119. bool operator() (const ParameterizedMotion& a, const ParameterizedMotion& b) const
  120. {
  121. if (a.mParam != b.mParam)
  122. return (a.mParam < b.mParam);
  123. else
  124. return a.mMotion < b.mMotion;
  125. }
  126. };
  127. typedef std::set < ParameterizedMotion, compare_motions > motion_list_t;
  128. typedef std::map <std::string, motion_list_t > motion_map_t;
  129. motion_map_t mParameterizedMotions;
  130. LLMotion* mDefaultKeyframeMotion;
  131. LLCharacter* mCharacter;
  132. LLPoseBlender mPoseBlender;
  133. F32 mEaseInDuration;
  134. F32 mEaseOutDuration;
  135. F32 mDuration;
  136. LLJoint::JointPriority mPriority;
  137. LLUUID mTransactionID;
  138. };
  139. #endif // LL_LLKEYFRAMEMOTIONPARAM_H