aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llwlparammanager.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llwlparammanager.h
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-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/llwlparammanager.h')
-rw-r--r--linden/indra/newview/llwlparammanager.h292
1 files changed, 292 insertions, 0 deletions
diff --git a/linden/indra/newview/llwlparammanager.h b/linden/indra/newview/llwlparammanager.h
new file mode 100644
index 0000000..bfb84e9
--- /dev/null
+++ b/linden/indra/newview/llwlparammanager.h
@@ -0,0 +1,292 @@
1/**
2 * @file llwlparammanager.h
3 * @brief Implementation for the LLWLParamManager class.
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-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#ifndef LL_WLPARAMMANAGER_H
33#define LL_WLPARAMMANAGER_H
34
35#include <vector>
36#include <map>
37#include "llwlparamset.h"
38#include "llwlanimator.h"
39#include "llwldaycycle.h"
40#include "llviewercamera.h"
41
42class LLGLSLShader;
43
44// color control
45struct WLColorControl {
46
47 F32 r, g, b, i; /// the values
48 char const * name; /// name to use to dereference params
49 std::string mSliderName; /// name of the slider in menu
50 bool hasSliderName; /// only set slider name for true color types
51 bool isSunOrAmbientColor; /// flag for if it's the sun or ambient color controller
52 bool isBlueHorizonOrDensity; /// flag for if it's the Blue Horizon or Density color controller
53
54 inline WLColorControl(F32 red, F32 green, F32 blue, F32 intensity, char const * n,
55 char const * sliderName = "")
56 : r(red), g(green), b(blue), i(intensity), name(n), mSliderName(sliderName)
57 {
58 // if there's a slider name, say we have one
59 hasSliderName = false;
60 if (mSliderName != "") {
61 hasSliderName = true;
62 }
63
64 // if it's the sun controller
65 isSunOrAmbientColor = false;
66 if (mSliderName == "WLSunlight" || mSliderName == "WLAmbient") {
67 isSunOrAmbientColor = true;
68 }
69
70 isBlueHorizonOrDensity = false;
71 if (mSliderName == "WLBlueHorizon" || mSliderName == "WLBlueDensity") {
72 isBlueHorizonOrDensity = true;
73 }
74 }
75
76 inline WLColorControl & operator = (LLVector4 const & val) {
77 r = val.mV[0];
78 g = val.mV[1];
79 b = val.mV[2];
80 i = val.mV[3];
81 return *this;
82 }
83
84 inline operator LLVector4 (void) const {
85 return LLVector4(r, g, b, i);
86 }
87
88 inline operator LLVector3 (void) const {
89 return LLVector3(r, g, b);
90 }
91
92 inline void update(LLWLParamSet & params) const {
93 params.set(name, r, g, b, i);
94 }
95};
96
97// float slider control
98struct WLFloatControl {
99 F32 x;
100 char const * name;
101 F32 mult;
102
103 inline WLFloatControl(F32 val, char const * n, F32 m=1.0f)
104 : x(val), name(n), mult(m)
105 {
106 }
107
108 inline WLFloatControl & operator = (LLVector4 const & val) {
109 x = val.mV[0];
110
111 return *this;
112 }
113
114 inline operator F32 (void) const {
115 return x;
116 }
117
118 inline void update(LLWLParamSet & params) const {
119 params.set(name, x);
120 }
121};
122
123/// WindLight parameter manager class - what controls all the wind light shaders
124class LLWLParamManager
125{
126public:
127
128 LLWLParamManager();
129 ~LLWLParamManager();
130
131 /// load a preset file
132 void loadPresets(const LLString & fileName);
133
134 /// save the preset file
135 void savePresets(const LLString & fileName);
136
137 /// load an individual preset into the sky
138 void loadPreset(const LLString & name);
139
140 /// save the parameter presets to file
141 void savePreset(const LLString & name);
142
143 /// Set shader uniforms dirty, so they'll update automatically.
144 void propagateParameters(void);
145
146 /// Update shader uniforms that have changed.
147 void updateShaderUniforms(LLGLSLShader * shader);
148
149 /// setup the animator to run
150 void resetAnimator(F32 curTime, bool run);
151
152 /// update information camera dependent parameters
153 void update(LLViewerCamera * cam);
154
155 // get where the light is pointing
156 inline LLVector4 getLightDir(void) const;
157
158 // get where the light is pointing
159 inline LLVector4 getClampedLightDir(void) const;
160
161 // get where the light is pointing
162 inline LLVector4 getRotatedLightDir(void) const;
163
164 /// get the dome's offset
165 inline F32 getDomeOffset(void) const;
166
167 /// get the radius of the dome
168 inline F32 getDomeRadius(void) const;
169
170 /// Perform global initialization for this class.
171 static void initClass(void);
172
173 // Cleanup of global data that's only inited once per class.
174 static void cleanupClass();
175
176 /// add a param to the list
177 bool addParamSet(const std::string& name, LLWLParamSet& param);
178
179 /// add a param to the list
180 BOOL addParamSet(const std::string& name, LLSD const & param);
181
182 /// get a param from the list
183 bool getParamSet(const std::string& name, LLWLParamSet& param);
184
185 /// set the param in the list with a new param
186 bool setParamSet(const std::string& name, LLWLParamSet& param);
187
188 /// set the param in the list with a new param
189 bool setParamSet(const std::string& name, LLSD const & param);
190
191 /// gets rid of a parameter and any references to it
192 /// returns true if successful
193 bool removeParamSet(const std::string& name, bool delete_from_disk);
194
195 // singleton pattern implementation
196 static LLWLParamManager * instance();
197
198
199public:
200
201 // helper variables
202 F32 mSunAngle;
203 F32 mEastAngle;
204 LLWLAnimator mAnimator;
205
206 /// actual direction of the sun
207 LLVector4 mLightDir;
208
209 /// light norm adjusted so haze works correctly
210 LLVector4 mRotatedLightDir;
211
212 /// clamped light norm for shaders that
213 /// are adversely affected when the sun goes below the
214 /// horizon
215 LLVector4 mClampedLightDir;
216
217 // list of params and how they're cycled for days
218 LLWLDayCycle mDay;
219
220 // length of the day in seconds
221 F32 mLengthOfDay;
222
223 LLWLParamSet mCurParams;
224
225 /// Sun Delta Terrain tweak variables.
226 F32 mSunDeltaYaw;
227 WLFloatControl mWLGamma;
228
229 F32 mSceneLightStrength;
230
231 /// Atmospherics
232 WLColorControl mBlueHorizon;
233 WLColorControl mHazeDensity;
234 WLColorControl mBlueDensity;
235 WLFloatControl mDensityMult;
236 WLColorControl mHazeHorizon;
237 WLFloatControl mMaxAlt;
238
239 /// Lighting
240 WLColorControl mLightnorm;
241 WLColorControl mSunlight;
242 WLColorControl mAmbient;
243 WLColorControl mGlow;
244
245 /// Clouds
246 WLColorControl mCloudColor;
247 WLColorControl mCloudMain;
248 WLFloatControl mCloudCoverage;
249 WLColorControl mCloudDetail;
250 WLFloatControl mDistanceMult;
251 WLFloatControl mCloudScale;
252
253 /// sky dome
254 F32 mDomeOffset;
255 F32 mDomeRadius;
256
257 // list of all the parameters, listed by name
258 std::map<std::string, LLWLParamSet> mParamList;
259
260
261private:
262 // our parameter manager singleton instance
263 static LLWLParamManager * sInstance;
264
265};
266
267inline F32 LLWLParamManager::getDomeOffset(void) const
268{
269 return mDomeOffset;
270}
271
272inline F32 LLWLParamManager::getDomeRadius(void) const
273{
274 return mDomeRadius;
275}
276
277inline LLVector4 LLWLParamManager::getLightDir(void) const
278{
279 return mLightDir;
280}
281
282inline LLVector4 LLWLParamManager::getClampedLightDir(void) const
283{
284 return mClampedLightDir;
285}
286
287inline LLVector4 LLWLParamManager::getRotatedLightDir(void) const
288{
289 return mRotatedLightDir;
290}
291
292#endif