aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llvoavatar.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llvoavatar.h
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llvoavatar.h916
1 files changed, 916 insertions, 0 deletions
diff --git a/linden/indra/newview/llvoavatar.h b/linden/indra/newview/llvoavatar.h
new file mode 100644
index 0000000..f942273
--- /dev/null
+++ b/linden/indra/newview/llvoavatar.h
@@ -0,0 +1,916 @@
1/**
2 * @file llvoavatar.h
3 * @brief Declaration of LLVOAvatar class which is a derivation fo
4 * LLViewerObject
5 *
6 * Copyright (c) 2001-2007, Linden Research, Inc.
7 *
8 * The source code in this file ("Source Code") is provided by Linden Lab
9 * to you under the terms of the GNU General Public License, version 2.0
10 * ("GPL"), unless you have obtained a separate licensing agreement
11 * ("Other License"), formally executed by you and Linden Lab. Terms of
12 * the GPL can be found in doc/GPL-license.txt in this distribution, or
13 * online at http://secondlife.com/developers/opensource/gplv2
14 *
15 * There are special exceptions to the terms and conditions of the GPL as
16 * it is applied to this Source Code. View the full text of the exception
17 * in the file doc/FLOSS-exception.txt in this software distribution, or
18 * online at http://secondlife.com/developers/opensource/flossexception
19 *
20 * By copying, modifying or distributing this software, you acknowledge
21 * that you have read and understood your obligations described above,
22 * and agree to abide by those obligations.
23 *
24 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
25 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
26 * COMPLETENESS OR PERFORMANCE.
27 */
28
29#ifndef LL_LLVOAVATAR_H
30#define LL_LLVOAVATAR_H
31
32// May help Visual Studio avoid opening this file.
33
34#include <set>
35#include <map>
36#include <algorithm>
37#include <deque>
38
39#include "llchat.h"
40#include "llviewerobject.h"
41#include "lljointsolverrp3.h"
42#include "llviewerjointshape.h"
43#include "llviewerjointmesh.h"
44#include "llviewerjointattachment.h"
45#include "llcharacter.h"
46#include "material_codes.h"
47#include "llanimationstates.h"
48#include "v4coloru.h"
49#include "llstring.h"
50#include "llframetimer.h"
51#include "llxmltree.h"
52#include "llwearable.h"
53
54const S32 VOAVATAR_SCRATCH_TEX_WIDTH = 512;
55const S32 VOAVATAR_SCRATCH_TEX_HEIGHT = 512;
56
57const LLUUID ANIM_AGENT_BODY_NOISE = LLUUID("9aa8b0a6-0c6f-9518-c7c3-4f41f2c001ad"); //"body_noise"
58const LLUUID ANIM_AGENT_BREATHE_ROT = LLUUID("4c5a103e-b830-2f1c-16bc-224aa0ad5bc8"); //"breathe_rot"
59const LLUUID ANIM_AGENT_EDITING = LLUUID("2a8eba1d-a7f8-5596-d44a-b4977bf8c8bb"); //"editing"
60const LLUUID ANIM_AGENT_EYE = LLUUID("5c780ea8-1cd1-c463-a128-48c023f6fbea"); //"eye"
61const LLUUID ANIM_AGENT_FLY_ADJUST = LLUUID("db95561f-f1b0-9f9a-7224-b12f71af126e"); //"fly_adjust"
62const LLUUID ANIM_AGENT_HAND_MOTION = LLUUID("ce986325-0ba7-6e6e-cc24-b17c4b795578"); //"hand_motion"
63const LLUUID ANIM_AGENT_HEAD_ROT = LLUUID("e6e8d1dd-e643-fff7-b238-c6b4b056a68d"); //"head_rot"
64const LLUUID ANIM_AGENT_PELVIS_FIX = LLUUID("0c5dd2a2-514d-8893-d44d-05beffad208b"); //"pelvis_fix"
65const LLUUID ANIM_AGENT_TARGET = LLUUID("0e4896cb-fba4-926c-f355-8720189d5b55"); //"target"
66const LLUUID ANIM_AGENT_WALK_ADJUST = LLUUID("829bc85b-02fc-ec41-be2e-74cc6dd7215d"); //"walk_adjust"
67
68class LLChat;
69class LLXmlTreeNode;
70class LLTexLayerSet;
71class LLTexGlobalColor;
72class LLTexGlobalColorInfo;
73class LLTexLayerSetInfo;
74class LLDriverParamInfo;
75
76class LLHUDText;
77class LLHUDEffectSpiral;
78
79typedef enum e_mesh_id
80{
81 MESH_ID_HAIR,
82 MESH_ID_HEAD,
83 MESH_ID_UPPER_BODY,
84 MESH_ID_LOWER_BODY,
85 MESH_ID_SKIRT
86} eMeshID;
87
88typedef enum e_render_name
89{
90 RENDER_NAME_NEVER,
91 RENDER_NAME_FADE,
92 RENDER_NAME_ALWAYS
93} eRenderName;
94
95const S32 BAKED_TEXTURE_COUNT = 5; // number of values in ETextureIndex that are pre-composited
96
97//------------------------------------------------------------------------
98// LLVOAvatar Support classes
99//------------------------------------------------------------------------
100
101class LLVOAvatarBoneInfo
102{
103 friend class LLVOAvatar;
104 friend class LLVOAvatarSkeletonInfo;
105public:
106 LLVOAvatarBoneInfo() : mIsJoint(FALSE) {}
107 ~LLVOAvatarBoneInfo()
108 {
109 std::for_each(mChildList.begin(), mChildList.end(), DeletePointer());
110 }
111 BOOL parseXml(LLXmlTreeNode* node);
112
113protected:
114 LLString mName;
115 BOOL mIsJoint;
116 LLVector3 mPos;
117 LLVector3 mRot;
118 LLVector3 mScale;
119 LLVector3 mPivot;
120 typedef std::vector<LLVOAvatarBoneInfo*> child_list_t;
121 child_list_t mChildList;
122};
123
124class LLVOAvatarSkeletonInfo
125{
126 friend class LLVOAvatar;
127public:
128 LLVOAvatarSkeletonInfo() :
129 mNumBones(0), mNumCollisionVolumes(0) {}
130 ~LLVOAvatarSkeletonInfo()
131 {
132 std::for_each(mBoneInfoList.begin(), mBoneInfoList.end(), DeletePointer());
133 }
134 BOOL parseXml(LLXmlTreeNode* node);
135 S32 getNumBones() { return mNumBones; }
136 S32 getNumCollisionVolumes() { return mNumCollisionVolumes; }
137
138protected:
139 S32 mNumBones;
140 S32 mNumCollisionVolumes;
141 typedef std::vector<LLVOAvatarBoneInfo*> bone_info_list_t;
142 bone_info_list_t mBoneInfoList;
143};
144
145
146//------------------------------------------------------------------------
147// LLVOAvatarInfo
148// One instance (in LLVOAvatar) with common data parsed from the XML files
149//------------------------------------------------------------------------
150class LLVOAvatarInfo
151{
152 friend class LLVOAvatar;
153public:
154 LLVOAvatarInfo();
155 ~LLVOAvatarInfo();
156
157protected:
158 BOOL parseXmlSkeletonNode(LLXmlTreeNode* root);
159 BOOL parseXmlMeshNodes(LLXmlTreeNode* root);
160 BOOL parseXmlColorNodes(LLXmlTreeNode* root);
161 BOOL parseXmlLayerNodes(LLXmlTreeNode* root);
162 BOOL parseXmlDriverNodes(LLXmlTreeNode* root);
163
164 struct LLVOAvatarMeshInfo
165 {
166 typedef std::pair<LLPolyMorphTargetInfo*,BOOL> morph_info_pair_t;
167 typedef std::vector<morph_info_pair_t> morph_info_list_t;
168
169 LLVOAvatarMeshInfo() : mLOD(0), mMinPixelArea(.1f) {}
170 ~LLVOAvatarMeshInfo()
171 {
172 morph_info_list_t::iterator iter;
173 for (iter = mPolyMorphTargetInfoList.begin(); iter != mPolyMorphTargetInfoList.end(); iter++)
174 {
175 delete iter->first;
176 }
177 mPolyMorphTargetInfoList.clear();
178 }
179
180 LLString mType;
181 S32 mLOD;
182 LLString mMeshFileName;
183 LLString mReferenceMeshName;
184 F32 mMinPixelArea;
185 morph_info_list_t mPolyMorphTargetInfoList;
186 };
187 typedef std::vector<LLVOAvatarMeshInfo*> mesh_info_list_t;
188 mesh_info_list_t mMeshInfoList;
189
190 typedef std::vector<LLPolySkeletalDistortionInfo*> skeletal_distortion_info_list_t;
191 skeletal_distortion_info_list_t mSkeletalDistortionInfoList;
192
193 struct LLVOAvatarAttachmentInfo
194 {
195 LLVOAvatarAttachmentInfo()
196 : mGroup(-1), mAttachmentID(-1), mPieMenuSlice(-1), mVisibleFirstPerson(FALSE),
197 mIsHUDAttachment(FALSE), mHasPosition(FALSE), mHasRotation(FALSE) {}
198 LLString mName;
199 LLString mJointName;
200 LLVector3 mPosition;
201 LLVector3 mRotationEuler;
202 S32 mGroup;
203 S32 mAttachmentID;
204 S32 mPieMenuSlice;
205 BOOL mVisibleFirstPerson;
206 BOOL mIsHUDAttachment;
207 BOOL mHasPosition;
208 BOOL mHasRotation;
209 };
210 typedef std::vector<LLVOAvatarAttachmentInfo*> attachment_info_list_t;
211 attachment_info_list_t mAttachmentInfoList;
212
213 LLTexGlobalColorInfo *mTexSkinColorInfo;
214 LLTexGlobalColorInfo *mTexHairColorInfo;
215 LLTexGlobalColorInfo *mTexEyeColorInfo;
216
217 typedef std::vector<LLTexLayerSetInfo*> layer_info_list_t;
218 layer_info_list_t mLayerInfoList;
219
220 typedef std::vector<LLDriverParamInfo*> driver_info_list_t;
221 driver_info_list_t mDriverInfoList;
222};
223
224//------------------------------------------------------------------------
225// LLVOAvatar
226//------------------------------------------------------------------------
227class LLVOAvatar :
228 public LLViewerObject,
229 public LLCharacter
230{
231protected:
232 virtual ~LLVOAvatar();
233
234public:
235 LLVOAvatar(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
236 /*virtual*/ void markDead();
237
238 //--------------------------------------------------------------------
239 // LLViewerObject interface
240 //--------------------------------------------------------------------
241 static void initClass(); // Initialize data that's only inited once per class.
242 static void cleanupClass(); // Cleanup data that's only inited once per class.
243 static BOOL parseSkeletonFile(const LLString& filename);
244 virtual U32 processUpdateMessage( LLMessageSystem *mesgsys,
245 void **user_data,
246 U32 block_num,
247 const EObjectUpdateType update_type,
248 LLDataPacker *dp);
249 virtual BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
250 void setFootPlane(const LLVector4 &plane) { mFootPlane = plane; }
251 /*virtual*/ BOOL isActive() const; // Whether this object needs to do an idleUpdate.
252
253 // Graphical stuff for objects - maybe broken out into render class later?
254
255 U32 renderSkinned(EAvatarRenderPass pass);
256 U32 renderRigid();
257
258 void renderCollisionVolumes();
259
260 /*virtual*/ void updateTextures(LLAgent &agent);
261 // If setting a baked texture, need to request it from a non-local sim.
262 /*virtual*/ S32 setTETexture(const U8 te, const LLUUID& uuid);
263
264 void updateVisibility(BOOL force_invisible);
265 void updateAttachmentVisibility(U32 camera_mode);
266 void clampAttachmentPositions();
267 S32 getAttachmentCount(); // Warning: order(N) not order(1)
268
269 BOOL hasHUDAttachment();
270 LLBBox getHUDBBox();
271// void renderHUD(BOOL for_select); // old
272 void rebuildHUD();
273
274 static void updateAllAvatarVisiblity();
275
276 /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
277 /*virtual*/ BOOL updateGeometry(LLDrawable *drawable);
278 void updateShadowFaces();
279
280 /*virtual*/ void setPixelAreaAndAngle(LLAgent &agent);
281 void updateJointLODs();
282
283 void writeCAL3D(std::string& path, std::string& file_base);
284
285 virtual void updateRegion(LLViewerRegion *regionp);
286
287 //--------------------------------------------------------------------
288 // texture entry assignment
289 //--------------------------------------------------------------------
290 enum ETextureIndex
291 {
292 TEX_HEAD_BODYPAINT = 0,
293 TEX_UPPER_SHIRT = 1,
294 TEX_LOWER_PANTS = 2,
295 TEX_EYES_IRIS = 3,
296 TEX_HAIR = 4,
297 TEX_UPPER_BODYPAINT = 5,
298 TEX_LOWER_BODYPAINT = 6,
299 TEX_LOWER_SHOES = 7,
300 TEX_HEAD_BAKED = 8, // Pre-composited
301 TEX_UPPER_BAKED = 9, // Pre-composited
302 TEX_LOWER_BAKED = 10, // Pre-composited
303 TEX_EYES_BAKED = 11, // Pre-composited
304 TEX_LOWER_SOCKS = 12,
305 TEX_UPPER_JACKET = 13,
306 TEX_LOWER_JACKET = 14,
307 TEX_UPPER_GLOVES = 15,
308 TEX_UPPER_UNDERSHIRT = 16,
309 TEX_LOWER_UNDERPANTS = 17,
310 TEX_SKIRT = 18,
311 TEX_SKIRT_BAKED = 19, // Pre-composited
312 TEX_NUM_ENTRIES = 20
313 };
314 // Note: if TEX_NUM_ENTRIES changes, update AGENT_TEXTURES in llagentinfo.h, mTextureIndexBaked, and BAKED_TEXTURE_COUNT
315
316 static BOOL isTextureIndexBaked( S32 i )
317 {
318 switch(i)
319 {
320 case TEX_HEAD_BAKED:
321 case TEX_UPPER_BAKED:
322 case TEX_LOWER_BAKED:
323 case TEX_EYES_BAKED:
324 case TEX_SKIRT_BAKED:
325 return TRUE;
326 default:
327 return FALSE;
328 }
329 }
330
331 //--------------------------------------------------------------------
332 // LLCharacter interface
333 //--------------------------------------------------------------------
334 virtual const char *getAnimationPrefix() { return "avatar"; }
335 virtual LLJoint *getRootJoint() { return &mRoot; }
336 virtual LLVector3 getCharacterPosition();
337 virtual LLQuaternion getCharacterRotation();
338 virtual LLVector3 getCharacterVelocity();
339 virtual LLVector3 getCharacterAngularVelocity();
340 virtual F32 getTimeDilation();
341 virtual void getGround(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
342 virtual BOOL allocateCharacterJoints( U32 num );
343 virtual LLJoint *getCharacterJoint( U32 num );
344 virtual void requestStopMotion( LLMotion* motion );
345 virtual F32 getPixelArea();
346 virtual LLPolyMesh* getHeadMesh();
347 virtual LLPolyMesh* getUpperBodyMesh();
348 virtual LLVector3d getPosGlobalFromAgent(const LLVector3 &position);
349 virtual LLVector3 getPosAgentFromGlobal(const LLVector3d &position);
350 virtual void updateVisualParams();
351 virtual BOOL startMotion(const LLUUID& id, F32 time_offset = 0.f);
352 virtual BOOL stopMotion(const LLUUID& id, BOOL stop_immediate = FALSE);
353 virtual void stopMotionFromSource(const LLUUID& source_id);
354 virtual LLVector3 getVolumePos(S32 joint_index, LLVector3& volume_offset);
355 virtual LLJoint* findCollisionVolume(U32 volume_id);
356 virtual S32 getCollisionVolumeID(std::string &name);
357 virtual void addDebugText(const char* text);
358 virtual const LLUUID& getID();
359 virtual LLJoint *getJoint( const std::string &name );
360
361 //--------------------------------------------------------------------
362 // Other public functions
363 //--------------------------------------------------------------------
364 BOOL allocateCollisionVolumes( U32 num );
365
366 static void getAnimLabels( LLDynamicArray<const char*>* labels );
367 static void getAnimNames( LLDynamicArray<const char*>* names );
368
369 static void onCustomizeStart();
370 static void onCustomizeEnd();
371
372 void getLocalTextureByteCount( S32* gl_byte_count );
373 static void dumpTotalLocalTextureByteCount();
374 LLMotion* findMotion(const LLUUID& id);
375
376 BOOL isVisible();
377 BOOL isSelf() { return mIsSelf; }
378 BOOL isCulled() { return mCulled; }
379
380 S32 getUnbakedPixelAreaRank();
381 static void cullAvatarsByPixelArea();
382
383 void dumpLocalTextures();
384 const LLUUID& grabLocalTexture(ETextureIndex index);
385 BOOL canGrabLocalTexture(ETextureIndex index);
386 void startAppearanceAnimation(BOOL set_by_user, BOOL play_sound);
387
388 void setCompositeUpdatesEnabled(BOOL b);
389
390 void addChat(const LLChat& chat);
391 void clearChat();
392 void startTyping() { mTyping = TRUE; mTypingTimer.reset(); }
393 void stopTyping() { mTyping = FALSE; }
394
395 // Returns "FirstName LastName"
396 LLString getFullname() const;
397
398 //--------------------------------------------------------------------
399 // internal (pseudo-private) functions
400 //--------------------------------------------------------------------
401 F32 getPelvisToFoot() { return mPelvisToFoot; }
402
403 void buildCharacter();
404 void releaseMeshData();
405 void restoreMeshData();
406 void updateMeshData();
407
408 void computeBodySize();
409
410 void updateCharacter(LLAgent &agent);
411 void updateHeadOffset();
412
413 LLUUID& getStepSound();
414 void processAnimationStateChanges();
415 BOOL processSingleAnimationStateChange(const LLUUID &anim_id, BOOL start);
416 void resetAnimations();
417 BOOL isAnyAnimationSignaled(const LLUUID *anim_array, const S32 num_anims);
418
419 BOOL needsRenderBeam();
420
421 // Utility functions
422 void resolveHeightGlobal(const LLVector3d &inPos, LLVector3d &outPos, LLVector3 &outNorm);
423 void resolveHeightAgent(const LLVector3 &inPos, LLVector3 &outPos, LLVector3 &outNorm);
424 void resolveRayCollisionAgent(const LLVector3d start_pt, const LLVector3d end_pt, LLVector3d &out_pos, LLVector3 &out_norm);
425
426 void slamPosition(); // Slam position to transmitted position (for teleport);
427
428 BOOL loadAvatar();
429 BOOL setupBone(LLVOAvatarBoneInfo* info, LLViewerJoint* parent);
430 BOOL buildSkeleton(LLVOAvatarSkeletonInfo *info);
431
432 // morph targets and such
433 void processAvatarAppearance( LLMessageSystem* mesgsys );
434 void onFirstTEMessageReceived();
435 void updateSexDependentLayerSets( BOOL set_by_user );
436 void dirtyMesh(); // Dirty the avatar mesh
437
438 virtual void setParent(LLViewerObject* parent);
439 virtual void addChild(LLViewerObject *childp);
440 virtual void removeChild(LLViewerObject *childp);
441
442 BOOL attachObject(LLViewerObject *viewer_object);
443 BOOL detachObject(LLViewerObject *viewer_object);
444 void lazyAttach();
445
446 void sitOnObject(LLViewerObject *sit_object);
447 void getOffObject();
448
449 BOOL isWearingAttachment( const LLUUID& inv_item_id );
450 LLViewerObject* getWornAttachment( const LLUUID& inv_item_id );
451 const LLString getAttachedPointName(const LLUUID& inv_item_id);
452
453 static LLVOAvatar* findAvatarFromAttachment( LLViewerObject* obj );
454
455 void updateMeshTextures();
456
457 //--------------------------------------------------------------------
458 // local textures for compositing.
459 //--------------------------------------------------------------------
460 enum ELocTexIndex
461 {
462 LOCTEX_UPPER_SHIRT = 0,
463 LOCTEX_UPPER_BODYPAINT = 1,
464 LOCTEX_LOWER_PANTS = 2,
465 LOCTEX_LOWER_BODYPAINT = 3,
466 LOCTEX_HEAD_BODYPAINT = 4,
467 LOCTEX_LOWER_SHOES = 5,
468 LOCTEX_LOWER_SOCKS = 6,
469 LOCTEX_UPPER_JACKET = 7,
470 LOCTEX_LOWER_JACKET = 8,
471 LOCTEX_UPPER_GLOVES = 9,
472 LOCTEX_UPPER_UNDERSHIRT = 10,
473 LOCTEX_LOWER_UNDERPANTS = 11,
474 LOCTEX_EYES_IRIS = 12,
475 LOCTEX_SKIRT = 13,
476 LOCTEX_NUM_ENTRIES = 14
477 };
478
479 //--------------------------------------------------------------------
480 // texture compositing (used only by the LLTexLayer series of classes)
481 //--------------------------------------------------------------------
482 LLColor4 getGlobalColor( const LLString& color_name );
483 BOOL isLocalTextureDataAvailable( LLTexLayerSet* layerset );
484 BOOL isLocalTextureDataFinal( LLTexLayerSet* layerset );
485 ETextureIndex getBakedTE( LLTexLayerSet* layerset );
486 void updateComposites();
487 void onGlobalColorChanged( LLTexGlobalColor* global_color, BOOL set_by_user );
488 BOOL getLocalTextureRaw( S32 index, LLImageRaw* image_raw_pp );
489 BOOL getLocalTextureGL( S32 index, LLImageGL** image_gl_pp );
490 const LLUUID& getLocalTextureID( S32 index );
491 LLGLuint getScratchTexName( LLGLenum format, U32* texture_bytes );
492 BOOL bindScratchTexture( LLGLenum format );
493 void invalidateComposite( LLTexLayerSet* layerset, BOOL set_by_user );
494 void forceBakeAllTextures(bool slam_for_debug = false);
495 static void processRebakeAvatarTextures(LLMessageSystem* msg, void**);
496 void setNewBakedTexture( ETextureIndex i, const LLUUID& uuid );
497 void setCachedBakedTexture( ETextureIndex i, const LLUUID& uuid );
498 void requestLayerSetUploads();
499 bool hasPendingBakedUploads();
500 static void onLocalTextureLoaded( BOOL succcess, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
501 static void dumpArchetypeXML( void* );
502 static void dumpScratchTextureByteCount();
503 static void dumpBakedStatus();
504 static void deleteCachedImages();
505 static void destroyGL();
506 static void restoreGL();
507 static void initVertexPrograms();
508 static void cleanupVertexPrograms();
509 static enum EWearableType getTEWearableType( S32 te );
510 static LLUUID getDefaultTEImageID( S32 te );
511
512 //--------------------------------------------------------------------
513 // Clothing colors (conventience functions to access visual parameters
514 //--------------------------------------------------------------------
515 void setClothesColor( ETextureIndex te, const LLColor4& new_color, BOOL set_by_user );
516 LLColor4 getClothesColor( ETextureIndex te );
517 BOOL teToColorParams( ETextureIndex te, const char* param_name[3] );
518
519 BOOL isWearingWearableType( EWearableType type );
520
521 //--------------------------------------------------------------------
522 // texture compositing
523 //--------------------------------------------------------------------
524 void setLocTexTE( U8 te, LLViewerImage* image, BOOL set_by_user );
525 void setupComposites();
526
527 //--------------------------------------------------------------------
528 // member variables
529 //--------------------------------------------------------------------
530
531 BOOL mDirtyMesh;
532
533 LLFace *mShadow0Facep;
534 LLFace *mShadow1Facep;
535
536 LLFrameTimer mUpdateLODTimer; // controls frequency of LOD change calculations
537
538 //--------------------------------------------------------------------
539 // State of deferred character building
540 //--------------------------------------------------------------------
541 BOOL mIsBuilt;
542
543 //--------------------------------------------------------------------
544 // avatar definition name
545 //--------------------------------------------------------------------
546 char mAvatarDefinition[64];
547
548 //--------------------------------------------------------------------
549 // skeleton for skinned avatar
550 //--------------------------------------------------------------------
551 S32 mNumJoints;
552 LLViewerJoint *mSkeleton;
553
554 S32 mNumCollisionVolumes;
555 LLViewerJointCollisionVolume* mCollisionVolumes;
556
557 //--------------------------------------------------------------------
558 // cached pointers to well known joints
559 //--------------------------------------------------------------------
560 LLViewerJoint *mPelvisp;
561 LLViewerJoint *mTorsop;
562 LLViewerJoint *mChestp;
563 LLViewerJoint *mNeckp;
564 LLViewerJoint *mHeadp;
565 LLViewerJoint *mSkullp;
566 LLViewerJoint *mEyeLeftp;
567 LLViewerJoint *mEyeRightp;
568 LLViewerJoint *mHipLeftp;
569 LLViewerJoint *mHipRightp;
570 LLViewerJoint *mKneeLeftp;
571 LLViewerJoint *mKneeRightp;
572 LLViewerJoint *mAnkleLeftp;
573 LLViewerJoint *mAnkleRightp;
574 LLViewerJoint *mFootLeftp;
575 LLViewerJoint *mFootRightp;
576 LLViewerJoint *mWristLeftp;
577 LLViewerJoint *mWristRightp;
578
579 //--------------------------------------------------------------------
580 // special purpose joint for HUD attachments
581 //--------------------------------------------------------------------
582 LLViewerJoint *mScreenp;
583 F32 mHUDTargetZoom;
584 F32 mHUDCurZoom;
585
586 //--------------------------------------------------------------------
587 // mesh objects for skinned avatar
588 //--------------------------------------------------------------------
589 LLViewerJoint mHairLOD;
590 LLViewerJointMesh mHairMesh0;
591 LLViewerJointMesh mHairMesh1;
592 LLViewerJointMesh mHairMesh2;
593 LLViewerJointMesh mHairMesh3;
594 LLViewerJointMesh mHairMesh4;
595 LLViewerJointMesh mHairMesh5;
596
597 LLViewerJoint mHeadLOD;
598 LLViewerJointMesh mHeadMesh0;
599 LLViewerJointMesh mHeadMesh1;
600 LLViewerJointMesh mHeadMesh2;
601 LLViewerJointMesh mHeadMesh3;
602 LLViewerJointMesh mHeadMesh4;
603
604 LLViewerJoint mEyeLashLOD;
605 LLViewerJointMesh mEyeLashMesh0;
606
607 LLViewerJoint mUpperBodyLOD;
608 LLViewerJointMesh mUpperBodyMesh0;
609 LLViewerJointMesh mUpperBodyMesh1;
610 LLViewerJointMesh mUpperBodyMesh2;
611 LLViewerJointMesh mUpperBodyMesh3;
612 LLViewerJointMesh mUpperBodyMesh4;
613
614 LLViewerJoint mLowerBodyLOD;
615 LLViewerJointMesh mLowerBodyMesh0;
616 LLViewerJointMesh mLowerBodyMesh1;
617 LLViewerJointMesh mLowerBodyMesh2;
618 LLViewerJointMesh mLowerBodyMesh3;
619 LLViewerJointMesh mLowerBodyMesh4;
620
621 LLViewerJoint mEyeBallLeftLOD;
622 LLViewerJointMesh mEyeBallLeftMesh0;
623 LLViewerJointMesh mEyeBallLeftMesh1;
624
625 LLViewerJoint mEyeBallRightLOD;
626 LLViewerJointMesh mEyeBallRightMesh0;
627 LLViewerJointMesh mEyeBallRightMesh1;
628
629 LLViewerJoint mSkirtLOD;
630 LLViewerJointMesh mSkirtMesh0;
631 LLViewerJointMesh mSkirtMesh1;
632 LLViewerJointMesh mSkirtMesh2;
633 LLViewerJointMesh mSkirtMesh3;
634 LLViewerJointMesh mSkirtMesh4;
635
636 typedef std::multimap<LLString, LLPolyMesh*> mesh_map_t;
637 mesh_map_t mMeshes;
638
639 //--------------------------------------------------------------------
640 // true if this avatar is for this viewers agent
641 //--------------------------------------------------------------------
642 BOOL mIsSelf;
643
644 //--------------------------------------------------------------------
645 // texture ids and pointers
646 //--------------------------------------------------------------------
647 LLUUID mShadowImageID;
648 LLPointer<LLViewerImage> mShadowImagep;
649
650 LLUUID mLastHeadBakedID;
651 LLUUID mLastUpperBodyBakedID;
652 LLUUID mLastLowerBodyBakedID;
653 LLUUID mLastEyesBakedID;
654 LLUUID mLastSkirtBakedID;
655
656 //--------------------------------------------------------------------
657 // Misc Render State
658 //--------------------------------------------------------------------
659 BOOL mIsDummy; // For special views
660 S32 mSpecialRenderMode; // Special lighting
661
662 //--------------------------------------------------------------------
663 // Animation timer
664 //--------------------------------------------------------------------
665 LLTimer mAnimTimer;
666 F32 mTimeLast;
667
668 //--------------------------------------------------------------------
669 // Measures speed (for diagnostics mostly).
670 //--------------------------------------------------------------------
671 F32 mSpeedAccum;
672
673 //--------------------------------------------------------------------
674 // animation state data
675 //--------------------------------------------------------------------
676 typedef std::map<LLUUID, S32>::iterator AnimIterator;
677
678 std::map<LLUUID, S32> mSignaledAnimations; // requested state of Animation name/value
679 std::map<LLUUID, S32> mPlayingAnimations; // current state of Animation name/value
680
681 typedef std::multimap<LLUUID, LLUUID> AnimationSourceMap;
682 typedef AnimationSourceMap::iterator AnimSourceIterator;
683 AnimationSourceMap mAnimationSources; // object ids that triggered anim ids
684
685 BOOL mTurning; // controls hysteresis on avatar rotation
686
687 //--------------------------------------------------------------------
688 // misc. animation related state
689 //--------------------------------------------------------------------
690 F32 mSpeed;
691
692 //
693 // Shadow stuff
694 //
695 LLDrawable* mShadow;
696 BOOL mInAir;
697 LLFrameTimer mTimeInAir;
698
699 //--------------------------------------------------------------------
700 // Keeps track of foot step state for generating sounds
701 //--------------------------------------------------------------------
702 BOOL mWasOnGroundLeft;
703 BOOL mWasOnGroundRight;
704 LLVector4 mFootPlane;
705
706 //--------------------------------------------------------------------
707 // Keep track of the material being stepped on
708 //--------------------------------------------------------------------
709 BOOL mStepOnLand;
710 U8 mStepMaterial;
711 LLVector3 mStepObjectVelocity;
712
713 //--------------------------------------------------------------------
714 // Pelvis height adjustment members.
715 //--------------------------------------------------------------------
716 F32 mPelvisToFoot;
717 LLVector3 mBodySize;
718 S32 mLastSkeletonSerialNum;
719
720 //--------------------------------------------------------------------
721 // current head position
722 //--------------------------------------------------------------------
723 LLVector3 mHeadOffset;
724
725 //--------------------------------------------------------------------
726 // avatar skeleton
727 //--------------------------------------------------------------------
728 LLViewerJoint mRoot;
729
730 //--------------------------------------------------------------------
731 // sitting state
732 //--------------------------------------------------------------------
733 BOOL mIsSitting;
734
735 //--------------------------------------------------------------------
736 // Display the name, then optionally fade it out
737 //--------------------------------------------------------------------
738 LLFrameTimer mTimeVisible;
739 LLPointer<LLHUDText> mNameText;
740 std::deque<LLChat> mChats;
741 LLFrameTimer mChatTimer;
742 BOOL mTyping;
743 LLFrameTimer mTypingTimer;
744
745 //--------------------------------------------------------------------
746 // destroy mesh data after being invisible for a while
747 //--------------------------------------------------------------------
748 BOOL mMeshValid;
749 BOOL mVisible;
750 LLFrameTimer mMeshInvisibleTime;
751
752 //--------------------------------------------------------------------
753 // wind rippling in clothes
754 //--------------------------------------------------------------------
755 LLVector4 mWindVec;
756 F32 mWindFreq;
757 F32 mRipplePhase;
758 LLFrameTimer mRippleTimer;
759 F32 mRippleTimeLast;
760 LLVector3 mRippleAccel;
761 LLVector3 mLastVel;
762 BOOL mBelowWater;
763
764 //--------------------------------------------------------------------
765 // appearance morphing
766 //--------------------------------------------------------------------
767 LLFrameTimer mAppearanceMorphTimer;
768 BOOL mAppearanceAnimSetByUser;
769 F32 mLastAppearanceBlendTime;
770 BOOL mAppearanceAnimating;
771
772 //--------------------------------------------------------------------
773 // static members
774 //--------------------------------------------------------------------
775 static S32 sMaxVisible;
776 static S32 sCurJoint;
777 static S32 sCurVolume;
778 static BOOL sShowAnimationDebug; // show animation debug info
779 static BOOL sShowFootPlane; // show foot collision plane reported by server
780 static BOOL sShowCollisionVolumes; // show skeletal collision volumes
781 static BOOL sVisibleInFirstPerson;
782
783 static S32 sMaxOtherAvatarsToComposite;
784
785 static S32 sNumLODChangesThisFrame;
786
787 // global table of sound ids per material, and the ground
788 static LLUUID sStepSounds[LL_MCODE_END];
789 static LLUUID sStepSoundOnLand;
790
791 static S32 sRenderName;
792 static S32 sNumVisibleChatBubbles;
793 static BOOL sDebugInvisible;
794 static BOOL sShowAttachmentPoints;
795
796 // Number of instances of this class
797 static S32 sNumVisibleAvatars;
798
799 // Scratch textures used for compositing
800 static LLMap< LLGLenum, LLGLuint*> sScratchTexNames;
801 static LLMap< LLGLenum, F32*> sScratchTexLastBindTime;
802 static S32 sScratchTexBytes;
803
804 // map of attachment points, by ID
805 LLPtrSkipMap<S32, LLViewerJointAttachment*> mAttachmentPoints;
806
807 // xml parse tree of avatar config file
808 static LLXmlTree sXMLTree;
809 // xml parse tree of avatar skeleton file
810 static LLXmlTree sSkeletonXMLTree;
811
812 // number of avatar duplicates, for debugging purposes
813 static BOOL sAvatarLoadTest;
814
815 // user-settable LOD factor
816 static F32 sLODFactor;
817
818 // output total number of joints being touched for each avatar
819 static BOOL sJointDebug;
820 static ETextureIndex sBakedTextureIndices[BAKED_TEXTURE_COUNT];
821
822 //--------------------------------------------------------------------
823 // Texture Layer Sets and Global Colors
824 //--------------------------------------------------------------------
825 LLTexLayerSet* mHeadLayerSet;
826 LLTexLayerSet* mUpperBodyLayerSet;
827 LLTexLayerSet* mLowerBodyLayerSet;
828 LLTexLayerSet* mEyesLayerSet;
829 LLTexLayerSet* mSkirtLayerSet;
830
831
832protected:
833 LLPointer<LLHUDEffectSpiral> mBeam;
834 LLFrameTimer mBeamTimer;
835 LLFrameTimer mEditEffectTimer;
836
837 F32 mRenderPriority;
838 F32 mAdjustedPixelArea;
839 S32 mNumAGPVertices;
840
841 LLWString mNameString;
842 LLString mTitle;
843 BOOL mNameAway;
844 BOOL mNameBusy;
845 BOOL mNameMute;
846 BOOL mNameAppearance;
847 BOOL mVisibleChat;
848
849 LLString mDebugText;
850 U64 mLastRegionHandle;
851 LLFrameTimer mRegionCrossingTimer;
852 S32 mRegionCrossingCount;
853
854 //--------------------------------------------------------------------
855 // local textures for compositing.
856 //--------------------------------------------------------------------
857
858 LLPointer<LLViewerImage> mLocalTexture[ LOCTEX_NUM_ENTRIES ];
859 BOOL mLocalTextureBaked[ LOCTEX_NUM_ENTRIES ]; // Texture is covered by a baked texture
860 S32 mLocalTextureDiscard[ LOCTEX_NUM_ENTRIES ];
861 LLUUID mSavedTE[ TEX_NUM_ENTRIES ];
862 BOOL mFirstTEMessageReceived;
863 BOOL mFirstAppearanceMessageReceived;
864
865 BOOL mHeadBakedLoaded;
866 S32 mHeadMaskDiscard;
867 BOOL mUpperBakedLoaded;
868 S32 mUpperMaskDiscard;
869 BOOL mLowerBakedLoaded;
870 S32 mLowerMaskDiscard;
871 BOOL mEyesBakedLoaded;
872 BOOL mSkirtBakedLoaded;
873
874 //RN: testing 2 pass rendering
875 U32 mHeadMaskTexName;
876 U32 mUpperMaskTexName;
877 U32 mLowerMaskTexName;
878
879 BOOL mCulled;
880
881 //--------------------------------------------------------------------
882 // Global Colors
883 //--------------------------------------------------------------------
884 LLTexGlobalColor* mTexSkinColor;
885 LLTexGlobalColor* mTexHairColor;
886 LLTexGlobalColor* mTexEyeColor;
887
888 static LLVOAvatarSkeletonInfo* sSkeletonInfo;
889 static LLVOAvatarInfo* sAvatarInfo;
890
891protected:
892
893 BOOL loadSkeletonNode();
894 BOOL loadMeshNodes();
895
896 BOOL isFullyBaked();
897 void deleteLayerSetCaches();
898 static BOOL areAllNearbyInstancesBaked();
899
900 static void onBakedTextureMasksLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
901
902 void setLocalTexture(ELocTexIndex i, LLViewerImage* tex, BOOL baked_version_exits);
903
904 void requestLayerSetUpdate(LLVOAvatar::ELocTexIndex i);
905 void addLocalTextureStats(LLVOAvatar::ELocTexIndex i, LLViewerImage* imagep, F32 texel_area_ratio, BOOL rendered, BOOL covered_by_baked);
906 static void onInitialBakedTextureLoaded( BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata );
907 static void onBakedTextureLoaded(BOOL success, LLViewerImage *src_vi, LLImageRaw* src, LLImageRaw* aux_src, S32 discard_level, BOOL final, void* userdata);
908 void useBakedTexture(const LLUUID& id);
909 void dumpAvatarTEs(const char* context);
910 void removeMissingBakedTextures();
911 LLTexLayerSet* getLayerSet(ETextureIndex index) const;
912 LLHost getObjectHost() const;
913 S32 getLocalDiscardLevel( S32 index);
914};
915
916#endif // LL_VO_AVATAR_H