llvoavatar.h

Go to the documentation of this file.
00001 
00033 #ifndef LL_LLVOAVATAR_H
00034 #define LL_LLVOAVATAR_H
00035 
00036 // May help Visual Studio avoid opening this file.
00037 
00038 #include <set>
00039 #include <map>
00040 #include <algorithm>
00041 #include <deque>
00042 
00043 #include "llchat.h"
00044 #include "llviewerobject.h"
00045 #include "lljointsolverrp3.h"
00046 #include "llviewerjointshape.h"
00047 #include "llviewerjointmesh.h"
00048 #include "llviewerjointattachment.h"
00049 #include "llcharacter.h"
00050 #include "material_codes.h"
00051 #include "llanimationstates.h"
00052 #include "v4coloru.h"
00053 #include "llstring.h"
00054 #include "lltrustnet.h"
00055 #include "llframetimer.h"
00056 #include "llxmltree.h"
00057 #include "llwearable.h"
00058 
00059 //Ventrella
00060 //#include "llvoiceclient.h"
00061 #include "llvoicevisualizer.h"
00062 //End Ventrella
00063 
00064 const S32 VOAVATAR_SCRATCH_TEX_WIDTH = 512;
00065 const S32 VOAVATAR_SCRATCH_TEX_HEIGHT = 512;
00066 
00067 const LLUUID ANIM_AGENT_BODY_NOISE              =       LLUUID("9aa8b0a6-0c6f-9518-c7c3-4f41f2c001ad"); //"body_noise"
00068 const LLUUID ANIM_AGENT_BREATHE_ROT     =       LLUUID("4c5a103e-b830-2f1c-16bc-224aa0ad5bc8");  //"breathe_rot"
00069 const LLUUID ANIM_AGENT_EDITING         =       LLUUID("2a8eba1d-a7f8-5596-d44a-b4977bf8c8bb");  //"editing"
00070 const LLUUID ANIM_AGENT_EYE                     =       LLUUID("5c780ea8-1cd1-c463-a128-48c023f6fbea");  //"eye"
00071 const LLUUID ANIM_AGENT_FLY_ADJUST              =       LLUUID("db95561f-f1b0-9f9a-7224-b12f71af126e");  //"fly_adjust"
00072 const LLUUID ANIM_AGENT_HAND_MOTION     =       LLUUID("ce986325-0ba7-6e6e-cc24-b17c4b795578");  //"hand_motion"
00073 const LLUUID ANIM_AGENT_HEAD_ROT                =       LLUUID("e6e8d1dd-e643-fff7-b238-c6b4b056a68d");  //"head_rot"
00074 const LLUUID ANIM_AGENT_PELVIS_FIX              =       LLUUID("0c5dd2a2-514d-8893-d44d-05beffad208b");  //"pelvis_fix"
00075 const LLUUID ANIM_AGENT_TARGET                  =       LLUUID("0e4896cb-fba4-926c-f355-8720189d5b55");  //"target"
00076 const LLUUID ANIM_AGENT_WALK_ADJUST     =       LLUUID("829bc85b-02fc-ec41-be2e-74cc6dd7215d");  //"walk_adjust"
00077 
00078 class LLChat;
00079 class LLXmlTreeNode;
00080 class LLTexLayerSet;
00081 class LLTexGlobalColor;
00082 class LLTexGlobalColorInfo;
00083 class LLTexLayerSetInfo;
00084 class LLDriverParamInfo;
00085 
00086 class LLHUDText;
00087 class LLHUDEffectSpiral;
00088 
00089 class LLVertexBufferAvatar : public LLVertexBuffer
00090 {
00091 public:
00092         LLVertexBufferAvatar();
00093         virtual void setupVertexBuffer(U32 data_mask) const;
00094 };
00095 
00096 typedef enum e_mesh_id
00097 {
00098         MESH_ID_HAIR,
00099         MESH_ID_HEAD,
00100         MESH_ID_UPPER_BODY,
00101         MESH_ID_LOWER_BODY,
00102         MESH_ID_SKIRT
00103 } eMeshID;
00104 
00105 typedef enum e_render_name
00106 {
00107         RENDER_NAME_NEVER,
00108         RENDER_NAME_FADE,
00109         RENDER_NAME_ALWAYS
00110 } eRenderName;
00111 
00112 const S32 BAKED_TEXTURE_COUNT = 5;  // number of values in ETextureIndex that are pre-composited
00113 
00114 //------------------------------------------------------------------------
00115 // LLVOAvatar Support classes
00116 //------------------------------------------------------------------------
00117 
00118 class LLVOAvatarBoneInfo
00119 {
00120         friend class LLVOAvatar;
00121         friend class LLVOAvatarSkeletonInfo;
00122 public:
00123         LLVOAvatarBoneInfo() : mIsJoint(FALSE) {}
00124         ~LLVOAvatarBoneInfo()
00125         {
00126                 std::for_each(mChildList.begin(), mChildList.end(), DeletePointer());
00127         }
00128         BOOL parseXml(LLXmlTreeNode* node);
00129         
00130 protected:
00131         LLString mName;
00132         BOOL mIsJoint;
00133         LLVector3 mPos;
00134         LLVector3 mRot;
00135         LLVector3 mScale;
00136         LLVector3 mPivot;
00137         typedef std::vector<LLVOAvatarBoneInfo*> child_list_t;
00138         child_list_t mChildList;
00139 };
00140 
00141 class LLVOAvatarSkeletonInfo
00142 {
00143         friend class LLVOAvatar;
00144 public:
00145         LLVOAvatarSkeletonInfo() :
00146                 mNumBones(0), mNumCollisionVolumes(0) {}
00147         ~LLVOAvatarSkeletonInfo()
00148         {
00149                 std::for_each(mBoneInfoList.begin(), mBoneInfoList.end(), DeletePointer());
00150         }
00151         BOOL parseXml(LLXmlTreeNode* node);
00152         S32 getNumBones() { return mNumBones; }
00153         S32 getNumCollisionVolumes() { return mNumCollisionVolumes; }
00154         
00155 protected:
00156         S32 mNumBones;
00157         S32 mNumCollisionVolumes;
00158         typedef std::vector<LLVOAvatarBoneInfo*> bone_info_list_t;
00159         bone_info_list_t mBoneInfoList;
00160 };
00161 
00162 
00163 //------------------------------------------------------------------------
00164 // LLVOAvatarInfo
00165 // One instance (in LLVOAvatar) with common data parsed from the XML files
00166 //------------------------------------------------------------------------
00167 class LLVOAvatarInfo
00168 {
00169         friend class LLVOAvatar;
00170 public:
00171         LLVOAvatarInfo();
00172         ~LLVOAvatarInfo();
00173         
00174 protected:
00175         BOOL    parseXmlSkeletonNode(LLXmlTreeNode* root);
00176         BOOL    parseXmlMeshNodes(LLXmlTreeNode* root);
00177         BOOL    parseXmlColorNodes(LLXmlTreeNode* root);
00178         BOOL    parseXmlLayerNodes(LLXmlTreeNode* root);
00179         BOOL    parseXmlDriverNodes(LLXmlTreeNode* root);
00180         
00181         struct LLVOAvatarMeshInfo
00182         {
00183                 typedef std::pair<LLPolyMorphTargetInfo*,BOOL> morph_info_pair_t;
00184                 typedef std::vector<morph_info_pair_t> morph_info_list_t;
00185 
00186                 LLVOAvatarMeshInfo() : mLOD(0), mMinPixelArea(.1f) {}
00187                 ~LLVOAvatarMeshInfo()
00188                 {
00189                         morph_info_list_t::iterator iter;
00190                         for (iter = mPolyMorphTargetInfoList.begin(); iter != mPolyMorphTargetInfoList.end(); iter++)
00191                         {
00192                                 delete iter->first;
00193                         }
00194                         mPolyMorphTargetInfoList.clear();
00195                 }
00196 
00197                 LLString        mType;
00198                 S32                     mLOD;
00199                 LLString        mMeshFileName;
00200                 LLString        mReferenceMeshName;
00201                 F32                     mMinPixelArea;
00202                 morph_info_list_t mPolyMorphTargetInfoList;
00203         };
00204         typedef std::vector<LLVOAvatarMeshInfo*> mesh_info_list_t;
00205         mesh_info_list_t mMeshInfoList;
00206 
00207         typedef std::vector<LLPolySkeletalDistortionInfo*> skeletal_distortion_info_list_t;
00208         skeletal_distortion_info_list_t mSkeletalDistortionInfoList;
00209         
00210         struct LLVOAvatarAttachmentInfo
00211         {
00212                 LLVOAvatarAttachmentInfo()
00213                         : mGroup(-1), mAttachmentID(-1), mPieMenuSlice(-1), mVisibleFirstPerson(FALSE),
00214                           mIsHUDAttachment(FALSE), mHasPosition(FALSE), mHasRotation(FALSE) {}
00215                 LLString mName;
00216                 LLString mJointName;
00217                 LLVector3 mPosition;
00218                 LLVector3 mRotationEuler;
00219                 S32 mGroup;
00220                 S32 mAttachmentID;
00221                 S32 mPieMenuSlice;
00222                 BOOL mVisibleFirstPerson;
00223                 BOOL mIsHUDAttachment;
00224                 BOOL mHasPosition;
00225                 BOOL mHasRotation;
00226         };
00227         typedef std::vector<LLVOAvatarAttachmentInfo*> attachment_info_list_t;
00228         attachment_info_list_t mAttachmentInfoList;
00229         
00230         LLTexGlobalColorInfo *mTexSkinColorInfo;
00231         LLTexGlobalColorInfo *mTexHairColorInfo;
00232         LLTexGlobalColorInfo *mTexEyeColorInfo;
00233 
00234         typedef std::vector<LLTexLayerSetInfo*> layer_info_list_t;
00235         layer_info_list_t mLayerInfoList;
00236 
00237         typedef std::vector<LLDriverParamInfo*> driver_info_list_t;
00238         driver_info_list_t mDriverInfoList;
00239 };
00240 
00241 //------------------------------------------------------------------------
00242 // LLVOAvatar
00243 //------------------------------------------------------------------------
00244 class LLVOAvatar :
00245         public LLViewerObject,
00246         public LLCharacter
00247 {
00248 protected:      
00249         virtual ~LLVOAvatar();
00250 
00251 public:
00252 
00253         struct CompareScreenAreaGreater
00254         {               
00255                 bool operator()(const LLCharacter* const& lhs, const LLCharacter* const& rhs)
00256                 {
00257                         return lhs->getPixelArea() > rhs->getPixelArea();
00258                 }
00259         };
00260 
00261         enum 
00262         {
00263                 VERTEX_DATA_MASK =      (1 << LLVertexBuffer::TYPE_VERTEX) |
00264                                                         (1 << LLVertexBuffer::TYPE_NORMAL) |
00265                                                         (1 << LLVertexBuffer::TYPE_TEXCOORD) |
00266                                                         (1 << LLVertexBuffer::TYPE_WEIGHT) |
00267                                                         (1 << LLVertexBuffer::TYPE_CLOTHWEIGHT)                                                 
00268         };
00269 
00270         LLVOAvatar(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
00271         /*virtual*/ void markDead();
00272 
00273         //--------------------------------------------------------------------
00274         // LLViewerObject interface
00275         //--------------------------------------------------------------------
00276         static void initClass();        // Initialize data that's only inited once per class.
00277         static void cleanupClass();     // Cleanup data that's only inited once per class.
00278         static BOOL parseSkeletonFile(const LLString& filename);
00279         virtual U32 processUpdateMessage(       LLMessageSystem *mesgsys,
00280                                                                                 void **user_data,
00281                                                                                 U32 block_num,
00282                                                                                 const EObjectUpdateType update_type,
00283                                                                                 LLDataPacker *dp);
00284         virtual BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
00285         virtual BOOL updateLOD();
00286         void setFootPlane(const LLVector4 &plane) { mFootPlane = plane; }
00287         /*virtual*/ BOOL    isActive() const; // Whether this object needs to do an idleUpdate.
00288 
00289         // Graphical stuff for objects - maybe broken out into render class later?
00290 
00291         U32 renderFootShadows();
00292         U32 renderRigid();
00293         U32 renderSkinned(EAvatarRenderPass pass);
00294         U32 renderTransparent();
00295         void renderCollisionVolumes();
00296         
00297         /*virtual*/ void updateTextures(LLAgent &agent);
00298         // If setting a baked texture, need to request it from a non-local sim.
00299         /*virtual*/ S32 setTETexture(const U8 te, const LLUUID& uuid);
00300         
00301         virtual U32 getPartitionType() const;
00302         
00303         void updateVisibility(BOOL force_invisible);
00304         void updateAttachmentVisibility(U32 camera_mode);
00305         void clampAttachmentPositions();
00306         S32 getAttachmentCount();       // Warning: order(N) not order(1)
00307 
00308         BOOL hasHUDAttachment();
00309         LLBBox getHUDBBox();
00310 //      void renderHUD(BOOL for_select); // old
00311         void rebuildHUD();
00312 
00313         static void updateAllAvatarVisiblity();
00314 
00315         /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
00316         /*virtual*/ BOOL                updateGeometry(LLDrawable *drawable);
00317         void updateShadowFaces();
00318 
00319         /*virtual*/ void                setPixelAreaAndAngle(LLAgent &agent);
00320         BOOL                                    updateJointLODs();
00321 
00322         void writeCAL3D(std::string& path, std::string& file_base);
00323 
00324         virtual void updateRegion(LLViewerRegion *regionp);
00325 
00326         
00327         void updateSpatialExtents(LLVector3& newMin, LLVector3 &newMax);
00328         
00329         //--------------------------------------------------------------------
00330         // texture entry assignment
00331         //--------------------------------------------------------------------
00332         enum ETextureIndex
00333         {
00334                 TEX_HEAD_BODYPAINT = 0,
00335                 TEX_UPPER_SHIRT = 1,
00336                 TEX_LOWER_PANTS = 2,
00337                 TEX_EYES_IRIS = 3,
00338                 TEX_HAIR = 4,
00339                 TEX_UPPER_BODYPAINT = 5,
00340                 TEX_LOWER_BODYPAINT = 6,
00341                 TEX_LOWER_SHOES = 7,
00342                 TEX_HEAD_BAKED = 8,                     // Pre-composited
00343                 TEX_UPPER_BAKED = 9,            // Pre-composited
00344                 TEX_LOWER_BAKED = 10,           // Pre-composited
00345                 TEX_EYES_BAKED = 11,            // Pre-composited
00346                 TEX_LOWER_SOCKS = 12,
00347                 TEX_UPPER_JACKET = 13,
00348                 TEX_LOWER_JACKET = 14,
00349                 TEX_UPPER_GLOVES = 15,
00350                 TEX_UPPER_UNDERSHIRT = 16,
00351                 TEX_LOWER_UNDERPANTS = 17,
00352                 TEX_SKIRT = 18,
00353                 TEX_SKIRT_BAKED = 19,           // Pre-composited
00354                 TEX_NUM_ENTRIES = 20
00355         };
00356         // Note: if TEX_NUM_ENTRIES changes, update AGENT_TEXTURES in llagentinfo.h, mTextureIndexBaked, and BAKED_TEXTURE_COUNT
00357 
00358         static BOOL isTextureIndexBaked( S32 i )
00359                 {
00360                         switch(i)
00361                         {
00362                         case TEX_HEAD_BAKED:
00363                         case TEX_UPPER_BAKED:
00364                         case TEX_LOWER_BAKED:
00365                         case TEX_EYES_BAKED:
00366                         case TEX_SKIRT_BAKED:
00367                                 return TRUE;
00368                         default:
00369                                 return FALSE;
00370                         }
00371                 }
00372 
00373         //--------------------------------------------------------------------
00374         // LLCharacter interface
00375         //--------------------------------------------------------------------
00376         virtual const char *getAnimationPrefix() { return "avatar"; }
00377         virtual LLJoint *getRootJoint() { return &mRoot; }
00378         virtual LLVector3 getCharacterPosition();
00379         virtual LLQuaternion getCharacterRotation();
00380         virtual LLVector3 getCharacterVelocity();
00381         virtual LLVector3 getCharacterAngularVelocity();
00382         virtual F32 getTimeDilation();
00383         virtual void getGround(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
00384         virtual BOOL allocateCharacterJoints( U32 num );
00385         virtual LLJoint *getCharacterJoint( U32 num );
00386         virtual void requestStopMotion( LLMotion* motion );
00387         virtual F32 getPixelArea() const;
00388         virtual LLPolyMesh*     getHeadMesh();
00389         virtual LLPolyMesh*     getUpperBodyMesh();
00390         virtual LLVector3d      getPosGlobalFromAgent(const LLVector3 &position);
00391         virtual LLVector3       getPosAgentFromGlobal(const LLVector3d &position);
00392         virtual void updateVisualParams();
00393         virtual BOOL startMotion(const LLUUID& id, F32 time_offset = 0.f);
00394         virtual BOOL stopMotion(const LLUUID& id, BOOL stop_immediate = FALSE);
00395         virtual void stopMotionFromSource(const LLUUID& source_id);
00396         virtual LLVector3 getVolumePos(S32 joint_index, LLVector3& volume_offset);
00397         virtual LLJoint* findCollisionVolume(U32 volume_id);
00398         virtual S32 getCollisionVolumeID(std::string &name);
00399         virtual void addDebugText(const std::string& text);
00400         virtual const LLUUID& getID();
00401         virtual LLJoint *getJoint( const std::string &name );
00402 
00403         //--------------------------------------------------------------------
00404         // Other public functions
00405         //--------------------------------------------------------------------
00406         BOOL                    allocateCollisionVolumes( U32 num );
00407         void                    resetHUDAttachments();
00408         static void             getAnimLabels( LLDynamicArray<const char*>* labels );
00409         static void             getAnimNames( LLDynamicArray<const char*>* names );
00410 
00411         static void             onCustomizeStart();
00412         static void             onCustomizeEnd();
00413 
00414         void                    getLocalTextureByteCount( S32* gl_byte_count );
00415         static void             dumpTotalLocalTextureByteCount();
00416         LLMotion*               findMotion(const LLUUID& id);
00417 
00418         BOOL                    isVisible();
00419         BOOL                    isSelf() { return mIsSelf; }
00420         BOOL                    isCulled() { return mCulled; }
00421         
00422         S32                             getUnbakedPixelAreaRank();
00423         static void             cullAvatarsByPixelArea();
00424 
00425         void                    dumpLocalTextures();
00426         const LLUUID&   grabLocalTexture(ETextureIndex index);
00427         BOOL                    canGrabLocalTexture(ETextureIndex index);
00428         void                    startAppearanceAnimation(BOOL set_by_user, BOOL play_sound);
00429 
00430         void                    setCompositeUpdatesEnabled(BOOL b);
00431 
00432         void                    addChat(const LLChat& chat);
00433         void                    clearChat();
00434         void                    startTyping() { mTyping = TRUE; mTypingTimer.reset(); }
00435         void                    stopTyping() { mTyping = FALSE; }
00436 
00437         // Returns "FirstName LastName"
00438         LLString                getFullname() const;
00439 
00440         //--------------------------------------------------------------------
00441         // internal (pseudo-private) functions
00442         //--------------------------------------------------------------------
00443         F32 getPelvisToFoot() { return mPelvisToFoot; }
00444 
00445         void buildCharacter();
00446         void releaseMeshData();
00447         void restoreMeshData();
00448         void updateMeshData();
00449 
00450         void computeBodySize();
00451 
00452         void updateCharacter(LLAgent &agent);
00453         void updateHeadOffset();
00454 
00455         LLUUID& getStepSound();
00456         void processAnimationStateChanges();
00457         BOOL processSingleAnimationStateChange(const LLUUID &anim_id, BOOL start);
00458         void resetAnimations();
00459         BOOL isAnyAnimationSignaled(const LLUUID *anim_array, const S32 num_anims);
00460 
00461         BOOL needsRenderBeam();
00462 
00463         // Utility functions
00464         void resolveHeightGlobal(const LLVector3d &inPos, LLVector3d &outPos, LLVector3 &outNorm);
00465         void resolveHeightAgent(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
00466         void resolveRayCollisionAgent(const LLVector3d start_pt, const LLVector3d end_pt, LLVector3d &out_pos, LLVector3 &out_norm);
00467 
00468         void slamPosition(); // Slam position to transmitted position (for teleport);
00469 
00470         BOOL loadAvatar();
00471         BOOL setupBone(LLVOAvatarBoneInfo* info, LLViewerJoint* parent);
00472         BOOL buildSkeleton(LLVOAvatarSkeletonInfo *info);
00473 
00474         // morph targets and such
00475         void processAvatarAppearance( LLMessageSystem* mesgsys );
00476         void onFirstTEMessageReceived();
00477         void updateSexDependentLayerSets( BOOL set_by_user );
00478         void dirtyMesh(); // Dirty the avatar mesh
00479 
00480         virtual void setParent(LLViewerObject* parent);
00481         virtual void addChild(LLViewerObject *childp);
00482         virtual void removeChild(LLViewerObject *childp);
00483 
00484         LLViewerJointAttachment* getTargetAttachmentPoint(LLViewerObject* viewer_object);
00485         BOOL attachObject(LLViewerObject *viewer_object);
00486         BOOL detachObject(LLViewerObject *viewer_object);
00487         void lazyAttach();
00488 
00489         void sitOnObject(LLViewerObject *sit_object);
00490         void getOffObject();
00491 
00492         BOOL isWearingAttachment( const LLUUID& inv_item_id );
00493         LLViewerObject* getWornAttachment( const LLUUID& inv_item_id );
00494         const LLString getAttachedPointName(const LLUUID& inv_item_id);
00495 
00496         static LLVOAvatar* findAvatarFromAttachment( LLViewerObject* obj );
00497 
00498         void                    updateMeshTextures();
00499 
00500         //--------------------------------------------------------------------
00501         // local textures for compositing.
00502         //--------------------------------------------------------------------
00503         enum ELocTexIndex
00504         {
00505                 LOCTEX_UPPER_SHIRT = 0,
00506                 LOCTEX_UPPER_BODYPAINT = 1,
00507                 LOCTEX_LOWER_PANTS = 2,
00508                 LOCTEX_LOWER_BODYPAINT = 3,
00509                 LOCTEX_HEAD_BODYPAINT = 4,
00510                 LOCTEX_LOWER_SHOES = 5,
00511                 LOCTEX_LOWER_SOCKS = 6,
00512                 LOCTEX_UPPER_JACKET = 7,
00513                 LOCTEX_LOWER_JACKET = 8,
00514                 LOCTEX_UPPER_GLOVES = 9,
00515                 LOCTEX_UPPER_UNDERSHIRT = 10,
00516                 LOCTEX_LOWER_UNDERPANTS = 11,
00517                 LOCTEX_EYES_IRIS = 12,
00518                 LOCTEX_SKIRT = 13,
00519                 LOCTEX_NUM_ENTRIES = 14
00520         };
00521 
00522         //--------------------------------------------------------------------
00523         // texture compositing (used only by the LLTexLayer series of classes)
00524         //--------------------------------------------------------------------
00525         LLColor4                getGlobalColor( const LLString& color_name );
00526         BOOL                    isLocalTextureDataAvailable( LLTexLayerSet* layerset );
00527         BOOL                    isLocalTextureDataFinal( LLTexLayerSet* layerset );
00528         ETextureIndex   getBakedTE( LLTexLayerSet* layerset );
00529         void                    updateComposites();
00530         void                    onGlobalColorChanged( LLTexGlobalColor* global_color, BOOL set_by_user );
00531         BOOL                    getLocalTextureRaw( S32 index, LLImageRaw* image_raw_pp );
00532         BOOL                    getLocalTextureGL( S32 index, LLImageGL** image_gl_pp );
00533         const LLUUID&   getLocalTextureID( S32 index );
00534         LLGLuint                getScratchTexName( LLGLenum format, U32* texture_bytes );
00535         BOOL                    bindScratchTexture( LLGLenum format );
00536         void                    invalidateComposite( LLTexLayerSet* layerset, BOOL set_by_user );
00537         void                    forceBakeAllTextures(bool slam_for_debug = false);
00538         static void             processRebakeAvatarTextures(LLMessageSystem* msg, void**);
00539         void                    setNewBakedTexture( ETextureIndex i, const LLUUID& uuid );
00540         void                    setCachedBakedTexture( ETextureIndex i, const LLUUID& uuid );
00541         void                    requestLayerSetUploads();
00542         bool                    hasPendingBakedUploads();
00543         static void             onLocalTextureLoaded( BOOL succcess, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
00544         static void             dumpArchetypeXML( void* );
00545         static void             dumpScratchTextureByteCount();
00546         static void             dumpBakedStatus();
00547         static void             deleteCachedImages();
00548         static void             destroyGL();
00549         static void             restoreGL();
00550         static void             initVertexPrograms();
00551         static void             cleanupVertexPrograms();
00552         static enum EWearableType       getTEWearableType( S32 te );
00553         static LLUUID                   getDefaultTEImageID( S32 te );
00554 
00555         //--------------------------------------------------------------------
00556         // Clothing colors (conventience functions to access visual parameters
00557         //--------------------------------------------------------------------
00558         void                    setClothesColor( ETextureIndex te, const LLColor4& new_color, BOOL set_by_user );
00559         LLColor4                getClothesColor( ETextureIndex te );
00560         BOOL                    teToColorParams( ETextureIndex te, const char* param_name[3] );
00561 
00562         BOOL                    isWearingWearableType( EWearableType type );
00563 
00564         //--------------------------------------------------------------------
00565         // texture compositing
00566         //--------------------------------------------------------------------
00567         void                    setLocTexTE( U8 te, LLViewerImage* image, BOOL set_by_user );
00568         void                    setupComposites();
00569 
00570         //--------------------------------------------------------------------
00571         // member variables
00572         //--------------------------------------------------------------------
00573 
00574         BOOL mDirtyMesh;
00575 
00576         LLFace *mShadow0Facep;
00577         LLFace *mShadow1Facep;
00578 
00579         LLFrameTimer mUpdateLODTimer; // controls frequency of LOD change calculations
00580         
00581         //--------------------------------------------------------------------
00582         // State of deferred character building
00583         //--------------------------------------------------------------------
00584         BOOL mIsBuilt;
00585 
00586         //--------------------------------------------------------------------
00587         // avatar definition name
00588         //--------------------------------------------------------------------
00589         char mAvatarDefinition[64];             /* Flawfinder: ignore */
00590 
00591         //--------------------------------------------------------------------
00592         // skeleton for skinned avatar
00593         //--------------------------------------------------------------------
00594         S32                             mNumJoints;
00595         LLViewerJoint   *mSkeleton;
00596 
00597         S32                                                             mNumCollisionVolumes;
00598         LLViewerJointCollisionVolume*   mCollisionVolumes;
00599 
00600         //--------------------------------------------------------------------
00601         // cached pointers to well known joints
00602         //--------------------------------------------------------------------
00603         LLViewerJoint *mPelvisp;
00604         LLViewerJoint *mTorsop;
00605         LLViewerJoint *mChestp;
00606         LLViewerJoint *mNeckp;
00607         LLViewerJoint *mHeadp;
00608         LLViewerJoint *mSkullp;
00609         LLViewerJoint *mEyeLeftp;
00610         LLViewerJoint *mEyeRightp;
00611         LLViewerJoint *mHipLeftp;
00612         LLViewerJoint *mHipRightp;
00613         LLViewerJoint *mKneeLeftp;
00614         LLViewerJoint *mKneeRightp;
00615         LLViewerJoint *mAnkleLeftp;
00616         LLViewerJoint *mAnkleRightp;
00617         LLViewerJoint *mFootLeftp;
00618         LLViewerJoint *mFootRightp;
00619         LLViewerJoint *mWristLeftp;
00620         LLViewerJoint *mWristRightp;
00621 
00622         //--------------------------------------------------------------------
00623         // special purpose joint for HUD attachments
00624         //--------------------------------------------------------------------
00625         LLViewerJoint *mScreenp;
00626         F32                             mHUDTargetZoom;
00627         F32                             mHUDCurZoom;
00628 
00629         //--------------------------------------------------------------------
00630         // mesh objects for skinned avatar
00631         //--------------------------------------------------------------------
00632         LLViewerJoint           mHairLOD;
00633         LLViewerJointMesh               mHairMesh0;
00634         LLViewerJointMesh               mHairMesh1;
00635         LLViewerJointMesh               mHairMesh2;
00636         LLViewerJointMesh               mHairMesh3;
00637         LLViewerJointMesh               mHairMesh4;
00638         LLViewerJointMesh               mHairMesh5;
00639 
00640         LLViewerJoint           mHeadLOD;
00641         LLViewerJointMesh               mHeadMesh0;
00642         LLViewerJointMesh               mHeadMesh1;
00643         LLViewerJointMesh               mHeadMesh2;
00644         LLViewerJointMesh               mHeadMesh3;
00645         LLViewerJointMesh               mHeadMesh4;
00646 
00647         LLViewerJoint           mEyeLashLOD;
00648         LLViewerJointMesh               mEyeLashMesh0;
00649 
00650         LLViewerJoint           mUpperBodyLOD;
00651         LLViewerJointMesh               mUpperBodyMesh0;
00652         LLViewerJointMesh               mUpperBodyMesh1;
00653         LLViewerJointMesh               mUpperBodyMesh2;
00654         LLViewerJointMesh               mUpperBodyMesh3;
00655         LLViewerJointMesh               mUpperBodyMesh4;
00656 
00657         LLViewerJoint           mLowerBodyLOD;
00658         LLViewerJointMesh               mLowerBodyMesh0;
00659         LLViewerJointMesh               mLowerBodyMesh1;
00660         LLViewerJointMesh               mLowerBodyMesh2;
00661         LLViewerJointMesh               mLowerBodyMesh3;
00662         LLViewerJointMesh               mLowerBodyMesh4;
00663 
00664         LLViewerJoint           mEyeBallLeftLOD;
00665         LLViewerJointMesh               mEyeBallLeftMesh0;
00666         LLViewerJointMesh               mEyeBallLeftMesh1;
00667 
00668         LLViewerJoint           mEyeBallRightLOD;
00669         LLViewerJointMesh               mEyeBallRightMesh0;
00670         LLViewerJointMesh               mEyeBallRightMesh1;
00671 
00672         LLViewerJoint           mSkirtLOD;
00673         LLViewerJointMesh               mSkirtMesh0;
00674         LLViewerJointMesh               mSkirtMesh1;
00675         LLViewerJointMesh               mSkirtMesh2;
00676         LLViewerJointMesh               mSkirtMesh3;
00677         LLViewerJointMesh               mSkirtMesh4;
00678 
00679         typedef std::multimap<LLString, LLPolyMesh*> mesh_map_t;
00680         mesh_map_t                              mMeshes;
00681 
00682         //--------------------------------------------------------------------
00683         // true if this avatar is for this viewers agent
00684         //--------------------------------------------------------------------
00685         BOOL                    mIsSelf;
00686 
00687         //--------------------------------------------------------------------
00688         // texture ids and pointers
00689         //--------------------------------------------------------------------
00690         LLUUID                  mShadowImageID;
00691         LLPointer<LLViewerImage> mShadowImagep;
00692 
00693         LLUUID                  mLastHeadBakedID;
00694         LLUUID                  mLastUpperBodyBakedID;
00695         LLUUID                  mLastLowerBodyBakedID;
00696         LLUUID                  mLastEyesBakedID;
00697         LLUUID                  mLastSkirtBakedID;
00698 
00699         //--------------------------------------------------------------------
00700         // Misc Render State
00701         //--------------------------------------------------------------------
00702         BOOL                    mIsDummy; // For special views
00703         S32                             mSpecialRenderMode; // Special lighting
00704 
00705         //--------------------------------------------------------------------
00706         // Animation timer
00707         //--------------------------------------------------------------------
00708         LLTimer         mAnimTimer;
00709         F32                     mTimeLast;
00710 
00711         //--------------------------------------------------------------------
00712         // Measures speed (for diagnostics mostly).
00713         //--------------------------------------------------------------------
00714         F32 mSpeedAccum;
00715 
00716         //--------------------------------------------------------------------
00717         // animation state data
00718         //--------------------------------------------------------------------
00719         typedef std::map<LLUUID, S32>::iterator AnimIterator;
00720 
00721         std::map<LLUUID, S32> mSignaledAnimations;              // requested state of Animation name/value
00722         std::map<LLUUID, S32> mPlayingAnimations;               // current state of Animation name/value
00723 
00724         typedef std::multimap<LLUUID, LLUUID> AnimationSourceMap;
00725         typedef AnimationSourceMap::iterator AnimSourceIterator;
00726         AnimationSourceMap mAnimationSources;   // object ids that triggered anim ids
00727 
00728         BOOL                            mTurning;               // controls hysteresis on avatar rotation
00729 
00730         //--------------------------------------------------------------------
00731         // misc. animation related state
00732         //--------------------------------------------------------------------
00733         F32                             mSpeed;
00734 
00735         //
00736         // Shadow stuff
00737         //
00738         LLDrawable*             mShadow;
00739         BOOL                    mInAir;
00740         LLFrameTimer    mTimeInAir;
00741 
00742         //--------------------------------------------------------------------
00743         // Keeps track of foot step state for generating sounds
00744         //--------------------------------------------------------------------
00745         BOOL                    mWasOnGroundLeft;
00746         BOOL                    mWasOnGroundRight;
00747         LLVector4               mFootPlane;
00748 
00749         //--------------------------------------------------------------------
00750         // Keep track of the material being stepped on
00751         //--------------------------------------------------------------------
00752         BOOL                    mStepOnLand;
00753         U8                              mStepMaterial;
00754         LLVector3               mStepObjectVelocity;
00755 
00756         //--------------------------------------------------------------------
00757         // Pelvis height adjustment members.
00758         //--------------------------------------------------------------------
00759         F32                             mPelvisToFoot;
00760         LLVector3               mBodySize;
00761         S32                             mLastSkeletonSerialNum;
00762 
00763         //--------------------------------------------------------------------
00764         // current head position
00765         //--------------------------------------------------------------------
00766         LLVector3               mHeadOffset;
00767 
00768         //--------------------------------------------------------------------
00769         // avatar skeleton
00770         //--------------------------------------------------------------------
00771         LLViewerJoint   mRoot;
00772 
00773         //--------------------------------------------------------------------
00774         // sitting state
00775         //--------------------------------------------------------------------
00776         BOOL                    mIsSitting;
00777 
00778         //--------------------------------------------------------------------
00779         // Display the name, then optionally fade it out
00780         //--------------------------------------------------------------------
00781         LLFrameTimer                            mTimeVisible;
00782         LLPointer<LLHUDText>            mNameText;
00783         std::deque<LLChat>                      mChats;
00784         LLFrameTimer                            mChatTimer;
00785         BOOL                                            mTyping;
00786         LLFrameTimer                            mTypingTimer;
00787 
00788         //--------------------------------------------------------------------
00789         // destroy mesh data after being invisible for a while
00790         //--------------------------------------------------------------------
00791         BOOL                    mMeshValid;
00792         BOOL                    mVisible;
00793         LLFrameTimer    mMeshInvisibleTime;
00794 
00795         //--------------------------------------------------------------------
00796         // wind rippling in clothes
00797         //--------------------------------------------------------------------
00798         LLVector4               mWindVec;
00799         F32                             mWindFreq;
00800         F32                             mRipplePhase;
00801         LLFrameTimer    mRippleTimer;
00802         F32                             mRippleTimeLast;
00803         LLVector3               mRippleAccel;
00804         LLVector3               mLastVel;
00805         BOOL                    mBelowWater;
00806 
00807         //--------------------------------------------------------------------
00808         // appearance morphing
00809         //--------------------------------------------------------------------
00810         LLFrameTimer    mAppearanceMorphTimer;
00811         BOOL                    mAppearanceAnimSetByUser;
00812         F32                             mLastAppearanceBlendTime;
00813         BOOL                    mAppearanceAnimating;
00814 
00815         //--------------------------------------------------------------------
00816         // static members
00817         //--------------------------------------------------------------------
00818         static S32              sMaxVisible;
00819         static S32              sCurJoint;
00820         static S32              sCurVolume;
00821         static BOOL             sShowAnimationDebug; // show animation debug info
00822         static BOOL             sShowFootPlane; // show foot collision plane reported by server
00823         static BOOL             sShowCollisionVolumes;  // show skeletal collision volumes
00824         static BOOL             sVisibleInFirstPerson;
00825 
00826         static S32              sMaxOtherAvatarsToComposite;
00827 
00828         static S32              sNumLODChangesThisFrame;
00829 
00830         // global table of sound ids per material, and the ground
00831         static LLUUID   sStepSounds[LL_MCODE_END];
00832         static LLUUID   sStepSoundOnLand;
00833 
00834         static S32              sRenderName;
00835         static BOOL             sRenderGroupTitles;
00836         static S32              sNumVisibleChatBubbles;
00837         static BOOL             sDebugInvisible;
00838         static BOOL             sShowAttachmentPoints;
00839 
00840         // Number of instances of this class
00841         static S32              sNumVisibleAvatars;
00842 
00843         // Scratch textures used for compositing
00844         static LLMap< LLGLenum, LLGLuint*> sScratchTexNames;
00845         static LLMap< LLGLenum, F32*> sScratchTexLastBindTime;
00846         static S32 sScratchTexBytes;
00847 
00848         // map of attachment points, by ID
00849         LLPtrSkipMap<S32, LLViewerJointAttachment*> mAttachmentPoints;
00850 
00851         // xml parse tree of avatar config file
00852         static LLXmlTree sXMLTree;
00853         // xml parse tree of avatar skeleton file
00854         static LLXmlTree sSkeletonXMLTree;
00855 
00856         // number of avatar duplicates, for debugging purposes
00857         static BOOL             sAvatarLoadTest;
00858 
00859         // user-settable LOD factor
00860         static F32              sLODFactor;
00861 
00862         // output total number of joints being touched for each avatar
00863         static BOOL             sJointDebug;
00864         static ETextureIndex sBakedTextureIndices[BAKED_TEXTURE_COUNT];
00865 
00866         //--------------------------------------------------------------------
00867         // Texture Layer Sets and Global Colors
00868         //--------------------------------------------------------------------  
00869         LLTexLayerSet*          mHeadLayerSet;
00870         LLTexLayerSet*          mUpperBodyLayerSet;
00871         LLTexLayerSet*          mLowerBodyLayerSet;
00872         LLTexLayerSet*          mEyesLayerSet;
00873         LLTexLayerSet*          mSkirtLayerSet;
00874 
00875 
00876 protected:
00877         LLPointer<LLHUDEffectSpiral> mBeam;
00878         LLFrameTimer mBeamTimer;
00879         LLFrameTimer mEditEffectTimer;
00880 
00881         F32             mRenderPriority;
00882         F32             mAdjustedPixelArea;
00883 
00884         LLWString mNameString;
00885         LLString  mTitle;
00886         BOOL      mNameAway;
00887         BOOL      mNameBusy;
00888         BOOL      mNameMute;
00889         BOOL      mNameAppearance;
00890         BOOL      mVisibleChat;
00891 
00892         BOOL mTrustNetTitleEnabled;
00893         ETrustNetState  mTrustNetState;
00894         ETrustNetDatumState     mTrustNetScoreState;
00895 
00896         LLString  mDebugText;
00897         U64               mLastRegionHandle;
00898         LLFrameTimer mRegionCrossingTimer;
00899         S32               mRegionCrossingCount;
00900         
00901         //--------------------------------------------------------------------
00902         // local textures for compositing.
00903         //--------------------------------------------------------------------
00904 
00905         LLPointer<LLViewerImage> mLocalTexture[ LOCTEX_NUM_ENTRIES ];
00906         BOOL                            mLocalTextureBaked[ LOCTEX_NUM_ENTRIES ]; // Texture is covered by a baked texture
00907         S32                             mLocalTextureDiscard[ LOCTEX_NUM_ENTRIES ];
00908         LLUUID                          mSavedTE[ TEX_NUM_ENTRIES ];
00909         BOOL                            mFirstTEMessageReceived;
00910         BOOL                            mFirstAppearanceMessageReceived;
00911 
00912         BOOL                            mHeadBakedLoaded;
00913         S32                                     mHeadMaskDiscard;
00914         BOOL                            mUpperBakedLoaded;
00915         S32                                     mUpperMaskDiscard;
00916         BOOL                            mLowerBakedLoaded;
00917         S32                                     mLowerMaskDiscard;
00918         BOOL                            mEyesBakedLoaded;
00919         BOOL                            mSkirtBakedLoaded;
00920 
00921         //RN: testing 2 pass rendering
00922         U32                                     mHeadMaskTexName;
00923         U32                                     mUpperMaskTexName;
00924         U32                                     mLowerMaskTexName;
00925 
00926         BOOL                            mCulled;
00927         F32                                     mMinPixelArea; // debug
00928         F32                                     mMaxPixelArea; // debug
00929         
00930         //--------------------------------------------------------------------
00931         // Global Colors
00932         //--------------------------------------------------------------------
00933         LLTexGlobalColor*       mTexSkinColor;
00934         LLTexGlobalColor*       mTexHairColor;
00935         LLTexGlobalColor*       mTexEyeColor;
00936 
00937         static LLVOAvatarSkeletonInfo*  sSkeletonInfo;
00938         static LLVOAvatarInfo*                  sAvatarInfo;
00939         
00940 protected:
00941 
00942         BOOL                    loadSkeletonNode();
00943         BOOL                    loadMeshNodes();
00944         
00945         BOOL                    isFullyBaked();
00946         void                    deleteLayerSetCaches();
00947         static BOOL             areAllNearbyInstancesBaked();
00948 
00949         static void             onBakedTextureMasksLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
00950 
00951         void                    setLocalTexture(ELocTexIndex i, LLViewerImage* tex, BOOL baked_version_exits);
00952         
00953         void                    requestLayerSetUpdate(LLVOAvatar::ELocTexIndex i);
00954         void                    addLocalTextureStats(LLVOAvatar::ELocTexIndex i, LLViewerImage* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked);
00955         void                    addBakedTextureStats( LLViewerImage* imagep, F32 pixel_area, F32 texel_area_ratio, S32 boost_level);
00956         static void             onInitialBakedTextureLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
00957         static void             onBakedTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
00958         void                    useBakedTexture(const LLUUID& id);
00959         void                    dumpAvatarTEs(const char* context);
00960         void                    removeMissingBakedTextures();
00961         LLTexLayerSet*  getLayerSet(ETextureIndex index) const;
00962         LLHost                  getObjectHost() const;
00963         S32                             getLocalDiscardLevel( S32 index);
00964         
00965 //Ventrella
00966         //-----------------------------------------------------------------------------------------------
00967         // the Voice Visualizer is responsible for detecting the user's voice signal, and when the
00968         // user speaks, it puts a voice symbol over the avatar's head, and triggering gesticulations
00969         //-----------------------------------------------------------------------------------------------
00970         private:
00971         LLVoiceVisualizer * mVoiceVisualizer;
00972         int                                     mCurrentGesticulationLevel;
00973 //End Ventrella
00974         
00975 };
00976 
00977 #endif // LL_VO_AVATAR_H

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