PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lldriverparam.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 128 lines | 72 code | 22 blank | 34 comment | 0 complexity | ba0f9975747e27d4bae346de07df5501 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lldriverparam.h
  3. * @brief A visual parameter that drives (controls) other visual parameters.
  4. *
  5. * $LicenseInfo:firstyear=2002&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_LLDRIVERPARAM_H
  27. #define LL_LLDRIVERPARAM_H
  28. #include "llviewervisualparam.h"
  29. #include "llwearabletype.h"
  30. class LLPhysicsMotion;
  31. class LLVOAvatar;
  32. class LLWearable;
  33. //-----------------------------------------------------------------------------
  34. struct LLDrivenEntryInfo
  35. {
  36. LLDrivenEntryInfo( S32 id, F32 min1, F32 max1, F32 max2, F32 min2 )
  37. : mDrivenID( id ), mMin1( min1 ), mMax1( max1 ), mMax2( max2 ), mMin2( min2 ) {}
  38. S32 mDrivenID;
  39. F32 mMin1;
  40. F32 mMax1;
  41. F32 mMax2;
  42. F32 mMin2;
  43. };
  44. struct LLDrivenEntry
  45. {
  46. LLDrivenEntry( LLViewerVisualParam* param, LLDrivenEntryInfo *info )
  47. : mParam( param ), mInfo( info ) {}
  48. LLViewerVisualParam* mParam;
  49. LLDrivenEntryInfo* mInfo;
  50. };
  51. //-----------------------------------------------------------------------------
  52. class LLDriverParamInfo : public LLViewerVisualParamInfo
  53. {
  54. friend class LLDriverParam;
  55. public:
  56. LLDriverParamInfo();
  57. /*virtual*/ ~LLDriverParamInfo() {};
  58. /*virtual*/ BOOL parseXml(LLXmlTreeNode* node);
  59. /*virtual*/ void toStream(std::ostream &out);
  60. protected:
  61. typedef std::deque<LLDrivenEntryInfo> entry_info_list_t;
  62. entry_info_list_t mDrivenInfoList;
  63. };
  64. //-----------------------------------------------------------------------------
  65. class LLDriverParam : public LLViewerVisualParam
  66. {
  67. friend class LLPhysicsMotion; // physics motion needs to access driven params directly.
  68. public:
  69. LLDriverParam(LLVOAvatar *avatarp);
  70. LLDriverParam(LLWearable *wearablep);
  71. ~LLDriverParam();
  72. // Special: These functions are overridden by child classes
  73. LLDriverParamInfo* getInfo() const { return (LLDriverParamInfo*)mInfo; }
  74. // This sets mInfo and calls initialization functions
  75. BOOL setInfo(LLDriverParamInfo *info);
  76. void setWearable(LLWearable *wearablep);
  77. void setAvatar(LLVOAvatar *avatarp);
  78. void updateCrossDrivenParams(LLWearableType::EType driven_type);
  79. /*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const;
  80. // LLVisualParam Virtual functions
  81. ///*virtual*/ BOOL parseData(LLXmlTreeNode* node);
  82. /*virtual*/ void apply( ESex sex ) {} // apply is called separately for each driven param.
  83. /*virtual*/ void setWeight(F32 weight, BOOL upload_bake);
  84. /*virtual*/ void setAnimationTarget( F32 target_value, BOOL upload_bake );
  85. /*virtual*/ void stopAnimating(BOOL upload_bake);
  86. /*virtual*/ BOOL linkDrivenParams(visual_param_mapper mapper, BOOL only_cross_params);
  87. /*virtual*/ void resetDrivenParams();
  88. // LLViewerVisualParam Virtual functions
  89. /*virtual*/ F32 getTotalDistortion();
  90. /*virtual*/ const LLVector3& getAvgDistortion();
  91. /*virtual*/ F32 getMaxDistortion();
  92. /*virtual*/ LLVector3 getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
  93. /*virtual*/ const LLVector3* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
  94. /*virtual*/ const LLVector3* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
  95. protected:
  96. F32 getDrivenWeight(const LLDrivenEntry* driven, F32 input_weight);
  97. void setDrivenWeight(LLDrivenEntry *driven, F32 driven_weight, bool upload_bake);
  98. LLVector3 mDefaultVec; // temp holder
  99. typedef std::vector<LLDrivenEntry> entry_list_t;
  100. entry_list_t mDriven;
  101. LLViewerVisualParam* mCurrentDistortionParam;
  102. // Backlink only; don't make this an LLPointer.
  103. LLVOAvatar* mAvatarp;
  104. LLWearable* mWearablep;
  105. };
  106. #endif // LL_LLDRIVERPARAM_H