/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. #ifndef LLVOAVATAR_DEFINES_H
  28. #define LLVOAVATAR_DEFINES_H
  29. #include <vector>
  30. #include "llwearable.h"
  31. #include "llviewerjoint.h"
  32. #include "lldictionary.h"
  33. namespace LLVOAvatarDefines
  34. {
  35. extern const S32 SCRATCH_TEX_WIDTH;
  36. extern const S32 SCRATCH_TEX_HEIGHT;
  37. extern const S32 IMPOSTOR_PERIOD;
  38. //--------------------------------------------------------------------
  39. // Enums
  40. //--------------------------------------------------------------------
  41. enum ETextureIndex
  42. {
  43. TEX_HEAD_BODYPAINT = 0,
  44. TEX_UPPER_SHIRT,
  45. TEX_LOWER_PANTS,
  46. TEX_EYES_IRIS,
  47. TEX_HAIR,
  48. TEX_UPPER_BODYPAINT,
  49. TEX_LOWER_BODYPAINT,
  50. TEX_LOWER_SHOES,
  51. TEX_HEAD_BAKED, // Pre-composited
  52. TEX_UPPER_BAKED, // Pre-composited
  53. TEX_LOWER_BAKED, // Pre-composited
  54. TEX_EYES_BAKED, // Pre-composited
  55. TEX_LOWER_SOCKS,
  56. TEX_UPPER_JACKET,
  57. TEX_LOWER_JACKET,
  58. TEX_UPPER_GLOVES,
  59. TEX_UPPER_UNDERSHIRT,
  60. TEX_LOWER_UNDERPANTS,
  61. TEX_SKIRT,
  62. TEX_SKIRT_BAKED, // Pre-composited
  63. TEX_HAIR_BAKED, // Pre-composited
  64. TEX_LOWER_ALPHA,
  65. TEX_UPPER_ALPHA,
  66. TEX_HEAD_ALPHA,
  67. TEX_EYES_ALPHA,
  68. TEX_HAIR_ALPHA,
  69. TEX_HEAD_TATTOO,
  70. TEX_UPPER_TATTOO,
  71. TEX_LOWER_TATTOO,
  72. TEX_NUM_INDICES
  73. };
  74. enum EBakedTextureIndex
  75. {
  76. BAKED_HEAD = 0,
  77. BAKED_UPPER,
  78. BAKED_LOWER,
  79. BAKED_EYES,
  80. BAKED_SKIRT,
  81. BAKED_HAIR,
  82. BAKED_NUM_INDICES
  83. };
  84. // Reference IDs for each mesh. Used as indices for vector of joints
  85. enum EMeshIndex
  86. {
  87. MESH_ID_HAIR = 0,
  88. MESH_ID_HEAD,
  89. MESH_ID_EYELASH,
  90. MESH_ID_UPPER_BODY,
  91. MESH_ID_LOWER_BODY,
  92. MESH_ID_EYEBALL_LEFT,
  93. MESH_ID_EYEBALL_RIGHT,
  94. MESH_ID_SKIRT,
  95. MESH_ID_NUM_INDICES
  96. };
  97. //--------------------------------------------------------------------
  98. // Vector Types
  99. //--------------------------------------------------------------------
  100. typedef std::vector<ETextureIndex> texture_vec_t;
  101. typedef std::vector<EBakedTextureIndex> bakedtexture_vec_t;
  102. typedef std::vector<EMeshIndex> mesh_vec_t;
  103. typedef std::vector<LLWearableType::EType> wearables_vec_t;
  104. //------------------------------------------------------------------------
  105. // LLVOAvatarDictionary
  106. //
  107. // Holds dictionary static entries for textures, baked textures, meshes, etc.; i.e.
  108. // information that is common to all avatars.
  109. //
  110. // This holds const data - it is initialized once and the contents never change after that.
  111. //------------------------------------------------------------------------
  112. class LLVOAvatarDictionary : public LLSingleton<LLVOAvatarDictionary>
  113. {
  114. //--------------------------------------------------------------------
  115. // Constructors and Destructors
  116. //--------------------------------------------------------------------
  117. public:
  118. LLVOAvatarDictionary();
  119. virtual ~LLVOAvatarDictionary();
  120. private:
  121. void createAssociations();
  122. //--------------------------------------------------------------------
  123. // Local and baked textures
  124. //--------------------------------------------------------------------
  125. public:
  126. struct TextureEntry : public LLDictionaryEntry
  127. {
  128. TextureEntry(const std::string &name, // this must match the xml name used by LLTexLayerInfo::parseXml
  129. bool is_local_texture,
  130. EBakedTextureIndex baked_texture_index = BAKED_NUM_INDICES,
  131. const std::string& default_image_name = "",
  132. LLWearableType::EType wearable_type = LLWearableType::WT_INVALID);
  133. const std::string mDefaultImageName;
  134. const LLWearableType::EType mWearableType;
  135. // It's either a local texture xor baked
  136. BOOL mIsLocalTexture;
  137. BOOL mIsBakedTexture;
  138. // If it's a local texture, it may be used by a baked texture
  139. BOOL mIsUsedByBakedTexture;
  140. EBakedTextureIndex mBakedTextureIndex;
  141. };
  142. struct Textures : public LLDictionary<ETextureIndex, TextureEntry>
  143. {
  144. Textures();
  145. } mTextures;
  146. const TextureEntry* getTexture(ETextureIndex index) const { return mTextures.lookup(index); }
  147. const Textures& getTextures() const { return mTextures; }
  148. //--------------------------------------------------------------------
  149. // Meshes
  150. //--------------------------------------------------------------------
  151. public:
  152. struct MeshEntry : public LLDictionaryEntry
  153. {
  154. MeshEntry(EBakedTextureIndex baked_index,
  155. const std::string &name, // names of mesh types as they are used in avatar_lad.xml
  156. U8 level,
  157. LLViewerJoint::PickName pick);
  158. // Levels of Detail for each mesh. Must match levels of detail present in avatar_lad.xml
  159. // Otherwise meshes will be unable to be found, or levels of detail will be ignored
  160. const U8 mLOD;
  161. const EBakedTextureIndex mBakedID;
  162. const LLViewerJoint::PickName mPickName;
  163. };
  164. struct Meshes : public LLDictionary<EMeshIndex, MeshEntry>
  165. {
  166. Meshes();
  167. } mMeshes;
  168. const MeshEntry* getMesh(EMeshIndex index) const { return mMeshes.lookup(index); }
  169. const Meshes& getMeshes() const { return mMeshes; }
  170. //--------------------------------------------------------------------
  171. // Baked Textures
  172. //--------------------------------------------------------------------
  173. public:
  174. struct BakedEntry : public LLDictionaryEntry
  175. {
  176. BakedEntry(ETextureIndex tex_index,
  177. const std::string &name, // unused, but necessary for templating.
  178. const std::string &hash_name,
  179. U32 num_local_textures, ... ); // # local textures, local texture list, # wearables, wearable list
  180. // Local Textures
  181. const ETextureIndex mTextureIndex;
  182. texture_vec_t mLocalTextures;
  183. // Wearables
  184. const LLUUID mWearablesHashID;
  185. wearables_vec_t mWearables;
  186. };
  187. struct BakedTextures: public LLDictionary<EBakedTextureIndex, BakedEntry>
  188. {
  189. BakedTextures();
  190. } mBakedTextures;
  191. const BakedEntry* getBakedTexture(EBakedTextureIndex index) const { return mBakedTextures.lookup(index); }
  192. const BakedTextures& getBakedTextures() const { return mBakedTextures; }
  193. //--------------------------------------------------------------------
  194. // Convenience Functions
  195. //--------------------------------------------------------------------
  196. public:
  197. // Convert from baked texture to associated texture; e.g. BAKED_HEAD -> TEX_HEAD_BAKED
  198. static ETextureIndex bakedToLocalTextureIndex(EBakedTextureIndex t);
  199. // find a baked texture index based on its name
  200. static EBakedTextureIndex findBakedByRegionName(std::string name);
  201. static const LLUUID getDefaultTextureImageID(ETextureIndex index);
  202. // Given a texture entry, determine which wearable type owns it.
  203. static LLWearableType::EType getTEWearableType(ETextureIndex index);
  204. }; // End LLVOAvatarDictionary
  205. } // End namespace LLVOAvatarDefines
  206. #endif //LL_VO_AVATARDEFINES_H