diff options
author | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:45:34 -0500 |
commit | cd17687f01420952712a500107e0f93e7ab8d5f8 (patch) | |
tree | ce48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llwaterparamset.cpp | |
parent | Second Life viewer sources 1.19.0.5 (diff) | |
download | meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2 meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz |
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/newview/llwaterparamset.cpp')
-rw-r--r-- | linden/indra/newview/llwaterparamset.cpp | 233 |
1 files changed, 233 insertions, 0 deletions
diff --git a/linden/indra/newview/llwaterparamset.cpp b/linden/indra/newview/llwaterparamset.cpp new file mode 100644 index 0000000..d3068a7 --- /dev/null +++ b/linden/indra/newview/llwaterparamset.cpp | |||
@@ -0,0 +1,233 @@ | |||
1 | /** | ||
2 | * @file llwaterparamset.cpp | ||
3 | * @brief Implementation for the LLWaterParamSet class. | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2005&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2005-2008, Linden Research, Inc. | ||
8 | * | ||
9 | * Second Life Viewer Source Code | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
31 | |||
32 | #include "llviewerprecompiledheaders.h" | ||
33 | |||
34 | #include "llwaterparamset.h" | ||
35 | #include "llsd.h" | ||
36 | |||
37 | #include "llfloaterwater.h" | ||
38 | #include "llwaterparammanager.h" | ||
39 | #include "lluictrlfactory.h" | ||
40 | #include "llsliderctrl.h" | ||
41 | #include "llviewerimagelist.h" | ||
42 | #include "llviewercontrol.h" | ||
43 | #include "lluuid.h" | ||
44 | |||
45 | #include <llgl.h> | ||
46 | |||
47 | #include <sstream> | ||
48 | |||
49 | LLWaterParamSet::LLWaterParamSet(void) : | ||
50 | mName("Unnamed Preset") | ||
51 | { | ||
52 | LLSD vec4; | ||
53 | LLSD vec3; | ||
54 | LLSD real(0.0f); | ||
55 | |||
56 | vec4 = LLSD::emptyArray(); | ||
57 | vec4.append(22.f/255.f); | ||
58 | vec4.append(43.f/255.f); | ||
59 | vec4.append(54.f/255.f); | ||
60 | vec4.append(0.f/255.f); | ||
61 | |||
62 | vec3 = LLSD::emptyArray(); | ||
63 | vec3.append(2); | ||
64 | vec3.append(2); | ||
65 | vec3.append(2); | ||
66 | |||
67 | LLSD wave1, wave2; | ||
68 | wave1 = LLSD::emptyArray(); | ||
69 | wave2 = LLSD::emptyArray(); | ||
70 | wave1.append(0.5f); | ||
71 | wave1.append(-.17f); | ||
72 | wave2.append(0.58f); | ||
73 | wave2.append(-.67f); | ||
74 | |||
75 | LLUUID normalMap = LLUUID(gViewerArt.getString("water_normal.tga")); | ||
76 | |||
77 | mParamValues.insert("waterFogColor", vec4); | ||
78 | mParamValues.insert("waterFogDensity", 16.0f); | ||
79 | mParamValues.insert("underWaterFogMod", 0.25f); | ||
80 | mParamValues.insert("normScale", vec3); | ||
81 | mParamValues.insert("fresnelScale", 0.5f); | ||
82 | mParamValues.insert("fresnelOffset", 0.4f); | ||
83 | mParamValues.insert("scaleAbove", 0.025f); | ||
84 | mParamValues.insert("scaleBelow", 0.2f); | ||
85 | mParamValues.insert("blurMultiplier", 0.01f); | ||
86 | mParamValues.insert("wave1Dir", wave1); | ||
87 | mParamValues.insert("wave2Dir", wave2); | ||
88 | mParamValues.insert("normalMap", normalMap); | ||
89 | |||
90 | } | ||
91 | |||
92 | void LLWaterParamSet::set(const char * paramName, float x) | ||
93 | { | ||
94 | // handle case where no array | ||
95 | if(mParamValues[paramName].isReal()) | ||
96 | { | ||
97 | mParamValues[paramName] = x; | ||
98 | } | ||
99 | |||
100 | // handle array | ||
101 | else if(mParamValues[paramName].isArray() && | ||
102 | mParamValues[paramName][0].isReal()) | ||
103 | { | ||
104 | mParamValues[paramName][0] = x; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | void LLWaterParamSet::set(const char * paramName, float x, float y) { | ||
109 | mParamValues[paramName][0] = x; | ||
110 | mParamValues[paramName][1] = y; | ||
111 | } | ||
112 | |||
113 | void LLWaterParamSet::set(const char * paramName, float x, float y, float z) | ||
114 | { | ||
115 | mParamValues[paramName][0] = x; | ||
116 | mParamValues[paramName][1] = y; | ||
117 | mParamValues[paramName][2] = z; | ||
118 | } | ||
119 | |||
120 | void LLWaterParamSet::set(const char * paramName, float x, float y, float z, float w) | ||
121 | { | ||
122 | mParamValues[paramName][0] = x; | ||
123 | mParamValues[paramName][1] = y; | ||
124 | mParamValues[paramName][2] = z; | ||
125 | mParamValues[paramName][3] = w; | ||
126 | } | ||
127 | |||
128 | void LLWaterParamSet::set(const char * paramName, const float * val) | ||
129 | { | ||
130 | mParamValues[paramName][0] = val[0]; | ||
131 | mParamValues[paramName][1] = val[1]; | ||
132 | mParamValues[paramName][2] = val[2]; | ||
133 | mParamValues[paramName][3] = val[3]; | ||
134 | } | ||
135 | |||
136 | void LLWaterParamSet::set(const char * paramName, const LLVector4 & val) | ||
137 | { | ||
138 | mParamValues[paramName][0] = val.mV[0]; | ||
139 | mParamValues[paramName][1] = val.mV[1]; | ||
140 | mParamValues[paramName][2] = val.mV[2]; | ||
141 | mParamValues[paramName][3] = val.mV[3]; | ||
142 | } | ||
143 | |||
144 | void LLWaterParamSet::set(const char * paramName, const LLColor4 & val) | ||
145 | { | ||
146 | mParamValues[paramName][0] = val.mV[0]; | ||
147 | mParamValues[paramName][1] = val.mV[1]; | ||
148 | mParamValues[paramName][2] = val.mV[2]; | ||
149 | mParamValues[paramName][3] = val.mV[3]; | ||
150 | } | ||
151 | |||
152 | LLVector4 LLWaterParamSet::getVector4(const char * paramName, bool& error) | ||
153 | { | ||
154 | |||
155 | // test to see if right type | ||
156 | LLSD cur_val = mParamValues.get(paramName); | ||
157 | if (!cur_val.isArray() || cur_val.size() != 4) | ||
158 | { | ||
159 | error = true; | ||
160 | return LLVector4(0,0,0,0); | ||
161 | } | ||
162 | |||
163 | LLVector4 val; | ||
164 | val.mV[0] = (F32) cur_val[0].asReal(); | ||
165 | val.mV[1] = (F32) cur_val[1].asReal(); | ||
166 | val.mV[2] = (F32) cur_val[2].asReal(); | ||
167 | val.mV[3] = (F32) cur_val[3].asReal(); | ||
168 | |||
169 | error = false; | ||
170 | return val; | ||
171 | } | ||
172 | |||
173 | LLVector3 LLWaterParamSet::getVector3(const char * paramName, bool& error) | ||
174 | { | ||
175 | |||
176 | // test to see if right type | ||
177 | LLSD cur_val = mParamValues.get(paramName); | ||
178 | if (!cur_val.isArray()|| cur_val.size() != 3) | ||
179 | { | ||
180 | error = true; | ||
181 | return LLVector3(0,0,0); | ||
182 | } | ||
183 | |||
184 | LLVector3 val; | ||
185 | val.mV[0] = (F32) cur_val[0].asReal(); | ||
186 | val.mV[1] = (F32) cur_val[1].asReal(); | ||
187 | val.mV[2] = (F32) cur_val[2].asReal(); | ||
188 | |||
189 | error = false; | ||
190 | return val; | ||
191 | } | ||
192 | |||
193 | LLVector2 LLWaterParamSet::getVector2(const char * paramName, bool& error) | ||
194 | { | ||
195 | // test to see if right type | ||
196 | int ttest; | ||
197 | ttest = mParamValues.size(); | ||
198 | LLSD cur_val = mParamValues.get(paramName); | ||
199 | if (!cur_val.isArray() || cur_val.size() != 2) | ||
200 | { | ||
201 | error = true; | ||
202 | return LLVector2(0,0); | ||
203 | } | ||
204 | |||
205 | LLVector2 val; | ||
206 | val.mV[0] = (F32) cur_val[0].asReal(); | ||
207 | val.mV[1] = (F32) cur_val[1].asReal(); | ||
208 | |||
209 | error = false; | ||
210 | return val; | ||
211 | } | ||
212 | |||
213 | F32 LLWaterParamSet::getFloat(const char * paramName, bool& error) | ||
214 | { | ||
215 | |||
216 | // test to see if right type | ||
217 | LLSD cur_val = mParamValues.get(paramName); | ||
218 | if (cur_val.isArray() && cur_val.size() != 0) | ||
219 | { | ||
220 | error = false; | ||
221 | return (F32) cur_val[0].asReal(); | ||
222 | } | ||
223 | |||
224 | if(cur_val.isReal()) | ||
225 | { | ||
226 | error = false; | ||
227 | return (F32) cur_val.asReal(); | ||
228 | } | ||
229 | |||
230 | error = true; | ||
231 | return 0; | ||
232 | } | ||
233 | |||