PageRenderTime 55ms CodeModel.GetById 41ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/lltexlayerparams.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 193 lines | 118 code | 26 blank | 49 comment | 0 complexity | 09fde44d5e7f8280db7609b0277da440 MD5 | raw file
  1/** 
  2 * @file lltexlayerparams.h
  3 * @brief Texture layer parameters, used by lltexlayer.
  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_LLTEXLAYERPARAMS_H
 28#define LL_LLTEXLAYERPARAMS_H
 29
 30#include "llviewervisualparam.h"
 31
 32class LLImageRaw;
 33class LLImageTGA;
 34class LLTexLayer;
 35class LLTexLayerInterface;
 36class LLViewerTexture;
 37class LLVOAvatar;
 38class LLWearable;
 39
 40//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 41// LLTexLayerParam
 42// 
 43//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 44class LLTexLayerParam : public LLViewerVisualParam
 45{
 46public: 
 47	LLTexLayerParam(LLTexLayerInterface *layer);
 48	LLTexLayerParam(LLVOAvatar *avatar);
 49	/*virtual*/ BOOL setInfo(LLViewerVisualParamInfo *info, BOOL add_to_avatar  );
 50	/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable) const = 0;
 51
 52protected:
 53	LLTexLayerInterface*	mTexLayer;
 54	LLVOAvatar*             mAvatar;
 55};
 56
 57//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 58// LLTexLayerParamAlpha
 59// 
 60//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 61class LLTexLayerParamAlpha : public LLTexLayerParam
 62{
 63public:
 64	LLTexLayerParamAlpha( LLTexLayerInterface* layer );
 65	LLTexLayerParamAlpha( LLVOAvatar* avatar );
 66	/*virtual*/ ~LLTexLayerParamAlpha();
 67
 68	/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable = NULL) const;
 69
 70	// LLVisualParam Virtual functions
 71	///*virtual*/ BOOL		parseData(LLXmlTreeNode* node);
 72	/*virtual*/ void		apply( ESex avatar_sex ) {}
 73	/*virtual*/ void		setWeight(F32 weight, BOOL upload_bake);
 74	/*virtual*/ void		setAnimationTarget(F32 target_value, BOOL upload_bake); 
 75	/*virtual*/ void		animate(F32 delta, BOOL upload_bake);
 76
 77	// LLViewerVisualParam Virtual functions
 78	/*virtual*/ F32					getTotalDistortion()									{ return 1.f; }
 79	/*virtual*/ const LLVector3&	getAvgDistortion()										{ return mAvgDistortionVec; }
 80	/*virtual*/ F32					getMaxDistortion()										{ return 3.f; }
 81	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector3(1.f, 1.f, 1.f);}
 82	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
 83	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
 84
 85	// New functions
 86	BOOL					render( S32 x, S32 y, S32 width, S32 height );
 87	BOOL					getSkip() const;
 88	void					deleteCaches();
 89	BOOL					getMultiplyBlend() const;
 90
 91private:
 92	LLPointer<LLViewerTexture>	mCachedProcessedTexture;
 93	LLPointer<LLImageTGA>	mStaticImageTGA;
 94	LLPointer<LLImageRaw>	mStaticImageRaw;
 95	BOOL					mNeedsCreateTexture;
 96	BOOL					mStaticImageInvalid;
 97	LLVector3				mAvgDistortionVec;
 98	F32						mCachedEffectiveWeight;
 99
100public:
101	// Global list of instances for gathering statistics
102	static void				dumpCacheByteCount();
103	static void				getCacheByteCount( S32* gl_bytes );
104
105	typedef std::list< LLTexLayerParamAlpha* > param_alpha_ptr_list_t;
106	static param_alpha_ptr_list_t sInstances;
107};
108class LLTexLayerParamAlphaInfo : public LLViewerVisualParamInfo
109{
110	friend class LLTexLayerParamAlpha;
111public:
112	LLTexLayerParamAlphaInfo();
113	/*virtual*/ ~LLTexLayerParamAlphaInfo() {};
114
115	/*virtual*/ BOOL parseXml(LLXmlTreeNode* node);
116
117private:
118	std::string				mStaticImageFileName;
119	BOOL					mMultiplyBlend;
120	BOOL					mSkipIfZeroWeight;
121	F32						mDomain;
122};
123//
124// LLTexLayerParamAlpha
125//-----------------------------------------------------------------------------
126
127//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
128// LLTexLayerParamColor
129//
130//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131class LLTexLayerParamColor : public LLTexLayerParam
132{
133public:
134	enum EColorOperation
135	{
136		OP_ADD = 0,
137		OP_MULTIPLY = 1,
138		OP_BLEND = 2,
139		OP_COUNT = 3 // Number of operations
140	};
141
142	LLTexLayerParamColor( LLTexLayerInterface* layer );
143	LLTexLayerParamColor( LLVOAvatar* avatar );
144	/* virtual */ ~LLTexLayerParamColor();
145
146	/*virtual*/ LLViewerVisualParam* cloneParam(LLWearable* wearable = NULL) const;
147
148	// LLVisualParam Virtual functions
149	///*virtual*/ BOOL			parseData(LLXmlTreeNode* node);
150	/*virtual*/ void			apply( ESex avatar_sex ) {}
151	/*virtual*/ void			setWeight(F32 weight, BOOL upload_bake);
152	/*virtual*/ void			setAnimationTarget(F32 target_value, BOOL upload_bake);
153	/*virtual*/ void			animate(F32 delta, BOOL upload_bake);
154
155
156	// LLViewerVisualParam Virtual functions
157	/*virtual*/ F32					getTotalDistortion()									{ return 1.f; }
158	/*virtual*/ const LLVector3&	getAvgDistortion()										{ return mAvgDistortionVec; }
159	/*virtual*/ F32					getMaxDistortion()										{ return 3.f; }
160	/*virtual*/ LLVector3			getVertexDistortion(S32 index, LLPolyMesh *poly_mesh)	{ return LLVector3(1.f, 1.f, 1.f); }
161	/*virtual*/ const LLVector3*	getFirstDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return &mAvgDistortionVec;};
162	/*virtual*/ const LLVector3*	getNextDistortion(U32 *index, LLPolyMesh **poly_mesh)	{ index = 0; poly_mesh = NULL; return NULL;};
163
164	// New functions
165	LLColor4				getNetColor() const;
166protected:
167	virtual void onGlobalColorChanged(bool upload_bake) {}
168private:
169	LLVector3				mAvgDistortionVec;
170};
171
172class LLTexLayerParamColorInfo : public LLViewerVisualParamInfo
173{
174	friend class LLTexLayerParamColor;
175
176public:
177	LLTexLayerParamColorInfo();
178	virtual ~LLTexLayerParamColorInfo() {};
179	BOOL parseXml( LLXmlTreeNode* node );
180	LLTexLayerParamColor::EColorOperation getOperation() const { return mOperation; }
181private:
182	enum { MAX_COLOR_VALUES = 20 };
183	LLTexLayerParamColor::EColorOperation		mOperation;
184	LLColor4			mColors[MAX_COLOR_VALUES];
185	S32					mNumColors;
186};
187
188typedef std::vector<LLTexLayerParamColor *> param_color_list_t;
189typedef std::vector<LLTexLayerParamAlpha *> param_alpha_list_t;
190typedef std::vector<LLTexLayerParamColorInfo *> param_color_info_list_t;
191typedef std::vector<LLTexLayerParamAlphaInfo *> param_alpha_info_list_t;
192
193#endif