llwearable.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. * @file llwearable.h
  3. * @brief LLWearable class header file
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-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_LLWEARABLE_H
  33. #define LL_LLWEARABLE_H
  34. #include "llavatarappearancedefines.h"
  35. #include "lllocaltextureobject.h"
  36. #include "llpermissions.h"
  37. #include "llsaleinfo.h"
  38. #include "llwearabletype.h"
  39. class LLAvatarAppearance;
  40. class LLMD5;
  41. class LLTexGlobalColor;
  42. class LLTexGlobalColorInfo;
  43. class LLViewerWearable;
  44. class LLVisualParam;
  45. // Abstract class.
  46. class LLWearable
  47. {
  48. protected:
  49. LOG_CLASS(LLWearable);
  50. public:
  51. LLWearable();
  52. virtual ~LLWearable();
  53. LL_INLINE virtual LLViewerWearable* asViewerWearable()
  54. {
  55. return NULL;
  56. }
  57. LL_INLINE virtual const LLViewerWearable* asViewerWearable() const
  58. {
  59. return NULL;
  60. }
  61. LL_INLINE LLWearableType::EType getType() const { return mType; }
  62. void setType(LLWearableType::EType type, LLAvatarAppearance* avatarp);
  63. LL_INLINE const std::string& getName() const { return mName; }
  64. LL_INLINE void setName(const std::string& name) { mName = name; }
  65. LL_INLINE const std::string& getDescription() const { return mDescription; }
  66. LL_INLINE void setDescription(const std::string& d) { mDescription = d; }
  67. LL_INLINE const LLPermissions& getPermissions() const
  68. {
  69. return mPermissions;
  70. }
  71. LL_INLINE void setPermissions(const LLPermissions& p)
  72. {
  73. mPermissions = p;
  74. }
  75. LL_INLINE const LLSaleInfo& getSaleInfo() const { return mSaleInfo; }
  76. LL_INLINE void setSaleInfo(const LLSaleInfo& info) { mSaleInfo = info; }
  77. const std::string& getTypeLabel() const;
  78. const std::string& getTypeName() const;
  79. LLAssetType::EType getAssetType() const;
  80. LL_INLINE S32 getDefinitionVersion() const { return mDefinitionVersion; }
  81. LL_INLINE void setDefinitionVersion(S32 version) { mDefinitionVersion = version; }
  82. LL_INLINE static S32 getCurrentDefinitionVersion() { return sCurrentDefinitionVersion; }
  83. LL_INLINE static void setCurrentDefinitionVersion(S32 version)
  84. {
  85. sCurrentDefinitionVersion = version;
  86. }
  87. typedef std::vector<LLVisualParam*> visual_param_vec_t;
  88. virtual void writeToAvatar(LLAvatarAppearance* avatarp);
  89. enum EImportResult
  90. {
  91. FAILURE = 0,
  92. SUCCESS,
  93. BAD_HEADER
  94. };
  95. bool exportFile(const std::string& filename) const;
  96. EImportResult importFile(const std::string& filename,
  97. LLAvatarAppearance* avatarp);
  98. virtual bool exportStream(std::ostream& output_stream) const;
  99. virtual EImportResult importStream(std::istream& input_stream,
  100. LLAvatarAppearance* avatarp);
  101. virtual LLUUID getDefaultTextureImageID(LLAvatarAppearanceDefines::ETextureIndex index) = 0;
  102. LLLocalTextureObject* getLocalTextureObject(S32 index);
  103. const LLLocalTextureObject* getLocalTextureObject(S32 index) const;
  104. void getLocalTextureListSeq(std::vector<LLLocalTextureObject*>& ltovec);
  105. LLLocalTextureObject* setLocalTextureObject(S32 index,
  106. LLLocalTextureObject& lto);
  107. void addVisualParam(LLVisualParam* param);
  108. void setVisualParamWeight(S32 index, F32 value,
  109. bool upload_bake);
  110. F32 getVisualParamWeight(S32 index) const;
  111. LLVisualParam* getVisualParam(S32 index) const;
  112. void getVisualParams(visual_param_vec_t& list);
  113. void animateParams(F32 delta, bool upload_bake);
  114. LLColor4 getClothesColor(S32 te) const;
  115. void setClothesColor(S32 te, const LLColor4& new_color, bool upload_bake);
  116. virtual void revertValues();
  117. virtual void saveValues();
  118. // Something happened that requires the wearable to be updated (e.g.
  119. // worn/unworn).
  120. virtual void setUpdated() const = 0;
  121. // Update the baked texture hash.
  122. virtual void addToBakedTextureHash(LLMD5& hash) const = 0;
  123. typedef std::map<S32, F32> param_map_t;
  124. typedef std::map<S32, LLVisualParam*> visual_param_index_map_t;
  125. protected:
  126. typedef std::map<S32, LLLocalTextureObject*> te_map_t;
  127. void syncImages(te_map_t& src, te_map_t& dst);
  128. void destroyTextures();
  129. void createVisualParams(LLAvatarAppearance* avatarp);
  130. void createLayers(S32 te, LLAvatarAppearance* avatarp);
  131. bool getNextPopulatedLine(std::istream& input_stream, char* buffer,
  132. U32 buffer_size);
  133. protected:
  134. std::string mName;
  135. std::string mDescription;
  136. LLPermissions mPermissions;
  137. LLSaleInfo mSaleInfo;
  138. LLWearableType::EType mType;
  139. // Last saved version of visual params
  140. param_map_t mSavedVisualParamMap;
  141. visual_param_index_map_t mVisualParamIndexMap;
  142. te_map_t mTEMap; // maps TE to LocalTextureObject
  143. te_map_t mSavedTEMap; // last saved version of TEMap
  144. // Depends on the state of the avatar_lad.xml when this asset was created:
  145. S32 mDefinitionVersion;
  146. // Depends on the current state of the avatar_lad.xml:
  147. static S32 sCurrentDefinitionVersion;
  148. public:
  149. static fast_hset<LLWearable*> sWearableList;
  150. };
  151. #endif // LL_LLWEARABLE_H