/indra/newview/llpolymorph.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 182 lines · 100 code · 31 blank · 51 comment · 0 complexity · f768f1223226c22fee1c077340938841 MD5 · raw file

  1. /**
  2. * @file llpolymorph.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_LLPOLYMORPH_H
  27. #define LL_LLPOLYMORPH_H
  28. #include <string>
  29. #include <vector>
  30. #include "llviewervisualparam.h"
  31. class LLPolyMeshSharedData;
  32. class LLVOAvatar;
  33. class LLVector2;
  34. class LLViewerJointCollisionVolume;
  35. class LLWearable;
  36. //-----------------------------------------------------------------------------
  37. // LLPolyMorphData()
  38. //-----------------------------------------------------------------------------
  39. class LLPolyMorphData
  40. {
  41. public:
  42. LLPolyMorphData(const std::string& morph_name);
  43. ~LLPolyMorphData();
  44. LLPolyMorphData(const LLPolyMorphData &rhs);
  45. BOOL loadBinary(LLFILE* fp, LLPolyMeshSharedData *mesh);
  46. const std::string& getName() { return mName; }
  47. public:
  48. std::string mName;
  49. // morphology
  50. U32 mNumIndices;
  51. U32* mVertexIndices;
  52. U32 mCurrentIndex;
  53. LLVector3* mCoords;
  54. LLVector3* mNormals;
  55. LLVector3* mBinormals;
  56. LLVector2* mTexCoords;
  57. F32 mTotalDistortion; // vertex distortion summed over entire morph
  58. F32 mMaxDistortion; // maximum single vertex distortion in a given morph
  59. LLVector3 mAvgDistortion; // average vertex distortion, to infer directionality of the morph
  60. LLPolyMeshSharedData* mMesh;
  61. };
  62. //-----------------------------------------------------------------------------
  63. // LLPolyVertexMask()
  64. //-----------------------------------------------------------------------------
  65. class LLPolyVertexMask
  66. {
  67. public:
  68. LLPolyVertexMask(LLPolyMorphData* morph_data);
  69. ~LLPolyVertexMask();
  70. void generateMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4 *clothing_weights);
  71. F32* getMorphMaskWeights();
  72. protected:
  73. F32* mWeights;
  74. LLPolyMorphData *mMorphData;
  75. BOOL mWeightsGenerated;
  76. };
  77. //-----------------------------------------------------------------------------
  78. // LLPolyMorphTarget Data structs
  79. //-----------------------------------------------------------------------------
  80. struct LLPolyVolumeMorphInfo
  81. {
  82. LLPolyVolumeMorphInfo(std::string &name, LLVector3 &scale, LLVector3 &pos)
  83. : mName(name), mScale(scale), mPos(pos) {};
  84. std::string mName;
  85. LLVector3 mScale;
  86. LLVector3 mPos;
  87. };
  88. struct LLPolyVolumeMorph
  89. {
  90. LLPolyVolumeMorph(LLViewerJointCollisionVolume* volume, LLVector3 scale, LLVector3 pos)
  91. : mVolume(volume), mScale(scale), mPos(pos) {};
  92. LLViewerJointCollisionVolume* mVolume;
  93. LLVector3 mScale;
  94. LLVector3 mPos;
  95. };
  96. //-----------------------------------------------------------------------------
  97. // LLPolyMorphTargetInfo
  98. // Shared information for LLPolyMorphTargets
  99. //-----------------------------------------------------------------------------
  100. class LLPolyMorphTargetInfo : public LLViewerVisualParamInfo
  101. {
  102. friend class LLPolyMorphTarget;
  103. public:
  104. LLPolyMorphTargetInfo();
  105. /*virtual*/ ~LLPolyMorphTargetInfo() {};
  106. /*virtual*/ BOOL parseXml(LLXmlTreeNode* node);
  107. protected:
  108. std::string mMorphName;
  109. BOOL mIsClothingMorph;
  110. typedef std::vector<LLPolyVolumeMorphInfo> volume_info_list_t;
  111. volume_info_list_t mVolumeInfoList;
  112. };
  113. //-----------------------------------------------------------------------------
  114. // LLPolyMorphTarget
  115. // A set of vertex data associated with morph target.
  116. // These morph targets must be topologically consistent with a given Polymesh
  117. // (share face sets)
  118. //-----------------------------------------------------------------------------
  119. class LLPolyMorphTarget : public LLViewerVisualParam
  120. {
  121. public:
  122. LLPolyMorphTarget(LLPolyMesh *poly_mesh);
  123. ~LLPolyMorphTarget();
  124. // Special: These functions are overridden by child classes
  125. LLPolyMorphTargetInfo* getInfo() const { return (LLPolyMorphTargetInfo*)mInfo; }
  126. // This sets mInfo and calls initialization functions
  127. BOOL setInfo(LLPolyMorphTargetInfo *info);
  128. /*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const;
  129. // LLVisualParam Virtual functions
  130. ///*virtual*/ BOOL parseData(LLXmlTreeNode* node);
  131. /*virtual*/ void apply( ESex sex );
  132. // LLViewerVisualParam Virtual functions
  133. /*virtual*/ F32 getTotalDistortion();
  134. /*virtual*/ const LLVector3& getAvgDistortion();
  135. /*virtual*/ F32 getMaxDistortion();
  136. /*virtual*/ LLVector3 getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
  137. /*virtual*/ const LLVector3* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
  138. /*virtual*/ const LLVector3* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
  139. void applyMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert);
  140. void addPendingMorphMask() { mNumMorphMasksPending++; }
  141. protected:
  142. LLPolyMorphData* mMorphData;
  143. LLPolyMesh* mMesh;
  144. LLPolyVertexMask * mVertMask;
  145. ESex mLastSex;
  146. // number of morph masks that haven't been generated, must be 0 before this morph is applied
  147. BOOL mNumMorphMasksPending;
  148. typedef std::vector<LLPolyVolumeMorph> volume_list_t;
  149. volume_list_t mVolumeMorphs;
  150. };
  151. #endif // LL_LLPOLYMORPH_H