llvisualparam.h

Go to the documentation of this file.
00001 
00032 #ifndef LL_LLVisualParam_H
00033 #define LL_LLVisualParam_H
00034 
00035 #include "v3math.h"
00036 #include "llstring.h"
00037 #include "llxmltree.h"
00038 
00039 class LLPolyMesh;
00040 class LLXmlTreeNode;
00041 
00042 enum ESex
00043 {
00044         SEX_FEMALE =    0x01,
00045         SEX_MALE =              0x02,
00046         SEX_BOTH =              0x03  // values chosen to allow use as a bit field.
00047 };
00048 
00049 enum EVisualParamGroup
00050 {
00051         VISUAL_PARAM_GROUP_TWEAKABLE,
00052         VISUAL_PARAM_GROUP_ANIMATABLE,
00053         NUM_VISUAL_PARAM_GROUPS
00054 };
00055 
00056 const S32 MAX_TRANSMITTED_VISUAL_PARAMS = 255;
00057 
00058 //-----------------------------------------------------------------------------
00059 // LLVisualParamInfo
00060 // Contains shared data for VisualParams
00061 //-----------------------------------------------------------------------------
00062 class LLVisualParamInfo
00063 {
00064         friend class LLVisualParam;
00065 public:
00066         LLVisualParamInfo();
00067         virtual ~LLVisualParamInfo() {};
00068 
00069         virtual BOOL parseXml(LLXmlTreeNode *node);
00070         
00071 protected:
00072         S32                                     mID;                            // ID associated with VisualParam
00073         
00074         LLString                        mName;                          // name (for internal purposes)
00075         LLString                        mDisplayName;           // name displayed to the user
00076         LLString                        mMinName;                       // name associated with minimum value
00077         LLString                        mMaxName;                       // name associated with maximum value
00078         EVisualParamGroup       mGroup;                         // morph group for separating UI controls
00079         F32                                     mMinWeight;                     // minimum weight that can be assigned to this morph target
00080         F32                                     mMaxWeight;                     // maximum weight that can be assigned to this morph target
00081         F32                                     mDefaultWeight;         
00082         ESex                            mSex;                           // Which gender(s) this param applies to.
00083 };
00084 
00085 //-----------------------------------------------------------------------------
00086 // LLVisualParam
00087 // VIRTUAL CLASS
00088 // An interface class for a generalized parametric modification of the avatar mesh
00089 // Contains data that is specific to each Avatar
00090 //-----------------------------------------------------------------------------
00091 class LLVisualParam
00092 {
00093 public:
00094         LLVisualParam();
00095         virtual ~LLVisualParam();
00096 
00097         // Special: These functions are overridden by child classes
00098         // (They can not be virtual because they use specific derived Info classes)
00099         LLVisualParamInfo*              getInfo() const { return mInfo; }
00100         //   This sets mInfo and calls initialization functions
00101         BOOL                                    setInfo(LLVisualParamInfo *info);
00102 
00103         // Virtual functions
00104         //  Pure virtuals
00105         //virtual BOOL                  parseData( LLXmlTreeNode *node ) = 0;
00106         virtual void                    apply( ESex avatar_sex ) = 0;
00107         //  Default functions
00108         virtual void                    setWeight(F32 weight, BOOL set_by_user);
00109         virtual void                    setAnimationTarget( F32 target_value, BOOL set_by_user );
00110         virtual void                    animate(F32 delta, BOOL set_by_user);
00111         virtual void                    stopAnimating(BOOL set_by_user);
00112 
00113         // Interface methods
00114         S32                                             getID()                         { return mID; }
00115         void                                    setID(S32 id)           { llassert(!mInfo); mID = id; }
00116         
00117         const LLString&                 getName() const                         { return mInfo->mName; }
00118         const LLString&                 getDisplayName() const          { return mInfo->mDisplayName; }
00119         const LLString&                 getMaxDisplayName() const       { return mInfo->mMaxName; }
00120         const LLString&                 getMinDisplayName() const       { return mInfo->mMinName; }
00121 
00122         void                                    setDisplayName(const LLString& s)        { mInfo->mDisplayName = s; }
00123         void                                    setMaxDisplayName(const LLString& s) { mInfo->mMaxName = s; }
00124         void                                    setMinDisplayName(const LLString& s) { mInfo->mMinName = s; }
00125 
00126         EVisualParamGroup               getGroup()                      { return mInfo->mGroup; }
00127         F32                                             getMinWeight()          { return mInfo->mMinWeight; }
00128         F32                                             getMaxWeight()          { return mInfo->mMaxWeight; }
00129         F32                                             getDefaultWeight()      { return mInfo->mDefaultWeight; }
00130         ESex                                    getSex()                        { return mInfo->mSex; }
00131 
00132         F32                                             getWeight()             { return mIsAnimating ? mTargetWeight : mCurWeight; }
00133         F32                                             getCurrentWeight()      { return mCurWeight; }
00134         F32                                             getLastWeight()         { return mLastWeight; }
00135         BOOL                                    isAnimating()   { return mIsAnimating; }
00136 
00137         LLVisualParam*                  getNextParam()          { return mNext; }
00138         void                                    setNextParam( LLVisualParam *next );
00139         
00140         virtual void                    setAnimating(BOOL is_animating) { mIsAnimating = is_animating; }
00141         BOOL                                    getAnimating() { return mIsAnimating; }
00142 
00143 protected:
00144         F32                                     mCurWeight;                     // current weight
00145         F32                                     mLastWeight;            // last weight
00146         LLVisualParam*          mNext;                          // next param in a shared chain
00147         F32                                     mTargetWeight;          // interpolation target
00148         BOOL                            mIsAnimating;   // this value has been given an interpolation target
00149 
00150         S32                                     mID;                            // id for storing weight/morphtarget compares compactly
00151         LLVisualParamInfo       *mInfo;
00152 };
00153 
00154 #endif // LL_LLVisualParam_H

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