llavatarappearancedefines.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /**
  2. * @file llavatarappearancedefines.h
  3. * @brief Various LLAvatarAppearance related definitions
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_AVATARAPPEARANCE_DEFINES_H
  33. #define LL_AVATARAPPEARANCE_DEFINES_H
  34. #include <vector>
  35. #include "llavatarjoint.h"
  36. #include "lldictionary.h"
  37. #include "lluuid.h"
  38. #include "llwearabletype.h"
  39. namespace LLAvatarAppearanceDefines
  40. {
  41. constexpr S32 IMPOSTOR_PERIOD = 2;
  42. constexpr U32 AVATAR_HOVER = 11001;
  43. //--------------------------------------------------------------------
  44. // Enums
  45. //--------------------------------------------------------------------
  46. enum ETextureIndex
  47. {
  48. TEX_INVALID = -1,
  49. TEX_HEAD_BODYPAINT = 0,
  50. TEX_UPPER_SHIRT,
  51. TEX_LOWER_PANTS,
  52. TEX_EYES_IRIS,
  53. TEX_HAIR,
  54. TEX_UPPER_BODYPAINT,
  55. TEX_LOWER_BODYPAINT,
  56. TEX_LOWER_SHOES,
  57. TEX_HEAD_BAKED, // Pre-composited
  58. TEX_UPPER_BAKED, // Pre-composited
  59. TEX_LOWER_BAKED, // Pre-composited
  60. TEX_EYES_BAKED, // Pre-composited
  61. TEX_LOWER_SOCKS,
  62. TEX_UPPER_JACKET,
  63. TEX_LOWER_JACKET,
  64. TEX_UPPER_GLOVES,
  65. TEX_UPPER_UNDERSHIRT,
  66. TEX_LOWER_UNDERPANTS,
  67. TEX_SKIRT,
  68. TEX_SKIRT_BAKED, // Pre-composited
  69. TEX_HAIR_BAKED, // Pre-composited
  70. TEX_LOWER_ALPHA,
  71. TEX_UPPER_ALPHA,
  72. TEX_HEAD_ALPHA,
  73. TEX_EYES_ALPHA,
  74. TEX_HAIR_ALPHA,
  75. TEX_HEAD_TATTOO,
  76. TEX_UPPER_TATTOO,
  77. TEX_LOWER_TATTOO,
  78. TEX_HEAD_UNIVERSAL_TATTOO,
  79. TEX_UPPER_UNIVERSAL_TATTOO,
  80. TEX_LOWER_UNIVERSAL_TATTOO,
  81. TEX_SKIRT_TATTOO,
  82. TEX_HAIR_TATTOO,
  83. TEX_EYES_TATTOO,
  84. TEX_LEFT_ARM_TATTOO,
  85. TEX_LEFT_LEG_TATTOO,
  86. TEX_AUX1_TATTOO,
  87. TEX_AUX2_TATTOO,
  88. TEX_AUX3_TATTOO,
  89. TEX_LEFT_ARM_BAKED, // Pre-composited
  90. TEX_LEFT_LEG_BAKED, // Pre-composited
  91. TEX_AUX1_BAKED, // Pre-composited
  92. TEX_AUX2_BAKED, // Pre-composited
  93. TEX_AUX3_BAKED, // Pre-composited
  94. TEX_NUM_INDICES
  95. };
  96. enum EBakedTextureIndex
  97. {
  98. BAKED_HEAD = 0,
  99. BAKED_UPPER,
  100. BAKED_LOWER,
  101. BAKED_EYES,
  102. BAKED_SKIRT,
  103. BAKED_HAIR,
  104. BAKED_LEFT_ARM,
  105. BAKED_LEFT_LEG,
  106. BAKED_AUX1,
  107. BAKED_AUX2,
  108. BAKED_AUX3,
  109. BAKED_NUM_INDICES
  110. };
  111. // Reference IDs for each mesh. Used as indices for vector of joints
  112. enum EMeshIndex
  113. {
  114. MESH_ID_HAIR = 0,
  115. MESH_ID_HEAD,
  116. MESH_ID_EYELASH,
  117. MESH_ID_UPPER_BODY,
  118. MESH_ID_LOWER_BODY,
  119. MESH_ID_EYEBALL_LEFT,
  120. MESH_ID_EYEBALL_RIGHT,
  121. MESH_ID_SKIRT,
  122. MESH_ID_NUM_INDICES
  123. };
  124. //-----------------------------------------------------------------------------
  125. // Vector Types
  126. //-----------------------------------------------------------------------------
  127. typedef std::vector<ETextureIndex> texture_vec_t;
  128. typedef std::vector<EBakedTextureIndex> bakedtexture_vec_t;
  129. typedef std::vector<EMeshIndex> mesh_vec_t;
  130. typedef std::vector<LLWearableType::EType> wearables_vec_t;
  131. //-----------------------------------------------------------------------------
  132. // LLAvatarAppearanceDictionary
  133. //
  134. // Holds dictionary static entries for textures, baked textures, meshes, etc,
  135. // i.e. information that is common to all avatars.
  136. //
  137. // This holds const data - it is initialized once and the contents never change
  138. // after that.
  139. //-----------------------------------------------------------------------------
  140. class LLAvatarAppearanceDictionary
  141. {
  142. public:
  143. LLAvatarAppearanceDictionary();
  144. ~LLAvatarAppearanceDictionary();
  145. private:
  146. void createAssociations();
  147. public:
  148. //-------------------------------------------------------------------------
  149. // Local and baked textures
  150. //-------------------------------------------------------------------------
  151. struct TextureEntry : public LLDictionaryEntry
  152. {
  153. // 'name' must match the xml name used by LLTexLayerInfo::parseXml
  154. TextureEntry(const std::string& name,
  155. bool is_local_texture,
  156. EBakedTextureIndex baked_texture_index = BAKED_NUM_INDICES,
  157. const std::string& default_image_name = "",
  158. LLWearableType::EType wearable_type = LLWearableType::WT_INVALID);
  159. const std::string mDefaultImageName;
  160. const LLWearableType::EType mWearableType;
  161. // It is either a local texture or a baked one
  162. bool mIsLocalTexture;
  163. bool mIsBakedTexture;
  164. // If it is a local texture, it may be used by a baked texture
  165. bool mIsUsedByBakedTexture;
  166. EBakedTextureIndex mBakedTextureIndex;
  167. };
  168. struct Textures : public LLDictionary<ETextureIndex, TextureEntry>
  169. {
  170. Textures();
  171. } mTextures;
  172. LL_INLINE const TextureEntry* getTexture(ETextureIndex index) const
  173. {
  174. return mTextures.lookup(index);
  175. }
  176. LL_INLINE const Textures& getTextures() const
  177. {
  178. return mTextures;
  179. }
  180. //-------------------------------------------------------------------------
  181. // Meshes
  182. //-------------------------------------------------------------------------
  183. struct MeshEntry : public LLDictionaryEntry
  184. {
  185. MeshEntry(EBakedTextureIndex baked_index,
  186. // Name of mesh types as they are used in avatar_lad.xml
  187. const std::string& name, U8 level, LLJointPickName pick);
  188. // Levels of Detail for each mesh. Must match levels of detail present
  189. // in avatar_lad.xml, otherwise meshes will be unable to be found, or
  190. // levels of detail will be ignored
  191. const U8 mLOD;
  192. const EBakedTextureIndex mBakedID;
  193. const LLJointPickName mPickName;
  194. };
  195. struct MeshEntries : public LLDictionary<EMeshIndex, MeshEntry>
  196. {
  197. MeshEntries();
  198. } mMeshEntries;
  199. LL_INLINE const MeshEntry* getMeshEntry(EMeshIndex index) const
  200. {
  201. return mMeshEntries.lookup(index);
  202. }
  203. LL_INLINE const MeshEntries& getMeshEntries() const
  204. {
  205. return mMeshEntries;
  206. }
  207. //-------------------------------------------------------------------------
  208. // Baked Textures
  209. //-------------------------------------------------------------------------
  210. struct BakedEntry : public LLDictionaryEntry
  211. {
  212. BakedEntry(ETextureIndex tex_index,
  213. const std::string& name, // unused but needed for template
  214. const std::string& hash_name,
  215. // # local textures, local texture list, # wearables,
  216. // wearable list
  217. U32 num_local_textures, ... );
  218. // Local Textures
  219. const ETextureIndex mTextureIndex;
  220. texture_vec_t mLocalTextures;
  221. // Wearables
  222. const LLUUID mWearablesHashID;
  223. wearables_vec_t mWearables;
  224. };
  225. struct BakedTextures: public LLDictionary<EBakedTextureIndex, BakedEntry>
  226. {
  227. BakedTextures();
  228. } mBakedTextures;
  229. LL_INLINE const BakedEntry* getBakedTexture(EBakedTextureIndex index) const
  230. {
  231. return mBakedTextures.lookup(index);
  232. }
  233. LL_INLINE const BakedTextures& getBakedTextures() const
  234. {
  235. return mBakedTextures;
  236. }
  237. //-------------------------------------------------------------------------
  238. // Convenience Functions
  239. //-------------------------------------------------------------------------
  240. // Convert from baked texture to associated texture; e.g.
  241. // BAKED_HEAD -> TEX_HEAD_BAKED
  242. static ETextureIndex bakedToLocalTextureIndex(EBakedTextureIndex t);
  243. // find a baked texture index based on its name
  244. static EBakedTextureIndex findBakedByRegionName(const std::string& name);
  245. static EBakedTextureIndex findBakedByImageName(const std::string& name);
  246. // Given a texture entry, determine which wearable type owns it.
  247. static LLWearableType::EType getTEWearableType(ETextureIndex index);
  248. // Attachments baking
  249. static bool isBakedImageId(const LLUUID& id);
  250. static EBakedTextureIndex assetIdToBakedTextureIndex(const LLUUID& id);
  251. #if 0 // Not used
  252. static const LLUUID& localTextureIndexToMagicId(ETextureIndex t);
  253. #endif
  254. }; // End LLAvatarAppearanceDictionary
  255. } // End namespace LLAvatarAppearanceDefines
  256. extern LLAvatarAppearanceDefines::LLAvatarAppearanceDictionary* gAvatarAppDictp;
  257. #endif //LL_AVATARAPPEARANCE_DEFINES_H