PageRenderTime 33ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcharacter/llheadrotmotion.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 212 lines | 74 code | 45 blank | 93 comment | 0 complexity | 66d772944176d94cd2349861712198ab MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llheadrotmotion.h
  3. * @brief Implementation of LLHeadRotMotion 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_LLHEADROTMOTION_H
  27. #define LL_LLHEADROTMOTION_H
  28. //-----------------------------------------------------------------------------
  29. // Header files
  30. //-----------------------------------------------------------------------------
  31. #include "llmotion.h"
  32. #include "llframetimer.h"
  33. #define MIN_REQUIRED_PIXEL_AREA_HEAD_ROT 500.f;
  34. #define MIN_REQUIRED_PIXEL_AREA_EYE 25000.f;
  35. //-----------------------------------------------------------------------------
  36. // class LLHeadRotMotion
  37. //-----------------------------------------------------------------------------
  38. class LLHeadRotMotion :
  39. public LLMotion
  40. {
  41. public:
  42. // Constructor
  43. LLHeadRotMotion(const LLUUID &id);
  44. // Destructor
  45. virtual ~LLHeadRotMotion();
  46. public:
  47. //-------------------------------------------------------------------------
  48. // functions to support MotionController and MotionRegistry
  49. //-------------------------------------------------------------------------
  50. // static constructor
  51. // all subclasses must implement such a function and register it
  52. static LLMotion *create(const LLUUID &id) { return new LLHeadRotMotion(id); }
  53. public:
  54. //-------------------------------------------------------------------------
  55. // animation callbacks to be implemented by subclasses
  56. //-------------------------------------------------------------------------
  57. // motions must specify whether or not they loop
  58. virtual BOOL getLoop() { return TRUE; }
  59. // motions must report their total duration
  60. virtual F32 getDuration() { return 0.0; }
  61. // motions must report their "ease in" duration
  62. virtual F32 getEaseInDuration() { return 1.f; }
  63. // motions must report their "ease out" duration.
  64. virtual F32 getEaseOutDuration() { return 1.f; }
  65. // called to determine when a motion should be activated/deactivated based on avatar pixel coverage
  66. virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_HEAD_ROT; }
  67. // motions must report their priority
  68. virtual LLJoint::JointPriority getPriority() { return LLJoint::MEDIUM_PRIORITY; }
  69. virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
  70. // run-time (post constructor) initialization,
  71. // called after parameters have been set
  72. // must return true to indicate success and be available for activation
  73. virtual LLMotionInitStatus onInitialize(LLCharacter *character);
  74. // called when a motion is activated
  75. // must return TRUE to indicate success, or else
  76. // it will be deactivated
  77. virtual BOOL onActivate();
  78. // called per time step
  79. // must return TRUE while it is active, and
  80. // must return FALSE when the motion is completed.
  81. virtual BOOL onUpdate(F32 time, U8* joint_mask);
  82. // called when a motion is deactivated
  83. virtual void onDeactivate();
  84. public:
  85. //-------------------------------------------------------------------------
  86. // joint states to be animated
  87. //-------------------------------------------------------------------------
  88. LLCharacter *mCharacter;
  89. LLJoint *mTorsoJoint;
  90. LLJoint *mHeadJoint;
  91. LLJoint *mRootJoint;
  92. LLJoint *mPelvisJoint;
  93. LLPointer<LLJointState> mTorsoState;
  94. LLPointer<LLJointState> mNeckState;
  95. LLPointer<LLJointState> mHeadState;
  96. LLQuaternion mLastHeadRot;
  97. };
  98. //-----------------------------------------------------------------------------
  99. // class LLEyeMotion
  100. //-----------------------------------------------------------------------------
  101. class LLEyeMotion :
  102. public LLMotion
  103. {
  104. public:
  105. // Constructor
  106. LLEyeMotion(const LLUUID &id);
  107. // Destructor
  108. virtual ~LLEyeMotion();
  109. public:
  110. //-------------------------------------------------------------------------
  111. // functions to support MotionController and MotionRegistry
  112. //-------------------------------------------------------------------------
  113. // static constructor
  114. // all subclasses must implement such a function and register it
  115. static LLMotion *create( const LLUUID &id) { return new LLEyeMotion(id); }
  116. public:
  117. //-------------------------------------------------------------------------
  118. // animation callbacks to be implemented by subclasses
  119. //-------------------------------------------------------------------------
  120. // motions must specify whether or not they loop
  121. virtual BOOL getLoop() { return TRUE; }
  122. // motions must report their total duration
  123. virtual F32 getDuration() { return 0.0; }
  124. // motions must report their "ease in" duration
  125. virtual F32 getEaseInDuration() { return 0.5f; }
  126. // motions must report their "ease out" duration.
  127. virtual F32 getEaseOutDuration() { return 0.5f; }
  128. // called to determine when a motion should be activated/deactivated based on avatar pixel coverage
  129. virtual F32 getMinPixelArea() { return MIN_REQUIRED_PIXEL_AREA_EYE; }
  130. // motions must report their priority
  131. virtual LLJoint::JointPriority getPriority() { return LLJoint::MEDIUM_PRIORITY; }
  132. virtual LLMotionBlendType getBlendType() { return NORMAL_BLEND; }
  133. // run-time (post constructor) initialization,
  134. // called after parameters have been set
  135. // must return true to indicate success and be available for activation
  136. virtual LLMotionInitStatus onInitialize(LLCharacter *character);
  137. // called when a motion is activated
  138. // must return TRUE to indicate success, or else
  139. // it will be deactivated
  140. virtual BOOL onActivate();
  141. // called per time step
  142. // must return TRUE while it is active, and
  143. // must return FALSE when the motion is completed.
  144. virtual BOOL onUpdate(F32 time, U8* joint_mask);
  145. // called when a motion is deactivated
  146. virtual void onDeactivate();
  147. public:
  148. //-------------------------------------------------------------------------
  149. // joint states to be animated
  150. //-------------------------------------------------------------------------
  151. LLCharacter *mCharacter;
  152. LLJoint *mHeadJoint;
  153. LLPointer<LLJointState> mLeftEyeState;
  154. LLPointer<LLJointState> mRightEyeState;
  155. LLFrameTimer mEyeJitterTimer;
  156. F32 mEyeJitterTime;
  157. F32 mEyeJitterYaw;
  158. F32 mEyeJitterPitch;
  159. F32 mEyeLookAwayTime;
  160. F32 mEyeLookAwayYaw;
  161. F32 mEyeLookAwayPitch;
  162. // eye blinking
  163. LLFrameTimer mEyeBlinkTimer;
  164. F32 mEyeBlinkTime;
  165. BOOL mEyesClosed;
  166. };
  167. #endif // LL_LLHEADROTMOTION_H