/indra/llcharacter/lljointstate.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 128 lines · 66 code · 17 blank · 45 comment · 1 complexity · 1f8366ae9d24749931de3a336fc64e08 MD5 · raw file

  1. /**
  2. * @file lljointstate.h
  3. * @brief Implementation of LLJointState 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_LLJOINTSTATE_H
  27. #define LL_LLJOINTSTATE_H
  28. //-----------------------------------------------------------------------------
  29. // Header Files
  30. //-----------------------------------------------------------------------------
  31. #include "lljoint.h"
  32. #include "llrefcount.h"
  33. //-----------------------------------------------------------------------------
  34. // class LLJointState
  35. //-----------------------------------------------------------------------------
  36. class LLJointState : public LLRefCount
  37. {
  38. public:
  39. enum BlendPhase
  40. {
  41. INACTIVE,
  42. EASE_IN,
  43. ACTIVE,
  44. EASE_OUT
  45. };
  46. protected:
  47. // associated joint
  48. LLJoint *mJoint;
  49. // indicates which members are used
  50. U32 mUsage;
  51. // indicates weighted effect of this joint
  52. F32 mWeight;
  53. // transformation members
  54. LLVector3 mPosition; // position relative to parent joint
  55. LLQuaternion mRotation; // joint rotation relative to parent joint
  56. LLVector3 mScale; // scale relative to rotated frame
  57. LLJoint::JointPriority mPriority; // how important this joint state is relative to others
  58. public:
  59. // Constructor
  60. LLJointState()
  61. {
  62. mUsage = 0;
  63. mJoint = NULL;
  64. mUsage = 0;
  65. mWeight = 0.f;
  66. mPriority = LLJoint::USE_MOTION_PRIORITY;
  67. }
  68. LLJointState(LLJoint* joint)
  69. {
  70. mUsage = 0;
  71. mJoint = joint;
  72. mUsage = 0;
  73. mWeight = 0.f;
  74. mPriority = LLJoint::USE_MOTION_PRIORITY;
  75. }
  76. // joint that this state is applied to
  77. LLJoint* getJoint() { return mJoint; }
  78. const LLJoint* getJoint() const { return mJoint; }
  79. BOOL setJoint( LLJoint *joint ) { mJoint = joint; return mJoint != NULL; }
  80. // transform type (bitwise flags can be combined)
  81. // Note that these are set automatically when various
  82. // member setPos/setRot/setScale functions are called.
  83. enum Usage
  84. {
  85. POS = 1,
  86. ROT = 2,
  87. SCALE = 4,
  88. };
  89. U32 getUsage() const { return mUsage; }
  90. void setUsage( U32 usage ) { mUsage = usage; }
  91. F32 getWeight() const { return mWeight; }
  92. void setWeight( F32 weight ) { mWeight = weight; }
  93. // get/set position
  94. const LLVector3& getPosition() const { return mPosition; }
  95. void setPosition( const LLVector3& pos ) { llassert(mUsage & POS); mPosition = pos; }
  96. // get/set rotation
  97. const LLQuaternion& getRotation() const { return mRotation; }
  98. void setRotation( const LLQuaternion& rot ) { llassert(mUsage & ROT); mRotation = rot; }
  99. // get/set scale
  100. const LLVector3& getScale() const { return mScale; }
  101. void setScale( const LLVector3& scale ) { llassert(mUsage & SCALE); mScale = scale; }
  102. // get/set priority
  103. LLJoint::JointPriority getPriority() const { return mPriority; }
  104. void setPriority( LLJoint::JointPriority priority ) { mPriority = priority; }
  105. protected:
  106. // Destructor
  107. virtual ~LLJointState()
  108. {
  109. }
  110. };
  111. #endif // LL_LLJOINTSTATE_H