PageRenderTime 485ms CodeModel.GetById 271ms app.highlight 14ms RepoModel.GetById 198ms app.codeStats 0ms

/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
 27#ifndef LL_LLWEARABLE_H
 28#define LL_LLWEARABLE_H
 29
 30#include "lluuid.h"
 31#include "llstring.h"
 32#include "llpermissions.h"
 33#include "llsaleinfo.h"
 34#include "llassetstorage.h"
 35#include "llwearabletype.h"
 36#include "llfile.h"
 37#include "lllocaltextureobject.h"
 38
 39class LLViewerInventoryItem;
 40class LLVisualParam;
 41class LLTexGlobalColorInfo;
 42class LLTexGlobalColor;
 43
 44class LLWearable
 45{
 46	friend class LLWearableList;
 47
 48	//--------------------------------------------------------------------
 49	// Constructors and destructors
 50	//--------------------------------------------------------------------
 51private:
 52	// Private constructors used by LLWearableList
 53	LLWearable(const LLTransactionID& transactionID);
 54	LLWearable(const LLAssetID& assetID);
 55public:
 56	virtual ~LLWearable();
 57
 58	//--------------------------------------------------------------------
 59	// Accessors
 60	//--------------------------------------------------------------------
 61public:
 62	const LLUUID&				getItemID() const;
 63	const LLAssetID&			getAssetID() const { return mAssetID; }
 64	const LLTransactionID&		getTransactionID() const { return mTransactionID; }
 65	LLWearableType::EType				getType() const	{ return mType; }
 66	void						setType(LLWearableType::EType type);
 67	const std::string&			getName() const	{ return mName; }
 68	void						setName(const std::string& name) { mName = name; }
 69	const std::string&			getDescription() const { return mDescription; }
 70	void						setDescription(const std::string& desc)	{ mDescription = desc; }
 71	const LLPermissions& 		getPermissions() const { return mPermissions; }
 72	void						setPermissions(const LLPermissions& p) { mPermissions = p; }
 73	const LLSaleInfo&			getSaleInfo() const	{ return mSaleInfo; }
 74	void						setSaleInfo(const LLSaleInfo& info)	{ mSaleInfo = info; }
 75	const std::string&			getTypeLabel() const;
 76	const std::string&			getTypeName() const;
 77	LLAssetType::EType			getAssetType() const;
 78	S32							getDefinitionVersion() const { return mDefinitionVersion; }
 79	void						setDefinitionVersion( S32 new_version ) { mDefinitionVersion = new_version; }
 80
 81public:
 82	typedef std::vector<LLVisualParam*> visual_param_vec_t;
 83
 84	BOOL				isDirty() const;
 85	BOOL				isOldVersion() const;
 86
 87	void				writeToAvatar();
 88	void				removeFromAvatar( BOOL upload_bake )	{ LLWearable::removeFromAvatar( mType, upload_bake ); }
 89	static void			removeFromAvatar( LLWearableType::EType type, BOOL upload_bake ); 
 90
 91	BOOL				exportFile(LLFILE* file) const;
 92	BOOL				importFile(LLFILE* file);
 93	
 94	void				setParamsToDefaults();
 95	void				setTexturesToDefaults();
 96
 97	void				saveNewAsset() const;
 98	static void			onSaveNewAssetComplete( const LLUUID& asset_uuid, void* user_data, S32 status, LLExtStat ext_status );
 99
100	void				copyDataFrom(const LLWearable* src);
101
102	static void			setCurrentDefinitionVersion( S32 version ) { LLWearable::sCurrentDefinitionVersion = version; }
103
104	friend std::ostream& operator<<(std::ostream &s, const LLWearable &w);
105	void				setItemID(const LLUUID& item_id);
106
107	LLLocalTextureObject* getLocalTextureObject(S32 index);
108	const LLLocalTextureObject* getLocalTextureObject(S32 index) const;
109
110	void				setLocalTextureObject(S32 index, LLLocalTextureObject &lto);
111	void				addVisualParam(LLVisualParam *param);
112	void				setVisualParams();
113	void 				setVisualParamWeight(S32 index, F32 value, BOOL upload_bake);
114	F32					getVisualParamWeight(S32 index) const;
115	LLVisualParam*		getVisualParam(S32 index) const;
116	void				getVisualParams(visual_param_vec_t &list);
117	void				animateParams(F32 delta, BOOL upload_bake);
118
119	LLColor4			getClothesColor(S32 te) const;
120	void 				setClothesColor( S32 te, const LLColor4& new_color, BOOL upload_bake );
121
122	void				revertValues();
123	void				saveValues();
124	void				pullCrossWearableValues();		
125
126	BOOL				isOnTop() const;
127
128	// Something happened that requires the wearable's label to be updated (e.g. worn/unworn).
129	void				setLabelUpdated() const;
130
131	// the wearable was worn. make sure the name of the wearable object matches the LLViewerInventoryItem,
132	// not the wearable asset itself.
133	void				refreshName();
134
135private:
136	typedef std::map<S32, LLLocalTextureObject*> te_map_t;
137	typedef std::map<S32, LLVisualParam *>    visual_param_index_map_t;
138
139	void 				createLayers(S32 te);
140	void 				createVisualParams();
141	void				syncImages(te_map_t &src, te_map_t &dst);
142	void				destroyTextures();	
143
144	static S32			sCurrentDefinitionVersion;	// Depends on the current state of the avatar_lad.xml.
145	S32					mDefinitionVersion;			// Depends on the state of the avatar_lad.xml when this asset was created.
146	std::string			mName;
147	std::string			mDescription;
148	LLPermissions		mPermissions;
149	LLSaleInfo			mSaleInfo;
150	LLAssetID mAssetID;
151	LLTransactionID		mTransactionID;
152	LLWearableType::EType		mType;
153
154	typedef std::map<S32, F32> param_map_t;
155	param_map_t mSavedVisualParamMap; // last saved version of visual params
156
157	visual_param_index_map_t mVisualParamIndexMap;
158
159	te_map_t mTEMap;				// maps TE to LocalTextureObject
160	te_map_t mSavedTEMap;			// last saved version of TEMap
161	LLUUID				mItemID;  // ID of the inventory item in the agent's inventory	
162};
163
164#endif  // LL_LLWEARABLE_H