llhandmotion.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /**
  2. * @file llhandmotion.h
  3. * @brief Implementation of LLHandMotion class.
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLHANDMOTION_H
  33. #define LL_LLHANDMOTION_H
  34. #include "llmotion.h"
  35. #include "lltimer.h"
  36. #define MIN_REQUIRED_PIXEL_AREA_HAND 10000.f;
  37. class LLHandMotion final : public LLMotion
  38. {
  39. protected:
  40. LOG_CLASS(LLHandMotion);
  41. public:
  42. typedef enum e_hand_pose
  43. {
  44. HAND_POSE_SPREAD,
  45. HAND_POSE_RELAXED,
  46. HAND_POSE_POINT,
  47. HAND_POSE_FIST,
  48. HAND_POSE_RELAXED_L,
  49. HAND_POSE_POINT_L,
  50. HAND_POSE_FIST_L,
  51. HAND_POSE_RELAXED_R,
  52. HAND_POSE_POINT_R,
  53. HAND_POSE_FIST_R,
  54. HAND_POSE_SALUTE_R,
  55. HAND_POSE_TYPING,
  56. HAND_POSE_PEACE_R,
  57. HAND_POSE_PALM_R,
  58. NUM_HAND_POSES
  59. } eHandPose;
  60. LLHandMotion(const LLUUID& id);
  61. LL_INLINE static LLMotion* create(const LLUUID& id) { return new LLHandMotion(id); }
  62. // Motions must specify whether or not they loop
  63. LL_INLINE bool getLoop() override { return true; }
  64. // Motions must report their total duration
  65. LL_INLINE F32 getDuration() override { return 0.f; }
  66. // Motions must report their "ease in" duration
  67. LL_INLINE F32 getEaseInDuration() override { return 0.f; }
  68. // Motions must report their "ease out" duration.
  69. LL_INLINE F32 getEaseOutDuration() override { return 0.f; }
  70. // Called to determine when a motion should be activated/deactivated based
  71. // on avatar pixel coverage
  72. LL_INLINE F32 getMinPixelArea() override { return MIN_REQUIRED_PIXEL_AREA_HAND; }
  73. // Motions must report their priority
  74. LL_INLINE LLJoint::JointPriority getPriority() override { return LLJoint::MEDIUM_PRIORITY; }
  75. LL_INLINE LLMotionBlendType getBlendType() override { return NORMAL_BLEND; }
  76. // Run-time (post constructor) initialization, called after parameters have
  77. // been set.
  78. LLMotionInitStatus onInitialize(LLCharacter* character) override
  79. {
  80. mCharacter = character;
  81. return STATUS_SUCCESS;
  82. }
  83. // Called when a motion is activated. Must return true to indicate success,
  84. // or else it will be deactivated.
  85. bool onActivate() override;
  86. // Called per time step. Must return true while it is active, and must
  87. // return false when the motion is completed.
  88. bool onUpdate(F32 time, U8* joint_mask) override;
  89. // Called when a motion is deactivated
  90. LL_INLINE void onDeactivate() override {}
  91. LL_INLINE bool canDeprecate() override { return false; }
  92. static std::string getHandPoseName(eHandPose pose);
  93. static eHandPose getHandPose(const std::string& posename);
  94. public:
  95. LLCharacter* mCharacter;
  96. F32 mLastTime;
  97. eHandPose mCurrentPose;
  98. eHandPose mNewPose;
  99. };
  100. #endif // LL_LLHANDMOTION_H