00001
00032 #ifndef LL_WLPARAMMANAGER_H
00033 #define LL_WLPARAMMANAGER_H
00034
00035 #include <vector>
00036 #include <map>
00037 #include "llwlparamset.h"
00038 #include "llwlanimator.h"
00039 #include "llwldaycycle.h"
00040 #include "llviewercamera.h"
00041
00042 class LLGLSLShader;
00043
00044
00045 struct WLColorControl {
00046
00047 F32 r, g, b, i;
00048 char const * name;
00049 std::string mSliderName;
00050 bool hasSliderName;
00051 bool isSunOrAmbientColor;
00052 bool isBlueHorizonOrDensity;
00053
00054 inline WLColorControl(F32 red, F32 green, F32 blue, F32 intensity, char const * n,
00055 char const * sliderName = "")
00056 : r(red), g(green), b(blue), i(intensity), name(n), mSliderName(sliderName)
00057 {
00058
00059 hasSliderName = false;
00060 if (mSliderName != "") {
00061 hasSliderName = true;
00062 }
00063
00064
00065 isSunOrAmbientColor = false;
00066 if (mSliderName == "WLSunlight" || mSliderName == "WLAmbient") {
00067 isSunOrAmbientColor = true;
00068 }
00069
00070 isBlueHorizonOrDensity = false;
00071 if (mSliderName == "WLBlueHorizon" || mSliderName == "WLBlueDensity") {
00072 isBlueHorizonOrDensity = true;
00073 }
00074 }
00075
00076 inline WLColorControl & operator = (LLVector4 const & val) {
00077 r = val.mV[0];
00078 g = val.mV[1];
00079 b = val.mV[2];
00080 i = val.mV[3];
00081 return *this;
00082 }
00083
00084 inline operator LLVector4 (void) const {
00085 return LLVector4(r, g, b, i);
00086 }
00087
00088 inline operator LLVector3 (void) const {
00089 return LLVector3(r, g, b);
00090 }
00091
00092 inline void update(LLWLParamSet & params) const {
00093 params.set(name, r, g, b, i);
00094 }
00095 };
00096
00097
00098 struct WLFloatControl {
00099 F32 x;
00100 char const * name;
00101 F32 mult;
00102
00103 inline WLFloatControl(F32 val, char const * n, F32 m=1.0f)
00104 : x(val), name(n), mult(m)
00105 {
00106 }
00107
00108 inline WLFloatControl & operator = (LLVector4 const & val) {
00109 x = val.mV[0];
00110
00111 return *this;
00112 }
00113
00114 inline operator F32 (void) const {
00115 return x;
00116 }
00117
00118 inline void update(LLWLParamSet & params) const {
00119 params.set(name, x);
00120 }
00121 };
00122
00124 class LLWLParamManager
00125 {
00126 public:
00127
00128 LLWLParamManager();
00129 ~LLWLParamManager();
00130
00132 void loadPresets(const LLString & fileName);
00133
00135 void savePresets(const LLString & fileName);
00136
00138 void loadPreset(const LLString & name);
00139
00141 void savePreset(const LLString & name);
00142
00144 void propagateParameters(void);
00145
00147 void updateShaderUniforms(LLGLSLShader * shader);
00148
00150 void resetAnimator(F32 curTime, bool run);
00151
00153 void update(LLViewerCamera * cam);
00154
00155
00156 inline LLVector4 getLightDir(void) const;
00157
00158
00159 inline LLVector4 getClampedLightDir(void) const;
00160
00161
00162 inline LLVector4 getRotatedLightDir(void) const;
00163
00165 inline F32 getDomeOffset(void) const;
00166
00168 inline F32 getDomeRadius(void) const;
00169
00171 static void initClass(void);
00172
00173
00174 static void cleanupClass();
00175
00177 bool addParamSet(const std::string& name, LLWLParamSet& param);
00178
00180 BOOL addParamSet(const std::string& name, LLSD const & param);
00181
00183 bool getParamSet(const std::string& name, LLWLParamSet& param);
00184
00186 bool setParamSet(const std::string& name, LLWLParamSet& param);
00187
00189 bool setParamSet(const std::string& name, LLSD const & param);
00190
00193 bool removeParamSet(const std::string& name, bool delete_from_disk);
00194
00195
00196 static LLWLParamManager * instance();
00197
00198
00199 public:
00200
00201
00202 LLWLAnimator mAnimator;
00203
00205 LLVector4 mLightDir;
00206
00208 LLVector4 mRotatedLightDir;
00209
00213 LLVector4 mClampedLightDir;
00214
00215
00216 LLWLDayCycle mDay;
00217
00218 LLWLParamSet mCurParams;
00219
00221 F32 mSunDeltaYaw;
00222 WLFloatControl mWLGamma;
00223
00224 F32 mSceneLightStrength;
00225
00227 WLColorControl mBlueHorizon;
00228 WLColorControl mHazeDensity;
00229 WLColorControl mBlueDensity;
00230 WLFloatControl mDensityMult;
00231 WLColorControl mHazeHorizon;
00232 WLFloatControl mMaxAlt;
00233
00235 WLColorControl mLightnorm;
00236 WLColorControl mSunlight;
00237 WLColorControl mAmbient;
00238 WLColorControl mGlow;
00239
00241 WLColorControl mCloudColor;
00242 WLColorControl mCloudMain;
00243 WLFloatControl mCloudCoverage;
00244 WLColorControl mCloudDetail;
00245 WLFloatControl mDistanceMult;
00246 WLFloatControl mCloudScale;
00247
00249 F32 mDomeOffset;
00250 F32 mDomeRadius;
00251
00252
00253 std::map<std::string, LLWLParamSet> mParamList;
00254
00255
00256 private:
00257
00258 static LLWLParamManager * sInstance;
00259
00260 };
00261
00262 inline F32 LLWLParamManager::getDomeOffset(void) const
00263 {
00264 return mDomeOffset;
00265 }
00266
00267 inline F32 LLWLParamManager::getDomeRadius(void) const
00268 {
00269 return mDomeRadius;
00270 }
00271
00272 inline LLVector4 LLWLParamManager::getLightDir(void) const
00273 {
00274 return mLightDir;
00275 }
00276
00277 inline LLVector4 LLWLParamManager::getClampedLightDir(void) const
00278 {
00279 return mClampedLightDir;
00280 }
00281
00282 inline LLVector4 LLWLParamManager::getRotatedLightDir(void) const
00283 {
00284 return mRotatedLightDir;
00285 }
00286
00287 #endif