PageRenderTime 36ms CodeModel.GetById 14ms app.highlight 16ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llwaterparamset.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 150 lines | 49 code | 29 blank | 72 comment | 3 complexity | db15e7161863e9a5451e89f7fbd1c292 MD5 | raw file
  1/**
  2 * @file llwlparamset.h
  3 * @brief Interface for the LLWaterParamSet 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_WATER_PARAM_SET_H
 28#define LL_WATER_PARAM_SET_H
 29
 30#include <string>
 31#include <map>
 32
 33#include "v4math.h"
 34#include "v4color.h"
 35#include "llviewershadermgr.h"
 36
 37class LLWaterParamSet;
 38
 39/// A class representing a set of parameter values for the Water shaders.
 40class LLWaterParamSet 
 41{
 42	friend class LLWaterParamManager;
 43
 44public:
 45	std::string mName;	
 46	
 47private:
 48
 49	LLSD mParamValues;
 50
 51public:
 52
 53	LLWaterParamSet();
 54
 55	/// Bind this set of parameter values to the uniforms of a particular shader.
 56	void update(LLGLSLShader * shader) const;
 57
 58	/// set the total llsd
 59	void setAll(const LLSD& val);
 60	
 61	/// get the total llsd
 62	const LLSD& getAll();		
 63
 64	/// Set a float parameter.
 65	/// \param paramName	The name of the parameter to set.
 66	/// \param x			The float value to set.
 67	void set(const std::string& paramName, float x);
 68
 69	/// Set a float2 parameter.
 70	/// \param paramName	The name of the parameter to set.
 71	/// \param x			The x component's value to set.
 72	/// \param y			The y component's value to set.
 73	void set(const std::string& paramName, float x, float y);
 74
 75	/// Set a float3 parameter.
 76	/// \param paramName	The name of the parameter to set.
 77	/// \param x			The x component's value to set.
 78	/// \param y			The y component's value to set.
 79	/// \param z			The z component's value to set.
 80	void set(const std::string& paramName, float x, float y, float z);
 81
 82	/// Set a float4 parameter.
 83	/// \param paramName	The name of the parameter to set.
 84	/// \param x			The x component's value to set.
 85	/// \param y			The y component's value to set.
 86	/// \param z			The z component's value to set.
 87	/// \param w			The w component's value to set.
 88	void set(const std::string& paramName, float x, float y, float z, float w);
 89
 90	/// Set a float4 parameter.
 91	/// \param paramName	The name of the parameter to set.
 92	/// \param val			An array of the 4 float values to set the parameter to.
 93	void set(const std::string& paramName, const float * val);
 94
 95	/// Set a float4 parameter.
 96	/// \param paramName	The name of the parameter to set.
 97	/// \param val			A struct of the 4 float values to set the parameter to.
 98	void set(const std::string& paramName, const LLVector4 & val);
 99
100	/// Set a float4 parameter.
101	/// \param paramName	The name of the parameter to set.
102	/// \param val			A struct of the 4 float values to set the parameter to.
103	void set(const std::string& paramName, const LLColor4 & val);
104
105	/// Get a float4 parameter.
106	/// \param paramName	The name of the parameter to set.
107	/// \param error		A flag to set if it's not the proper return type
108	LLVector4 getVector4(const std::string& paramName, bool& error);
109
110	/// Get a float3 parameter.
111	/// \param paramName	The name of the parameter to set.
112	/// \param error		A flag to set if it's not the proper return type
113	LLVector3 getVector3(const std::string& paramName, bool& error);
114	
115	/// Get a float2 parameter.
116	/// \param paramName	The name of the parameter to set.
117	/// \param error		A flag to set if it's not the proper return type
118	LLVector2 getVector2(const std::string& paramName, bool& error);
119	
120	/// Get an integer parameter
121	/// \param paramName	The name of the parameter to set.
122	/// \param error		A flag to set if it's not the proper return type	
123	F32 getFloat(const std::string& paramName, bool& error);
124		
125	/// interpolate two parameter sets
126	/// \param src			The parameter set to start with
127	/// \param dest			The parameter set to end with
128	/// \param weight		The amount to interpolate
129	void mix(LLWaterParamSet& src, LLWaterParamSet& dest, 
130		F32 weight);
131
132};
133
134inline void LLWaterParamSet::setAll(const LLSD& val)
135{
136	if(val.isMap()) {
137		LLSD::map_const_iterator mIt = val.beginMap();
138		for(; mIt != val.endMap(); mIt++)
139		{
140			mParamValues[mIt->first] = mIt->second;
141		}
142	}
143}
144
145inline const LLSD& LLWaterParamSet::getAll()
146{
147	return mParamValues;
148}
149
150#endif // LL_WaterPARAM_SET_H