PageRenderTime 204ms CodeModel.GetById 111ms app.highlight 12ms RepoModel.GetById 78ms app.codeStats 1ms

/indra/newview/llwlparamset.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 238 lines | 94 code | 62 blank | 82 comment | 1 complexity | 83398e0250589eafe0d8e847ba90f75e MD5 | raw file
  1/**
  2 * @file llwlparamset.h
  3 * @brief Interface for the LLWLParamSet class.
  4 *
  5 * $LicenseInfo:firstyear=2005&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_WLPARAM_SET_H
 28#define LL_WLPARAM_SET_H
 29
 30#include <string>
 31#include <map>
 32
 33#include "v4math.h"
 34#include "v4color.h"
 35
 36class LLWLParamSet;
 37class LLGLSLShader;
 38
 39/// A class representing a set of parameter values for the WindLight shaders.
 40class LLWLParamSet {
 41
 42	friend class LLWLParamManager;
 43
 44public:
 45	std::string mName;	
 46	
 47private:
 48
 49	LLSD mParamValues;
 50	
 51	float mCloudScrollXOffset, mCloudScrollYOffset;
 52
 53public:
 54
 55	LLWLParamSet();
 56
 57	/// Update this set of shader uniforms from the parameter values.
 58	void update(LLGLSLShader * shader) const;
 59
 60	/// set the total llsd
 61	void setAll(const LLSD& val);
 62	
 63	/// get the total llsd
 64	const LLSD& getAll();		
 65	
 66
 67	/// Set a float parameter.
 68	/// \param paramName	The name of the parameter to set.
 69	/// \param x			The float value to set.
 70	void set(const std::string& paramName, float x);
 71
 72	/// Set a float2 parameter.
 73	/// \param paramName	The name of the parameter to set.
 74	/// \param x			The x component's value to set.
 75	/// \param y			The y component's value to set.
 76	void set(const std::string& paramName, float x, float y);
 77
 78	/// Set a float3 parameter.
 79	/// \param paramName	The name of the parameter to set.
 80	/// \param x			The x component's value to set.
 81	/// \param y			The y component's value to set.
 82	/// \param z			The z component's value to set.
 83	void set(const std::string& paramName, float x, float y, float z);
 84
 85	/// Set a float4 parameter.
 86	/// \param paramName	The name of the parameter to set.
 87	/// \param x			The x component's value to set.
 88	/// \param y			The y component's value to set.
 89	/// \param z			The z component's value to set.
 90	/// \param w			The w component's value to set.
 91	void set(const std::string& paramName, float x, float y, float z, float w);
 92
 93	/// Set a float4 parameter.
 94	/// \param paramName	The name of the parameter to set.
 95	/// \param val			An array of the 4 float values to set the parameter to.
 96	void set(const std::string& paramName, const float * val);
 97
 98	/// Set a float4 parameter.
 99	/// \param paramName	The name of the parameter to set.
100	/// \param val			A struct of the 4 float values to set the parameter to.
101	void set(const std::string& paramName, const LLVector4 & val);
102
103	/// Set a float4 parameter.
104	/// \param paramName	The name of the parameter to set.
105	/// \param val			A struct of the 4 float values to set the parameter to.
106	void set(const std::string& paramName, const LLColor4 & val);
107
108	/// Get a float4 parameter.
109	/// \param paramName	The name of the parameter to set.
110	/// \param error		A flag to set if it's not the proper return type
111	LLVector4 getVector(const std::string& paramName, bool& error);
112
113	/// Get an integer parameter
114	/// \param paramName	The name of the parameter to set.
115	/// \param error		A flag to set if it's not the proper return type	
116	F32 getFloat(const std::string& paramName, bool& error);
117	
118	
119	// specific getters and setters
120	
121	
122	/// set the star's brightness
123	/// \param val brightness value
124	void setStarBrightness(F32 val);
125	
126	/// get the star brightness value;
127	F32 getStarBrightness();	
128	
129	void setSunAngle(F32 val);
130	F32 getSunAngle();	
131	
132	void setEastAngle(F32 val);
133	F32 getEastAngle();	
134	
135							
136	
137	/// set the cloud scroll x enable value
138	/// \param val scroll x value	
139	void setEnableCloudScrollX(bool val);
140
141	/// get the scroll x enable value;	
142	bool getEnableCloudScrollX();
143	
144	/// set the star's brightness
145	/// \param val scroll y bool value		
146	void setEnableCloudScrollY(bool val);	
147
148	/// get the scroll enable y value;
149	bool getEnableCloudScrollY();
150	
151	/// set the cloud scroll x enable value
152	/// \param val scroll x value	
153	void setCloudScrollX(F32 val);
154
155	/// get the scroll x enable value;	
156	F32 getCloudScrollX();
157	
158	/// set the star's brightness
159	/// \param val scroll y bool value		
160	void setCloudScrollY(F32 val);	
161
162	/// get the scroll enable y value;
163	F32 getCloudScrollY();	
164
165	/// interpolate two parameter sets
166	/// \param src			The parameter set to start with
167	/// \param dest			The parameter set to end with
168	/// \param weight		The amount to interpolate
169	void mix(LLWLParamSet& src, LLWLParamSet& dest, 
170		F32 weight);
171
172	void updateCloudScrolling(void);
173};
174
175inline void LLWLParamSet::setAll(const LLSD& val)
176{
177	if(val.isMap()) {
178		mParamValues = val;
179	}
180}
181
182inline const LLSD& LLWLParamSet::getAll()
183{
184	return mParamValues;
185}
186
187inline void LLWLParamSet::setStarBrightness(float val) {
188	mParamValues["star_brightness"] = val;
189}
190
191inline F32 LLWLParamSet::getStarBrightness() {
192	return (F32) mParamValues["star_brightness"].asReal();
193}
194
195inline F32 LLWLParamSet::getSunAngle() {
196	return (F32) mParamValues["sun_angle"].asReal();
197}
198
199inline F32 LLWLParamSet::getEastAngle() {
200	return (F32) mParamValues["east_angle"].asReal();
201}
202
203
204inline void LLWLParamSet::setEnableCloudScrollX(bool val) {
205	mParamValues["enable_cloud_scroll"][0] = val;
206}
207
208inline bool LLWLParamSet::getEnableCloudScrollX() {
209	return mParamValues["enable_cloud_scroll"][0].asBoolean();
210}
211
212inline void LLWLParamSet::setEnableCloudScrollY(bool val) {
213	mParamValues["enable_cloud_scroll"][1] = val;
214}
215
216inline bool LLWLParamSet::getEnableCloudScrollY() {
217	return mParamValues["enable_cloud_scroll"][1].asBoolean();
218}
219
220
221inline void LLWLParamSet::setCloudScrollX(F32 val) {
222	mParamValues["cloud_scroll_rate"][0] = val;
223}
224
225inline F32 LLWLParamSet::getCloudScrollX() {
226	return (F32) mParamValues["cloud_scroll_rate"][0].asReal();
227}
228
229inline void LLWLParamSet::setCloudScrollY(F32 val) {
230	mParamValues["cloud_scroll_rate"][1] = val;
231}
232
233inline F32 LLWLParamSet::getCloudScrollY() {
234	return (F32) mParamValues["cloud_scroll_rate"][1].asReal();
235}
236
237
238#endif // LL_WLPARAM_SET_H