00001
00032 #ifndef LL_LLPOLYMORPH_H
00033 #define LL_LLPOLYMORPH_H
00034
00035 #include <string>
00036 #include <vector>
00037
00038 #include "llviewervisualparam.h"
00039 #include "llskiplist.h"
00040 #include "linked_lists.h"
00041
00042 class LLPolyMeshSharedData;
00043 class LLVOAvatar;
00044 class LLVector2;
00045 class LLViewerJointCollisionVolume;
00046
00047
00048
00049
00050 class LLPolyMorphData
00051 {
00052 public:
00053 LLPolyMorphData(char *morph_name);
00054 ~LLPolyMorphData();
00055
00056 BOOL loadBinary(FILE* fp, LLPolyMeshSharedData *mesh);
00057 char* loadASCII(char* text, LLPolyMeshSharedData *mesh);
00058 char* getName() { return mName; }
00059
00060 public:
00061 char* mName;
00062
00063
00064 U32 mNumIndices;
00065 U32* mVertexIndices;
00066 U32 mCurrentIndex;
00067 LLVector3* mCoords;
00068 LLVector3* mNormals;
00069 LLVector3* mBinormals;
00070 LLVector2* mTexCoords;
00071
00072 F32 mTotalDistortion;
00073 F32 mMaxDistortion;
00074 LLVector3 mAvgDistortion;
00075 LLPolyMeshSharedData* mMesh;
00076 };
00077
00078
00079
00080
00081 class LLPolyVertexMask
00082 {
00083 public:
00084 LLPolyVertexMask(LLPolyMorphData* morph_data);
00085 ~LLPolyVertexMask();
00086
00087 void generateMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4 *clothing_weights);
00088 F32* getMorphMaskWeights();
00089
00090
00091 protected:
00092 F32* mWeights;
00093 LLPolyMorphData *mMorphData;
00094 BOOL mWeightsGenerated;
00095
00096 };
00097
00098
00099
00100
00101 struct LLPolyVolumeMorphInfo
00102 {
00103 LLPolyVolumeMorphInfo(LLString &name, LLVector3 &scale, LLVector3 &pos)
00104 : mName(name), mScale(scale), mPos(pos) {};
00105
00106 LLString mName;
00107 LLVector3 mScale;
00108 LLVector3 mPos;
00109 };
00110
00111 struct LLPolyVolumeMorph
00112 {
00113 LLPolyVolumeMorph(LLViewerJointCollisionVolume* volume, LLVector3 scale, LLVector3 pos)
00114 : mVolume(volume), mScale(scale), mPos(pos) {};
00115
00116 LLViewerJointCollisionVolume* mVolume;
00117 LLVector3 mScale;
00118 LLVector3 mPos;
00119 };
00120
00121
00122
00123
00124
00125 class LLPolyMorphTargetInfo : public LLViewerVisualParamInfo
00126 {
00127 friend class LLPolyMorphTarget;
00128 public:
00129 LLPolyMorphTargetInfo();
00130 ~LLPolyMorphTargetInfo() {};
00131
00132 BOOL parseXml(LLXmlTreeNode* node);
00133
00134 protected:
00135 LLString mMorphName;
00136 BOOL mIsClothingMorph;
00137 typedef std::vector<LLPolyVolumeMorphInfo> volume_info_list_t;
00138 volume_info_list_t mVolumeInfoList;
00139 };
00140
00141
00142
00143
00144
00145
00146
00147 class LLPolyMorphTarget : public LLViewerVisualParam
00148 {
00149 public:
00150 LLPolyMorphTarget(LLPolyMesh *poly_mesh);
00151 ~LLPolyMorphTarget();
00152
00153
00154 LLPolyMorphTargetInfo* getInfo() const { return (LLPolyMorphTargetInfo*)mInfo; }
00155
00156 BOOL setInfo(LLPolyMorphTargetInfo *info);
00157
00158
00160 void apply( ESex sex );
00161
00162
00163 F32 getTotalDistortion();
00164 const LLVector3& getAvgDistortion();
00165 F32 getMaxDistortion();
00166 LLVector3 getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
00167 const LLVector3* getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
00168 const LLVector3* getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
00169
00170 void applyMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert);
00171 void addPendingMorphMask() { mNumMorphMasksPending++; }
00172
00173 protected:
00174 LLPolyMorphData* mMorphData;
00175 LLPolyMesh* mMesh;
00176 LLPolyVertexMask * mVertMask;
00177 ESex mLastSex;
00178
00179 BOOL mNumMorphMasksPending;
00180
00181 typedef std::vector<LLPolyVolumeMorph> volume_list_t;
00182 volume_list_t mVolumeMorphs;
00183
00184 };
00185
00186 #endif // LL_LLPOLYMORPH_H