diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/wlfloaterwindlightsend.cpp | 300 |
1 files changed, 300 insertions, 0 deletions
diff --git a/linden/indra/newview/wlfloaterwindlightsend.cpp b/linden/indra/newview/wlfloaterwindlightsend.cpp new file mode 100644 index 0000000..5244bcd --- /dev/null +++ b/linden/indra/newview/wlfloaterwindlightsend.cpp | |||
@@ -0,0 +1,300 @@ | |||
1 | /** | ||
2 | * @file wlfloaterwindlightsend.cpp | ||
3 | * @brief WLFloaterWindLightSend class definition | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2007-2009, 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 | ||
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
22 | * | ||
23 | * By copying, modifying or distributing this software, you acknowledge | ||
24 | * that you have read and understood your obligations described above, | ||
25 | * and agree to abide by those obligations. | ||
26 | * | ||
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
29 | * COMPLETENESS OR PERFORMANCE. | ||
30 | * $/LicenseInfo$ | ||
31 | */ | ||
32 | |||
33 | #include "llviewerprecompiledheaders.h" | ||
34 | |||
35 | #include "llfloaterwindlight.h" | ||
36 | |||
37 | #include "pipeline.h" | ||
38 | #include "llsky.h" | ||
39 | |||
40 | #include "llsliderctrl.h" | ||
41 | #include "llmultislider.h" | ||
42 | #include "llmultisliderctrl.h" | ||
43 | #include "llspinctrl.h" | ||
44 | #include "llcheckboxctrl.h" | ||
45 | #include "lluictrlfactory.h" | ||
46 | #include "llviewercamera.h" | ||
47 | #include "llcombobox.h" | ||
48 | #include "lllineeditor.h" | ||
49 | #include "llfloaterdaycycle.h" | ||
50 | #include "lltabcontainer.h" | ||
51 | #include "llboost.h" | ||
52 | |||
53 | #include "llagent.h" | ||
54 | #include "llinventorymodel.h" | ||
55 | #include "llviewerinventory.h" | ||
56 | |||
57 | #include "v4math.h" | ||
58 | #include "llviewerdisplay.h" | ||
59 | #include "llviewercontrol.h" | ||
60 | #include "llviewerwindow.h" | ||
61 | #include "llsavedsettingsglue.h" | ||
62 | |||
63 | #include "llwlparamset.h" | ||
64 | #include "llwlparammanager.h" | ||
65 | #include "llwaterparammanager.h" | ||
66 | #include "llpostprocess.h" | ||
67 | #include "hippoLimits.h" | ||
68 | #include "wlfloaterwindlightsend.h" | ||
69 | #include "llviewerregion.h" | ||
70 | |||
71 | #undef max | ||
72 | |||
73 | |||
74 | WLFloaterWindLightSend* WLFloaterWindLightSend::sWindLight = NULL; | ||
75 | |||
76 | WLFloaterWindLightSend::WLFloaterWindLightSend() : LLFloater(std::string("windlight send floater")) | ||
77 | { | ||
78 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_windlight_remote_save.xml"); | ||
79 | |||
80 | // load it up | ||
81 | initCallbacks(); | ||
82 | } | ||
83 | |||
84 | WLFloaterWindLightSend::~WLFloaterWindLightSend() | ||
85 | { | ||
86 | } | ||
87 | |||
88 | void WLFloaterWindLightSend::initCallbacks(void) { | ||
89 | |||
90 | // help buttons | ||
91 | initHelpBtn("fade_help", "HelpBlueHorizon"); | ||
92 | initHelpBtn("override_parcel_default_help", "HelpHazeHorizon"); | ||
93 | initHelpBtn("override_parcel_help", "HelpBlueDensity"); | ||
94 | initHelpBtn("max_altitude_help", "HelpHazeDensity"); | ||
95 | initHelpBtn("min_altitude_help", "HelpDensityMult"); | ||
96 | childSetAction("button_region_send_to_server", onSaveRegionPreset, this); | ||
97 | childSetAction("button_parcel_send_to_server", onSaveParcelPreset, this); | ||
98 | } | ||
99 | |||
100 | void WLFloaterWindLightSend::onClickHelp(void* data) | ||
101 | { | ||
102 | LLFloaterWindLight* self = LLFloaterWindLight::instance(); | ||
103 | |||
104 | const std::string xml_alert = *(std::string*)data; | ||
105 | LLNotifications::instance().add(self->contextualNotification(xml_alert)); | ||
106 | } | ||
107 | |||
108 | void WLFloaterWindLightSend::initHelpBtn(const std::string& name, const std::string& xml_alert) | ||
109 | { | ||
110 | childSetAction(name, onClickHelp, new std::string(xml_alert)); | ||
111 | } | ||
112 | |||
113 | // static | ||
114 | WLFloaterWindLightSend* WLFloaterWindLightSend::instance() | ||
115 | { | ||
116 | if (!sWindLight) | ||
117 | { | ||
118 | sWindLight = new WLFloaterWindLightSend(); | ||
119 | sWindLight->open(); | ||
120 | sWindLight->setFocus(TRUE); | ||
121 | } | ||
122 | return sWindLight; | ||
123 | } | ||
124 | |||
125 | void WLFloaterWindLightSend::show() | ||
126 | { | ||
127 | if (!sWindLight) | ||
128 | { | ||
129 | WLFloaterWindLightSend::instance(); | ||
130 | } | ||
131 | else | ||
132 | { | ||
133 | if (sWindLight->getVisible()) | ||
134 | { | ||
135 | sWindLight->close(); | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | sWindLight->open(); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | |||
144 | bool WLFloaterWindLightSend::isOpen() | ||
145 | { | ||
146 | if (sWindLight != NULL) { | ||
147 | return true; | ||
148 | } | ||
149 | return false; | ||
150 | } | ||
151 | |||
152 | // virtual | ||
153 | void WLFloaterWindLightSend::onClose(bool app_quitting) | ||
154 | { | ||
155 | if (sWindLight) | ||
156 | { | ||
157 | sWindLight->setVisible(FALSE); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | void WLFloaterWindLightSend::onSaveRegionPreset(void* userData) | ||
162 | { | ||
163 | int RegionType = 0; | ||
164 | SendSettings(false, RegionType, | ||
165 | WLFloaterWindLightSend::instance()->childGetValue("override_parcel"), | ||
166 | LLWLParamManager::instance()->mCurParams, | ||
167 | LLWaterParamManager::instance()->mCurParams, | ||
168 | WLFloaterWindLightSend::instance()->childGetValue("Fade"), | ||
169 | WLFloaterWindLightSend::instance()->childGetValue("min_altitude"), | ||
170 | WLFloaterWindLightSend::instance()->childGetValue("max_altitude"), | ||
171 | LLWaterParamManager::instance()->getNormalMapID()); | ||
172 | } | ||
173 | void WLFloaterWindLightSend::onSaveParcelPreset(void* userData) | ||
174 | { | ||
175 | int ParcelType = 1; | ||
176 | SendSettings(false, ParcelType, false, LLWLParamManager::instance()->mCurParams, | ||
177 | LLWaterParamManager::instance()->mCurParams, | ||
178 | WLFloaterWindLightSend::instance()->childGetValue("Fade"), | ||
179 | WLFloaterWindLightSend::instance()->childGetValue("min_altitude"), | ||
180 | WLFloaterWindLightSend::instance()->childGetValue("max_altitude"), | ||
181 | LLWaterParamManager::instance()->getNormalMapID()); | ||
182 | } | ||
183 | void WLFloaterWindLightSend::SendSettings(bool remove, int type, bool overrideParcels, | ||
184 | LLWLParamSet mSky, LLWaterParamSet mWater, | ||
185 | LLSD fade, LLSD minAlt, LLSD maxAlt, | ||
186 | LLUUID normalMap) | ||
187 | { | ||
188 | LLSD body; | ||
189 | std::string url = gAgent.getRegion()->getCapability("DispatchWindLightSettings"); | ||
190 | if (!url.empty()) | ||
191 | { | ||
192 | bool error; | ||
193 | |||
194 | body["type"] = type; | ||
195 | body["remove"] = remove; | ||
196 | body["fade"] = fade; | ||
197 | body["maxEffectiveAltitude"] = maxAlt; | ||
198 | body["minEffectiveAltitude"] = minAlt; | ||
199 | if(overrideParcels == true || overrideParcels == false) | ||
200 | body["overrideParcels"] = overrideParcels; | ||
201 | |||
202 | LLVector4 v = mSky.getVector("ambient", error); | ||
203 | body["ambientX"] = v[0] / 3.0; | ||
204 | body["ambientY"] = v[1] / 3.0; | ||
205 | body["ambientZ"] = v[2] / 3.0; | ||
206 | body["ambientW"] = v[3] / 3.0; | ||
207 | |||
208 | body["eastAngle"] = mSky.getEastAngle(); | ||
209 | body["sunMoonPosition"] = mSky.getSunAngle(); | ||
210 | |||
211 | v = mSky.getVector("sunlight_color",error); | ||
212 | body["sunMoonColorX"] = v[0] / 3.0; | ||
213 | body["sunMoonColorY"] = v[1] / 3.0; | ||
214 | body["sunMoonColorZ"] = v[2] / 3.0; | ||
215 | body["sunMoonColorW"] = v[3] / 3.0; | ||
216 | |||
217 | v = mSky.getVector("blue_horizon",error); | ||
218 | body["horizonX"] = v[0] / 2.0; | ||
219 | body["horizonY"] = v[1] / 2.0; | ||
220 | body["horizonZ"] = v[2] / 2.0; | ||
221 | body["horizonW"] = v[3] / 2.0; | ||
222 | |||
223 | v = mSky.getVector("blue_density",error); | ||
224 | body["blueDensityX"] = v[0]; | ||
225 | body["blueDensityY"] = v[1]; | ||
226 | body["blueDensityZ"] = v[2]; | ||
227 | |||
228 | v = mSky.getVector("haze_horizon",error); | ||
229 | body["hazeHorizon"] = v[0]; | ||
230 | |||
231 | body["hazeDensity"] = mSky.getFloat("haze_density",error); | ||
232 | body["cloudCoverage"] = mSky.getFloat("cloud_shadow",error); | ||
233 | body["densityMultiplier"] = mSky.getFloat("density_multiplier",error) * 1000; | ||
234 | body["distanceMultiplier"] = mSky.getFloat("distance_multiplier",error); | ||
235 | body["maxAltitude"] = mSky.getFloat("max_y",error); | ||
236 | |||
237 | v = mSky.getVector("cloud_color",error); | ||
238 | body["cloudColorX"] = v[0]; | ||
239 | body["cloudColorY"] = v[1]; | ||
240 | body["cloudColorZ"] = v[2]; | ||
241 | body["cloudColorW"] = v[3]; | ||
242 | |||
243 | v = mSky.getVector("cloud_pos_density1",error); | ||
244 | body["cloudXYDensityX"] = v[0]; | ||
245 | body["cloudXYDensityY"] = v[1]; | ||
246 | body["cloudXYDensityZ"] = v[2]; | ||
247 | |||
248 | v = mSky.getVector("cloud_pos_density2",error); | ||
249 | body["cloudDetailXYDensityX"] = v[0]; | ||
250 | body["cloudDetailXYDensityY"] = v[1]; | ||
251 | body["cloudDetailXYDensityZ"] = v[2]; | ||
252 | |||
253 | v = mSky.getVector("glow",error); | ||
254 | body["sunGlowSize"] = -((v[0]/ 20) - 2); | ||
255 | body["sunGlowFocus"] = -v[2] / 5; | ||
256 | |||
257 | body["cloudScale"] = mSky.getFloat("cloud_scale",error); | ||
258 | body["sceneGamma"] = mSky.getFloat("gamma",error); | ||
259 | body["cloudScrollX"] = mSky.getCloudScrollX() - 10; | ||
260 | body["cloudScrollY"] = mSky.getCloudScrollY() - 10; | ||
261 | body["cloudScrollXLock"] = !mSky.getEnableCloudScrollX(); | ||
262 | body["cloudScrollYLock"] = !mSky.getEnableCloudScrollY(); | ||
263 | body["starBrightness"] = mSky.getStarBrightness(); | ||
264 | body["drawClassicClouds"] = gHippoLimits->skyUseClassicClouds; | ||
265 | body["classicCloudHeight"] = gSavedSettings.getF32("ClassicCloudHeight"); | ||
266 | body["classicCloudRange"] = gSavedSettings.getF32("ClassicCloudRange"); | ||
267 | |||
268 | LLVector3 vvv = mWater.getVector3("normScale",error); | ||
269 | body["reflectionWaveletScaleX"] = vvv[0]; | ||
270 | body["reflectionWaveletScaleY"] = vvv[1]; | ||
271 | body["reflectionWaveletScaleZ"] = vvv[2]; | ||
272 | |||
273 | v = mWater.getVector4("waterFogColor",error); | ||
274 | body["waterColorX"] = v[0] * 256.0; | ||
275 | body["waterColorY"] = v[1] * 256.0; | ||
276 | body["waterColorZ"] = v[2] * 256.0; | ||
277 | body["waterColorW"] = v[3] * 256.0; | ||
278 | |||
279 | body["waterFogDensityExponent"] = mWater.getFloat("waterFogDensity", error); | ||
280 | body["underwaterFogModifier"] = mWater.getFloat("underWaterFogMod", error); | ||
281 | |||
282 | body["fresnelScale"] = mWater.getFloat("fresnelScale", error); | ||
283 | body["fresnelOffset"] = mWater.getFloat("fresnelOffset", error); | ||
284 | body["refractScaleAbove"] = mWater.getFloat("scaleAbove", error); | ||
285 | body["refractScaleBelow"] = mWater.getFloat("scaleBelow", error); | ||
286 | body["blurMultiplier"] = mWater.getFloat("blurMultiplier", error); | ||
287 | |||
288 | LLVector2 vv = mWater.getVector2("wave1Dir",error); | ||
289 | body["littleWaveDirectionX"] = vv[0]; | ||
290 | body["littleWaveDirectionY"] = vv[1]; | ||
291 | |||
292 | vv = mWater.getVector2("wave2Dir",error); | ||
293 | body["bigWaveDirectionX"] = vv[0]; | ||
294 | body["bigWaveDirectionY"] = vv[1]; | ||
295 | |||
296 | body["normalMapTexture"] = normalMap; | ||
297 | |||
298 | LLHTTPClient::post(url, body, new LLHTTPClient::Responder()); | ||
299 | } | ||
300 | } \ No newline at end of file | ||