lleditingmotion.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * @file lleditingmotion.h
  3. * @brief Implementation of LLEditingMotion 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_LLEDITINGMOTION_H
  33. #define LL_LLEDITINGMOTION_H
  34. #include "lljointsolverrp3.h"
  35. #include "llmotion.h"
  36. #include "llvector3d.h"
  37. #define EDITING_EASEIN_DURATION 0.0f
  38. #define EDITING_EASEOUT_DURATION 0.5f
  39. #define EDITING_PRIORITY LLJoint::HIGH_PRIORITY
  40. #define MIN_REQUIRED_PIXEL_AREA_EDITING 500.f
  41. class LLEditingMotion final : public LLMotion
  42. {
  43. protected:
  44. LOG_CLASS(LLEditingMotion);
  45. public:
  46. LLEditingMotion(const LLUUID& id);
  47. LL_INLINE static LLMotion* create(const LLUUID& id) { return new LLEditingMotion(id); }
  48. // Motions must specify whether or not they loop
  49. LL_INLINE bool getLoop() override { return true; }
  50. // Motions must report their total duration
  51. LL_INLINE F32 getDuration() override { return 0.f; }
  52. // Motions must report their "ease in" duration
  53. LL_INLINE F32 getEaseInDuration() override { return EDITING_EASEIN_DURATION; }
  54. // Motions must report their "ease out" duration.
  55. LL_INLINE F32 getEaseOutDuration() override { return EDITING_EASEOUT_DURATION; }
  56. // Motions must report their priority
  57. LL_INLINE LLJoint::JointPriority getPriority() override { return EDITING_PRIORITY; }
  58. LL_INLINE LLMotionBlendType getBlendType() override { return NORMAL_BLEND; }
  59. // Called to determine when a motion should be activated/deactivated based
  60. // on avatar pixel coverage.
  61. LL_INLINE F32 getMinPixelArea() override { return MIN_REQUIRED_PIXEL_AREA_EDITING; }
  62. // Run-time (post constructor) initialization, called after parameters have
  63. // been set. Must return true to indicate success and be available for
  64. // activation.
  65. LLMotionInitStatus onInitialize(LLCharacter* character) override;
  66. // Called when a motion is activated must return true to indicate success,
  67. // or else it will be deactivated.
  68. bool onActivate() override;
  69. // Called per time step. Must return true while it is active, and must
  70. // return false when the motion is completed.
  71. bool onUpdate(F32 time, U8* joint_mask) override;
  72. // Called when a motion is deactivated
  73. LL_INLINE void onDeactivate() override {}
  74. public:
  75. LLJoint mParentJoint;
  76. LLJoint mShoulderJoint;
  77. LLJoint mElbowJoint;
  78. LLJoint mWristJoint;
  79. LLJoint mTarget;
  80. // Joint states to be animated
  81. LLPointer<LLJointState> mParentState;
  82. LLPointer<LLJointState> mShoulderState;
  83. LLPointer<LLJointState> mElbowState;
  84. LLPointer<LLJointState> mWristState;
  85. LLPointer<LLJointState> mTorsoState;
  86. LLCharacter* mCharacter;
  87. LLVector3 mWristOffset;
  88. LLVector3 mLastSelectPt;
  89. LLJointSolverRP3 mIKSolver;
  90. static S32 sHandPose;
  91. static S32 sHandPosePriority;
  92. };
  93. #endif // LL_LLKEYFRAMEMOTION_H