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 
00040 class LLPolyMeshSharedData;
00041 class LLVOAvatar;
00042 class LLVector2;
00043 class LLViewerJointCollisionVolume;
00044 
00045 //-----------------------------------------------------------------------------
00046 // LLPolyMorphData()
00047 //-----------------------------------------------------------------------------
00048 class LLPolyMorphData
00049 {
00050 public:
00051         LLPolyMorphData(char *morph_name);
00052         ~LLPolyMorphData();
00053 
00054         BOOL                    loadBinary(LLFILE* fp, LLPolyMeshSharedData *mesh);
00055         char*                   loadASCII(char* text, LLPolyMeshSharedData *mesh);
00056         char*                   getName() { return mName; }
00057 
00058 public:
00059         char*                           mName;
00060 
00061         // morphology
00062         U32                                     mNumIndices;
00063         U32*                            mVertexIndices;
00064         U32                                     mCurrentIndex;
00065         LLVector3*                      mCoords;
00066         LLVector3*                      mNormals;
00067         LLVector3*                      mBinormals;
00068         LLVector2*                      mTexCoords;
00069 
00070         F32                                     mTotalDistortion;       // vertex distortion summed over entire morph
00071         F32                                     mMaxDistortion;         // maximum single vertex distortion in a given morph
00072         LLVector3                       mAvgDistortion;         // average vertex distortion, to infer directionality of the morph
00073         LLPolyMeshSharedData*   mMesh;
00074 };
00075 
00076 //-----------------------------------------------------------------------------
00077 // LLPolyVertexMask()
00078 //-----------------------------------------------------------------------------
00079 class LLPolyVertexMask
00080 {
00081 public:
00082         LLPolyVertexMask(LLPolyMorphData* morph_data);
00083         ~LLPolyVertexMask();
00084 
00085         void generateMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert, LLVector4 *clothing_weights);
00086         F32* getMorphMaskWeights();
00087 
00088 
00089 protected:
00090         F32*            mWeights;
00091         LLPolyMorphData *mMorphData;
00092         BOOL                    mWeightsGenerated;
00093 
00094 };
00095 
00096 //-----------------------------------------------------------------------------
00097 // LLPolyMorphTarget Data structs
00098 //-----------------------------------------------------------------------------
00099 struct LLPolyVolumeMorphInfo
00100 {
00101         LLPolyVolumeMorphInfo(LLString &name, LLVector3 &scale, LLVector3 &pos)
00102                 : mName(name), mScale(scale), mPos(pos) {};
00103 
00104         LLString                                                mName;
00105         LLVector3                                               mScale;
00106         LLVector3                                               mPos;
00107 };
00108 
00109 struct LLPolyVolumeMorph
00110 {
00111         LLPolyVolumeMorph(LLViewerJointCollisionVolume* volume, LLVector3 scale, LLVector3 pos)
00112                 : mVolume(volume), mScale(scale), mPos(pos) {};
00113 
00114         LLViewerJointCollisionVolume*   mVolume;
00115         LLVector3                                               mScale;
00116         LLVector3                                               mPos;
00117 };
00118 
00119 //-----------------------------------------------------------------------------
00120 // LLPolyMorphTargetInfo
00121 // Shared information for LLPolyMorphTargets
00122 //-----------------------------------------------------------------------------
00123 class LLPolyMorphTargetInfo : public LLViewerVisualParamInfo
00124 {
00125         friend class LLPolyMorphTarget;
00126 public:
00127         LLPolyMorphTargetInfo();
00128         /*virtual*/ ~LLPolyMorphTargetInfo() {};
00129         
00130         /*virtual*/ BOOL parseXml(LLXmlTreeNode* node);
00131 
00132 protected:
00133         LLString                mMorphName;
00134         BOOL                    mIsClothingMorph;
00135         typedef std::vector<LLPolyVolumeMorphInfo> volume_info_list_t;
00136         volume_info_list_t mVolumeInfoList;     
00137 };
00138 
00139 //-----------------------------------------------------------------------------
00140 // LLPolyMorphTarget
00141 // A set of vertex data associated with morph target.
00142 // These morph targets must be topologically consistent with a given Polymesh
00143 // (share face sets)
00144 //-----------------------------------------------------------------------------
00145 class LLPolyMorphTarget : public LLViewerVisualParam
00146 {
00147 public:
00148         LLPolyMorphTarget(LLPolyMesh *poly_mesh);
00149         ~LLPolyMorphTarget();
00150 
00151         // Special: These functions are overridden by child classes
00152         LLPolyMorphTargetInfo*  getInfo() const { return (LLPolyMorphTargetInfo*)mInfo; }
00153         //   This sets mInfo and calls initialization functions
00154         BOOL                                    setInfo(LLPolyMorphTargetInfo *info);
00155 
00156         // LLVisualParam Virtual functions
00158         /*virtual*/ void                                apply( ESex sex );
00159         
00160         // LLViewerVisualParam Virtual functions
00161         /*virtual*/ F32                                 getTotalDistortion();
00162         /*virtual*/ const LLVector3&    getAvgDistortion();
00163         /*virtual*/ F32                                 getMaxDistortion();
00164         /*virtual*/ LLVector3                   getVertexDistortion(S32 index, LLPolyMesh *poly_mesh);
00165         /*virtual*/ const LLVector3*    getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh);
00166         /*virtual*/ const LLVector3*    getNextDistortion(U32 *index, LLPolyMesh **poly_mesh);
00167 
00168         void    applyMask(U8 *maskData, S32 width, S32 height, S32 num_components, BOOL invert);
00169         void    addPendingMorphMask() { mNumMorphMasksPending++; }
00170 
00171 protected:
00172         LLPolyMorphData*                                mMorphData;
00173         LLPolyMesh*                                             mMesh;
00174         LLPolyVertexMask *                              mVertMask;
00175         ESex                                                    mLastSex;
00176         // number of morph masks that haven't been generated, must be 0 before this morph is applied
00177         BOOL                                                    mNumMorphMasksPending;  
00178 
00179         typedef std::vector<LLPolyVolumeMorph> volume_list_t;
00180         volume_list_t                                   mVolumeMorphs;
00181 
00182 };
00183 
00184 #endif // LL_LLPOLYMORPH_H

Generated on Fri May 16 08:33:56 2008 for SecondLife by  doxygen 1.5.5