PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llvoavatardefines.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 228 lines | 141 code | 22 blank | 65 comment | 0 complexity | e234da69acdf3f1cd977ec211afcb286 MD5 | raw file
  1/** 
  2 * @file llvoavatar.h
  3 * @brief Declaration of LLVOAvatar class which is a derivation fo
  4 * LLViewerObject
  5 *
  6 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 */
 27
 28#ifndef LLVOAVATAR_DEFINES_H
 29#define LLVOAVATAR_DEFINES_H
 30
 31#include <vector>
 32#include "llwearable.h"
 33#include "llviewerjoint.h"
 34#include "lldictionary.h"
 35
 36namespace LLVOAvatarDefines
 37{
 38
 39extern const S32 SCRATCH_TEX_WIDTH;
 40extern const S32 SCRATCH_TEX_HEIGHT;
 41extern const S32 IMPOSTOR_PERIOD;
 42
 43//--------------------------------------------------------------------
 44// Enums
 45//--------------------------------------------------------------------
 46enum ETextureIndex
 47{
 48	TEX_HEAD_BODYPAINT = 0,
 49	TEX_UPPER_SHIRT,
 50	TEX_LOWER_PANTS,
 51	TEX_EYES_IRIS,
 52	TEX_HAIR,
 53	TEX_UPPER_BODYPAINT,
 54	TEX_LOWER_BODYPAINT,
 55	TEX_LOWER_SHOES,
 56	TEX_HEAD_BAKED,		// Pre-composited
 57	TEX_UPPER_BAKED,	// Pre-composited
 58	TEX_LOWER_BAKED,	// Pre-composited
 59	TEX_EYES_BAKED,		// Pre-composited
 60	TEX_LOWER_SOCKS,
 61	TEX_UPPER_JACKET,
 62	TEX_LOWER_JACKET,
 63	TEX_UPPER_GLOVES,
 64	TEX_UPPER_UNDERSHIRT,
 65	TEX_LOWER_UNDERPANTS,
 66	TEX_SKIRT,
 67	TEX_SKIRT_BAKED,	// Pre-composited
 68	TEX_HAIR_BAKED,     // Pre-composited
 69	TEX_LOWER_ALPHA,
 70	TEX_UPPER_ALPHA,
 71	TEX_HEAD_ALPHA,
 72	TEX_EYES_ALPHA,
 73	TEX_HAIR_ALPHA,
 74	TEX_HEAD_TATTOO,
 75	TEX_UPPER_TATTOO,
 76	TEX_LOWER_TATTOO,
 77	TEX_NUM_INDICES
 78}; 
 79
 80enum EBakedTextureIndex
 81{
 82	BAKED_HEAD = 0,
 83	BAKED_UPPER,
 84	BAKED_LOWER,
 85	BAKED_EYES,
 86	BAKED_SKIRT,
 87	BAKED_HAIR,
 88	BAKED_NUM_INDICES
 89};
 90
 91// Reference IDs for each mesh. Used as indices for vector of joints
 92enum EMeshIndex
 93{
 94	MESH_ID_HAIR = 0,
 95	MESH_ID_HEAD,
 96	MESH_ID_EYELASH,
 97	MESH_ID_UPPER_BODY,
 98	MESH_ID_LOWER_BODY,
 99	MESH_ID_EYEBALL_LEFT,
100	MESH_ID_EYEBALL_RIGHT,
101	MESH_ID_SKIRT,
102	MESH_ID_NUM_INDICES
103};
104
105//--------------------------------------------------------------------
106// Vector Types
107//--------------------------------------------------------------------
108typedef std::vector<ETextureIndex> texture_vec_t;
109typedef std::vector<EBakedTextureIndex> bakedtexture_vec_t;
110typedef std::vector<EMeshIndex> mesh_vec_t;
111typedef std::vector<LLWearableType::EType> wearables_vec_t;
112
113//------------------------------------------------------------------------
114// LLVOAvatarDictionary
115// 
116// Holds dictionary static entries for textures, baked textures, meshes, etc.; i.e.
117// information that is common to all avatars.
118// 
119// This holds const data - it is initialized once and the contents never change after that.
120//------------------------------------------------------------------------
121class LLVOAvatarDictionary : public LLSingleton<LLVOAvatarDictionary>
122{
123	//--------------------------------------------------------------------
124	// Constructors and Destructors
125	//--------------------------------------------------------------------
126public:
127	LLVOAvatarDictionary();
128	virtual ~LLVOAvatarDictionary();
129private:
130	void createAssociations();
131	
132	//--------------------------------------------------------------------
133	// Local and baked textures
134	//--------------------------------------------------------------------
135public:
136	struct TextureEntry : public LLDictionaryEntry
137	{
138		TextureEntry(const std::string &name, // this must match the xml name used by LLTexLayerInfo::parseXml
139					 bool is_local_texture, 
140					 EBakedTextureIndex baked_texture_index = BAKED_NUM_INDICES,
141					 const std::string& default_image_name = "",
142					 LLWearableType::EType wearable_type = LLWearableType::WT_INVALID);
143		const std::string 	mDefaultImageName;
144		const LLWearableType::EType mWearableType;
145		// It's either a local texture xor baked
146		BOOL 				mIsLocalTexture;
147		BOOL 				mIsBakedTexture;
148		// If it's a local texture, it may be used by a baked texture
149		BOOL 				mIsUsedByBakedTexture;
150		EBakedTextureIndex 	mBakedTextureIndex;
151	};
152
153	struct Textures : public LLDictionary<ETextureIndex, TextureEntry>
154	{
155		Textures();
156	} mTextures;
157	const TextureEntry*		getTexture(ETextureIndex index) const { return mTextures.lookup(index); }
158	const Textures&			getTextures() const { return mTextures; }
159	
160	//--------------------------------------------------------------------
161	// Meshes
162	//--------------------------------------------------------------------
163public:
164	struct MeshEntry : public LLDictionaryEntry
165	{
166		MeshEntry(EBakedTextureIndex baked_index, 
167				  const std::string &name, // names of mesh types as they are used in avatar_lad.xml
168				  U8 level,
169				  LLViewerJoint::PickName pick);
170		// Levels of Detail for each mesh.  Must match levels of detail present in avatar_lad.xml
171        // Otherwise meshes will be unable to be found, or levels of detail will be ignored
172		const U8 						mLOD;
173		const EBakedTextureIndex 		mBakedID;
174		const LLViewerJoint::PickName 	mPickName;
175	};
176
177	struct Meshes : public LLDictionary<EMeshIndex, MeshEntry>
178	{
179		Meshes();
180	} mMeshes;
181	const MeshEntry*		getMesh(EMeshIndex index) const { return mMeshes.lookup(index); }
182	const Meshes&			getMeshes() const { return mMeshes; }
183
184	//--------------------------------------------------------------------
185	// Baked Textures
186	//--------------------------------------------------------------------
187public:
188	struct BakedEntry : public LLDictionaryEntry
189	{
190		BakedEntry(ETextureIndex tex_index, 
191				   const std::string &name, // unused, but necessary for templating.
192				   const std::string &hash_name,
193				   U32 num_local_textures, ... ); // # local textures, local texture list, # wearables, wearable list
194		// Local Textures
195		const ETextureIndex mTextureIndex;
196		texture_vec_t 		mLocalTextures;
197		// Wearables
198		const LLUUID 		mWearablesHashID;
199		wearables_vec_t 	mWearables;
200	};
201
202	struct BakedTextures: public LLDictionary<EBakedTextureIndex, BakedEntry>
203	{
204		BakedTextures();
205	} mBakedTextures;
206	const BakedEntry*		getBakedTexture(EBakedTextureIndex index) const { return mBakedTextures.lookup(index); }
207	const BakedTextures&	getBakedTextures() const { return mBakedTextures; }
208	
209	//--------------------------------------------------------------------
210	// Convenience Functions
211	//--------------------------------------------------------------------
212public:
213	// Convert from baked texture to associated texture; e.g. BAKED_HEAD -> TEX_HEAD_BAKED
214	static ETextureIndex 		bakedToLocalTextureIndex(EBakedTextureIndex t);
215
216	// find a baked texture index based on its name
217	static EBakedTextureIndex 	findBakedByRegionName(std::string name);
218
219	static const LLUUID			getDefaultTextureImageID(ETextureIndex index);
220
221	// Given a texture entry, determine which wearable type owns it.
222	static LLWearableType::EType 		getTEWearableType(ETextureIndex index);
223
224}; // End LLVOAvatarDictionary
225
226} // End namespace LLVOAvatarDefines
227
228#endif //LL_VO_AVATARDEFINES_H