/indra/newview/llwearable.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 164 lines · 100 code · 29 blank · 35 comment · 0 complexity · 9afa3e4338f0360efbbcfbd7589c42ae MD5 · raw file

  1. /**
  2. * @file llwearable.h
  3. * @brief LLWearable class header file
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLWEARABLE_H
  27. #define LL_LLWEARABLE_H
  28. #include "lluuid.h"
  29. #include "llstring.h"
  30. #include "llpermissions.h"
  31. #include "llsaleinfo.h"
  32. #include "llassetstorage.h"
  33. #include "llwearabletype.h"
  34. #include "llfile.h"
  35. #include "lllocaltextureobject.h"
  36. class LLViewerInventoryItem;
  37. class LLVisualParam;
  38. class LLTexGlobalColorInfo;
  39. class LLTexGlobalColor;
  40. class LLWearable
  41. {
  42. friend class LLWearableList;
  43. //--------------------------------------------------------------------
  44. // Constructors and destructors
  45. //--------------------------------------------------------------------
  46. private:
  47. // Private constructors used by LLWearableList
  48. LLWearable(const LLTransactionID& transactionID);
  49. LLWearable(const LLAssetID& assetID);
  50. public:
  51. virtual ~LLWearable();
  52. //--------------------------------------------------------------------
  53. // Accessors
  54. //--------------------------------------------------------------------
  55. public:
  56. const LLUUID& getItemID() const;
  57. const LLAssetID& getAssetID() const { return mAssetID; }
  58. const LLTransactionID& getTransactionID() const { return mTransactionID; }
  59. LLWearableType::EType getType() const { return mType; }
  60. void setType(LLWearableType::EType type);
  61. const std::string& getName() const { return mName; }
  62. void setName(const std::string& name) { mName = name; }
  63. const std::string& getDescription() const { return mDescription; }
  64. void setDescription(const std::string& desc) { mDescription = desc; }
  65. const LLPermissions& getPermissions() const { return mPermissions; }
  66. void setPermissions(const LLPermissions& p) { mPermissions = p; }
  67. const LLSaleInfo& getSaleInfo() const { return mSaleInfo; }
  68. void setSaleInfo(const LLSaleInfo& info) { mSaleInfo = info; }
  69. const std::string& getTypeLabel() const;
  70. const std::string& getTypeName() const;
  71. LLAssetType::EType getAssetType() const;
  72. S32 getDefinitionVersion() const { return mDefinitionVersion; }
  73. void setDefinitionVersion( S32 new_version ) { mDefinitionVersion = new_version; }
  74. public:
  75. typedef std::vector<LLVisualParam*> visual_param_vec_t;
  76. BOOL isDirty() const;
  77. BOOL isOldVersion() const;
  78. void writeToAvatar();
  79. void removeFromAvatar( BOOL upload_bake ) { LLWearable::removeFromAvatar( mType, upload_bake ); }
  80. static void removeFromAvatar( LLWearableType::EType type, BOOL upload_bake );
  81. BOOL exportFile(LLFILE* file) const;
  82. BOOL importFile(LLFILE* file);
  83. void setParamsToDefaults();
  84. void setTexturesToDefaults();
  85. void saveNewAsset() const;
  86. static void onSaveNewAssetComplete( const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status );
  87. void copyDataFrom(const LLWearable* src);
  88. static void setCurrentDefinitionVersion( S32 version ) { LLWearable::sCurrentDefinitionVersion = version; }
  89. friend std::ostream& operator<<(std::ostream &s, const LLWearable &w);
  90. void setItemID(const LLUUID& item_id);
  91. LLLocalTextureObject* getLocalTextureObject(S32 index);
  92. const LLLocalTextureObject* getLocalTextureObject(S32 index) const;
  93. void setLocalTextureObject(S32 index, LLLocalTextureObject &lto);
  94. void addVisualParam(LLVisualParam *param);
  95. void setVisualParams();
  96. void setVisualParamWeight(S32 index, F32 value, BOOL upload_bake);
  97. F32 getVisualParamWeight(S32 index) const;
  98. LLVisualParam* getVisualParam(S32 index) const;
  99. void getVisualParams(visual_param_vec_t &list);
  100. void animateParams(F32 delta, BOOL upload_bake);
  101. LLColor4 getClothesColor(S32 te) const;
  102. void setClothesColor( S32 te, const LLColor4& new_color, BOOL upload_bake );
  103. void revertValues();
  104. void saveValues();
  105. void pullCrossWearableValues();
  106. BOOL isOnTop() const;
  107. // Something happened that requires the wearable's label to be updated (e.g. worn/unworn).
  108. void setLabelUpdated() const;
  109. // the wearable was worn. make sure the name of the wearable object matches the LLViewerInventoryItem,
  110. // not the wearable asset itself.
  111. void refreshName();
  112. private:
  113. typedef std::map<S32, LLLocalTextureObject*> te_map_t;
  114. typedef std::map<S32, LLVisualParam *> visual_param_index_map_t;
  115. void createLayers(S32 te);
  116. void createVisualParams();
  117. void syncImages(te_map_t &src, te_map_t &dst);
  118. void destroyTextures();
  119. static S32 sCurrentDefinitionVersion; // Depends on the current state of the avatar_lad.xml.
  120. S32 mDefinitionVersion; // Depends on the state of the avatar_lad.xml when this asset was created.
  121. std::string mName;
  122. std::string mDescription;
  123. LLPermissions mPermissions;
  124. LLSaleInfo mSaleInfo;
  125. LLAssetID mAssetID;
  126. LLTransactionID mTransactionID;
  127. LLWearableType::EType mType;
  128. typedef std::map<S32, F32> param_map_t;
  129. param_map_t mSavedVisualParamMap; // last saved version of visual params
  130. visual_param_index_map_t mVisualParamIndexMap;
  131. te_map_t mTEMap; // maps TE to LocalTextureObject
  132. te_map_t mSavedTEMap; // last saved version of TEMap
  133. LLUUID mItemID; // ID of the inventory item in the agent's inventory
  134. };
  135. #endif // LL_LLWEARABLE_H