llpolymorph.h

Go to the documentation of this file.
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 // LLPolyMorphData()
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         // morphology
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;       // vertex distortion summed over entire morph
00073         F32                                     mMaxDistortion;         // maximum single vertex distortion in a given morph
00074         LLVector3                       mAvgDistortion;         // average vertex distortion, to infer directionality of the morph
00075         LLPolyMeshSharedData*   mMesh;
00076 };
00077 
00078 //-----------------------------------------------------------------------------
00079 // LLPolyVertexMask()
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 // LLPolyMorphTarget Data structs
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 // LLPolyMorphTargetInfo
00123 // Shared information for LLPolyMorphTargets
00124 //-----------------------------------------------------------------------------
00125 class LLPolyMorphTargetInfo : public LLViewerVisualParamInfo
00126 {
00127         friend class LLPolyMorphTarget;
00128 public:
00129         LLPolyMorphTargetInfo();
00130         /*virtual*/ ~LLPolyMorphTargetInfo() {};
00131         
00132         /*virtual*/ 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 // LLPolyMorphTarget
00143 // A set of vertex data associated with morph target.
00144 // These morph targets must be topologically consistent with a given Polymesh
00145 // (share face sets)
00146 //-----------------------------------------------------------------------------
00147 class LLPolyMorphTarget : public LLViewerVisualParam
00148 {
00149 public:
00150         LLPolyMorphTarget(LLPolyMesh *poly_mesh);
00151         ~LLPolyMorphTarget();
00152 
00153         // Special: These functions are overridden by child classes
00154         LLPolyMorphTargetInfo*  getInfo() const { return (LLPolyMorphTargetInfo*)mInfo; }
00155         //   This sets mInfo and calls initialization functions
00156         BOOL                                    setInfo(LLPolyMorphTargetInfo *info);
00157 
00158         // LLVisualParam Virtual functions
00160         /*virtual*/ void                                apply( ESex sex );
00161         
00162         // LLViewerVisualParam Virtual functions
00163         /*virtual*/ F32                                 getTotalDistortion();
00164         /*virtual*/ const LLVector3&    getAvgDistortion();
00165         /*virtual*/ F32                                 getMaxDistortion();
00166         /*virtual*/ LLVector3                   getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
00167         /*virtual*/ const LLVector3*    getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
00168         /*virtual*/ 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         // number of morph masks that haven't been generated, must be 0 before this morph is applied
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

Generated on Thu Jul 1 06:09:01 2010 for Second Life Viewer by  doxygen 1.4.7