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

/indra/llcharacter/llvisualparam.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 165 lines | 93 code | 29 blank | 43 comment | 4 complexity | 93d1c12c66917c0a3447fefc6062bc2c MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llvisualparam.h
  3. * @brief Implementation of LLPolyMesh 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_LLVisualParam_H
  27. #define LL_LLVisualParam_H
  28. #include "v3math.h"
  29. #include "llstring.h"
  30. #include "llxmltree.h"
  31. #include <boost/function.hpp>
  32. class LLPolyMesh;
  33. class LLXmlTreeNode;
  34. enum ESex
  35. {
  36. SEX_FEMALE = 0x01,
  37. SEX_MALE = 0x02,
  38. SEX_BOTH = 0x03 // values chosen to allow use as a bit field.
  39. };
  40. enum EVisualParamGroup
  41. {
  42. VISUAL_PARAM_GROUP_TWEAKABLE,
  43. VISUAL_PARAM_GROUP_ANIMATABLE,
  44. VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT,
  45. NUM_VISUAL_PARAM_GROUPS
  46. };
  47. const S32 MAX_TRANSMITTED_VISUAL_PARAMS = 255;
  48. //-----------------------------------------------------------------------------
  49. // LLVisualParamInfo
  50. // Contains shared data for VisualParams
  51. //-----------------------------------------------------------------------------
  52. class LLVisualParamInfo
  53. {
  54. friend class LLVisualParam;
  55. public:
  56. LLVisualParamInfo();
  57. virtual ~LLVisualParamInfo() {};
  58. virtual BOOL parseXml(LLXmlTreeNode *node);
  59. S32 getID() const { return mID; }
  60. virtual void toStream(std::ostream &out);
  61. protected:
  62. S32 mID; // ID associated with VisualParam
  63. std::string mName; // name (for internal purposes)
  64. std::string mDisplayName; // name displayed to the user
  65. std::string mMinName; // name associated with minimum value
  66. std::string mMaxName; // name associated with maximum value
  67. EVisualParamGroup mGroup; // morph group for separating UI controls
  68. F32 mMinWeight; // minimum weight that can be assigned to this morph target
  69. F32 mMaxWeight; // maximum weight that can be assigned to this morph target
  70. F32 mDefaultWeight;
  71. ESex mSex; // Which gender(s) this param applies to.
  72. };
  73. //-----------------------------------------------------------------------------
  74. // LLVisualParam
  75. // VIRTUAL CLASS
  76. // An interface class for a generalized parametric modification of the avatar mesh
  77. // Contains data that is specific to each Avatar
  78. //-----------------------------------------------------------------------------
  79. class LLVisualParam
  80. {
  81. public:
  82. typedef boost::function<LLVisualParam*(S32)> visual_param_mapper;
  83. LLVisualParam();
  84. virtual ~LLVisualParam();
  85. // Special: These functions are overridden by child classes
  86. // (They can not be virtual because they use specific derived Info classes)
  87. LLVisualParamInfo* getInfo() const { return mInfo; }
  88. // This sets mInfo and calls initialization functions
  89. BOOL setInfo(LLVisualParamInfo *info);
  90. // Virtual functions
  91. // Pure virtuals
  92. //virtual BOOL parseData( LLXmlTreeNode *node ) = 0;
  93. virtual void apply( ESex avatar_sex ) = 0;
  94. // Default functions
  95. virtual void setWeight(F32 weight, BOOL upload_bake);
  96. virtual void setAnimationTarget( F32 target_value, BOOL upload_bake );
  97. virtual void animate(F32 delta, BOOL upload_bake);
  98. virtual void stopAnimating(BOOL upload_bake);
  99. virtual BOOL linkDrivenParams(visual_param_mapper mapper, BOOL only_cross_params);
  100. virtual void resetDrivenParams();
  101. // Interface methods
  102. S32 getID() const { return mID; }
  103. void setID(S32 id) { llassert(!mInfo); mID = id; }
  104. const std::string& getName() const { return mInfo->mName; }
  105. const std::string& getDisplayName() const { return mInfo->mDisplayName; }
  106. const std::string& getMaxDisplayName() const { return mInfo->mMaxName; }
  107. const std::string& getMinDisplayName() const { return mInfo->mMinName; }
  108. void setDisplayName(const std::string& s) { mInfo->mDisplayName = s; }
  109. void setMaxDisplayName(const std::string& s) { mInfo->mMaxName = s; }
  110. void setMinDisplayName(const std::string& s) { mInfo->mMinName = s; }
  111. EVisualParamGroup getGroup() const { return mInfo->mGroup; }
  112. F32 getMinWeight() const { return mInfo->mMinWeight; }
  113. F32 getMaxWeight() const { return mInfo->mMaxWeight; }
  114. F32 getDefaultWeight() const { return mInfo->mDefaultWeight; }
  115. ESex getSex() const { return mInfo->mSex; }
  116. F32 getWeight() const { return mIsAnimating ? mTargetWeight : mCurWeight; }
  117. F32 getCurrentWeight() const { return mCurWeight; }
  118. F32 getLastWeight() const { return mLastWeight; }
  119. BOOL isAnimating() const { return mIsAnimating; }
  120. BOOL isTweakable() const { return (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE) || (getGroup() == VISUAL_PARAM_GROUP_TWEAKABLE_NO_TRANSMIT); }
  121. LLVisualParam* getNextParam() { return mNext; }
  122. void setNextParam( LLVisualParam *next );
  123. virtual void setAnimating(BOOL is_animating) { mIsAnimating = is_animating && !mIsDummy; }
  124. BOOL getAnimating() const { return mIsAnimating; }
  125. void setIsDummy(BOOL is_dummy) { mIsDummy = is_dummy; }
  126. protected:
  127. F32 mCurWeight; // current weight
  128. F32 mLastWeight; // last weight
  129. LLVisualParam* mNext; // next param in a shared chain
  130. F32 mTargetWeight; // interpolation target
  131. BOOL mIsAnimating; // this value has been given an interpolation target
  132. BOOL mIsDummy; // this is used to prevent dummy visual params from animating
  133. S32 mID; // id for storing weight/morphtarget compares compactly
  134. LLVisualParamInfo *mInfo;
  135. };
  136. #endif // LL_LLVisualParam_H