/indra/llcharacter/llpose.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 140 lines · 72 code · 21 blank · 47 comment · 0 complexity · 980912d87b4393818abee26df3b37fa6 MD5 · raw file

  1. /**
  2. * @file llpose.h
  3. * @brief Implementation of LLPose 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_LLPOSE_H
  27. #define LL_LLPOSE_H
  28. //-----------------------------------------------------------------------------
  29. // Header Files
  30. //-----------------------------------------------------------------------------
  31. #include "lljointstate.h"
  32. #include "lljoint.h"
  33. #include "llmap.h"
  34. #include "llpointer.h"
  35. #include <map>
  36. #include <string>
  37. //-----------------------------------------------------------------------------
  38. // class LLPose
  39. //-----------------------------------------------------------------------------
  40. class LLPose
  41. {
  42. friend class LLPoseBlender;
  43. protected:
  44. typedef std::map<std::string, LLPointer<LLJointState> > joint_map;
  45. typedef joint_map::iterator joint_map_iterator;
  46. typedef joint_map::value_type joint_map_value_type;
  47. joint_map mJointMap;
  48. F32 mWeight;
  49. joint_map_iterator mListIter;
  50. public:
  51. // Iterate through jointStates
  52. LLJointState* getFirstJointState();
  53. LLJointState* getNextJointState();
  54. LLJointState* findJointState(LLJoint *joint);
  55. LLJointState* findJointState(const std::string &name);
  56. public:
  57. // Constructor
  58. LLPose() : mWeight(0.f) {}
  59. // Destructor
  60. ~LLPose();
  61. // add a joint state in this pose
  62. BOOL addJointState(const LLPointer<LLJointState>& jointState);
  63. // remove a joint state from this pose
  64. BOOL removeJointState(const LLPointer<LLJointState>& jointState);
  65. // removes all joint states from this pose
  66. BOOL removeAllJointStates();
  67. // set weight for all joint states in this pose
  68. void setWeight(F32 weight);
  69. // get weight for this pose
  70. F32 getWeight() const;
  71. // returns number of joint states stored in this pose
  72. S32 getNumJointStates() const;
  73. };
  74. const S32 JSB_NUM_JOINT_STATES = 6;
  75. class LLJointStateBlender
  76. {
  77. protected:
  78. LLPointer<LLJointState> mJointStates[JSB_NUM_JOINT_STATES];
  79. S32 mPriorities[JSB_NUM_JOINT_STATES];
  80. BOOL mAdditiveBlends[JSB_NUM_JOINT_STATES];
  81. public:
  82. LLJointStateBlender();
  83. ~LLJointStateBlender();
  84. void blendJointStates(BOOL apply_now = TRUE);
  85. BOOL addJointState(const LLPointer<LLJointState>& joint_state, S32 priority, BOOL additive_blend);
  86. void interpolate(F32 u);
  87. void clear();
  88. void resetCachedJoint();
  89. public:
  90. LLJoint mJointCache;
  91. };
  92. class LLMotion;
  93. class LLPoseBlender
  94. {
  95. protected:
  96. typedef std::list<LLJointStateBlender*> blender_list_t;
  97. typedef std::map<LLJoint*,LLJointStateBlender*> blender_map_t;
  98. blender_map_t mJointStateBlenderPool;
  99. blender_list_t mActiveBlenders;
  100. S32 mNextPoseSlot;
  101. LLPose mBlendedPose;
  102. public:
  103. // Constructor
  104. LLPoseBlender();
  105. // Destructor
  106. ~LLPoseBlender();
  107. // request motion joint states to be added to pose blender joint state records
  108. BOOL addMotion(LLMotion* motion);
  109. // blend all joint states and apply to skeleton
  110. void blendAndApply();
  111. // removes all joint state blenders from last time
  112. void clearBlenders();
  113. // blend all joint states and cache results
  114. void blendAndCache(BOOL reset_cached_joints);
  115. // interpolate all joints towards cached values
  116. void interpolate(F32 u);
  117. LLPose* getBlendedPose() { return &mBlendedPose; }
  118. };
  119. #endif // LL_LLPOSE_H