aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation
diff options
context:
space:
mode:
authorCasperW2009-12-09 22:57:35 +0100
committerCasperW2009-12-09 23:28:00 +0100
commita6a6bf007a2fb0e33daefc0ea7c4ad968a85d08e (patch)
tree87635abdacf33a2c3c274cfab8dbb98560e84957 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation
parentLast bits and bobs to clean up the Meta7WindlightModule (diff)
downloadopensim-SC_OLD-a6a6bf007a2fb0e33daefc0ea7c4ad968a85d08e.zip
opensim-SC_OLD-a6a6bf007a2fb0e33daefc0ea7c4ad968a85d08e.tar.gz
opensim-SC_OLD-a6a6bf007a2fb0e33daefc0ea7c4ad968a85d08e.tar.bz2
opensim-SC_OLD-a6a6bf007a2fb0e33daefc0ea7c4ad968a85d08e.tar.xz
Move osFunctions into a new Careminster script interface
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs430
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs334
2 files changed, 430 insertions, 334 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
new file mode 100644
index 0000000..4cc2f0a
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -0,0 +1,430 @@
1using System;
2using System.Reflection;
3using System.Collections;
4using System.Collections.Generic;
5using System.Runtime.Remoting.Lifetime;
6using OpenMetaverse;
7using Nini.Config;
8using OpenSim;
9using OpenSim.Framework;
10using OpenSim.Region.CoreModules.World.Meta7Windlight;
11using OpenSim.Region.Framework.Interfaces;
12using OpenSim.Region.Framework.Scenes;
13using OpenSim.Region.ScriptEngine.Shared;
14using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
15using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
16using OpenSim.Region.ScriptEngine.Interfaces;
17using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
18
19using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
20using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
21using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
22using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
23using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
24using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
25using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
26
27namespace OpenSim.Region.ScriptEngine.Shared.Api
28{
29 [Serializable]
30 public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi
31 {
32 internal IScriptEngine m_ScriptEngine;
33 internal SceneObjectPart m_host;
34 internal uint m_localID;
35 internal UUID m_itemID;
36 internal bool m_CMFunctionsEnabled = false;
37 internal IScriptModuleComms m_comms = null;
38
39 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
40 {
41 m_ScriptEngine = ScriptEngine;
42 m_host = host;
43 m_localID = localID;
44 m_itemID = itemID;
45
46 if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false))
47 m_CMFunctionsEnabled = true;
48
49 m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
50 if (m_comms == null)
51 m_CMFunctionsEnabled = false;
52 }
53
54 public override Object InitializeLifetimeService()
55 {
56 ILease lease = (ILease)base.InitializeLifetimeService();
57
58 if (lease.CurrentState == LeaseState.Initial)
59 {
60 lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
61 // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
62 // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
63 }
64 return lease;
65 }
66
67 public Scene World
68 {
69 get { return m_ScriptEngine.World; }
70 }
71
72 //
73 //Dumps an error message on the debug console.
74 //
75
76 internal void CMShoutError(string message)
77 {
78 if (message.Length > 1023)
79 message = message.Substring(0, 1023);
80
81 World.SimChat(Utils.StringToBytes(message),
82 ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
83
84 IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
85 wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
86 }
87
88 /// <summary>
89 /// Get the current Windlight scene
90 /// </summary>
91 /// <returns>List of windlight parameters</returns>
92 public LSL_List cmGetWindlightScene(LSL_List rules)
93 {
94 if (!m_CMFunctionsEnabled)
95 {
96 CMShoutError("Careminster functions are not enabled.");
97 return new LSL_List();
98 }
99 m_host.AddScriptLPS(1);
100 RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
101
102 LSL_List values = new LSL_List();
103 int idx = 0;
104 while (idx < rules.Length)
105 {
106 uint rule = (uint)rules.GetLSLIntegerItem(idx);
107 LSL_List toadd = new LSL_List();
108
109 switch (rule)
110 {
111 case (int)ScriptBaseClass.WL_AMBIENT:
112 toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
113 break;
114 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
115 toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
116 break;
117 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
118 toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
119 break;
120 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
121 toadd.Add(new LSL_Float(wl.blurMultiplier));
122 break;
123 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
124 toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
125 break;
126 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
127 toadd.Add(new LSL_Float(wl.cloudCoverage));
128 break;
129 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
130 toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
131 break;
132 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
133 toadd.Add(new LSL_Float(wl.cloudScale));
134 break;
135 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
136 toadd.Add(new LSL_Float(wl.cloudScrollX));
137 break;
138 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
139 toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
140 break;
141 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
142 toadd.Add(new LSL_Float(wl.cloudScrollY));
143 break;
144 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
145 toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
146 break;
147 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
148 toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
149 break;
150 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
151 toadd.Add(new LSL_Float(wl.densityMultiplier));
152 break;
153 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
154 toadd.Add(new LSL_Float(wl.distanceMultiplier));
155 break;
156 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
157 toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
158 break;
159 case (int)ScriptBaseClass.WL_EAST_ANGLE:
160 toadd.Add(new LSL_Float(wl.eastAngle));
161 break;
162 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
163 toadd.Add(new LSL_Float(wl.fresnelOffset));
164 break;
165 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
166 toadd.Add(new LSL_Float(wl.fresnelScale));
167 break;
168 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
169 toadd.Add(new LSL_Float(wl.hazeDensity));
170 break;
171 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
172 toadd.Add(new LSL_Float(wl.hazeHorizon));
173 break;
174 case (int)ScriptBaseClass.WL_HORIZON:
175 toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
176 break;
177 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
178 toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
179 break;
180 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
181 toadd.Add(new LSL_Integer(wl.maxAltitude));
182 break;
183 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
184 toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
185 break;
186 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
187 toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
188 break;
189 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
190 toadd.Add(new LSL_Float(wl.refractScaleAbove));
191 break;
192 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
193 toadd.Add(new LSL_Float(wl.refractScaleBelow));
194 break;
195 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
196 toadd.Add(new LSL_Float(wl.sceneGamma));
197 break;
198 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
199 toadd.Add(new LSL_Float(wl.starBrightness));
200 break;
201 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
202 toadd.Add(new LSL_Float(wl.sunGlowFocus));
203 break;
204 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
205 toadd.Add(new LSL_Float(wl.sunGlowSize));
206 break;
207 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
208 toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
209 break;
210 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
211 toadd.Add(new LSL_Float(wl.underwaterFogModifier));
212 break;
213 case (int)ScriptBaseClass.WL_WATER_COLOR:
214 toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
215 break;
216 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
217 toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
218 break;
219 }
220
221 if (toadd.Length > 0)
222 {
223 values.Add(rule);
224 values.Add(toadd.Data[0]);
225 }
226 idx++;
227 }
228
229
230 return values;
231
232 }
233
234 /// <summary>
235 /// Set the current Windlight scene
236 /// </summary>
237 /// <param name="rules"></param>
238 /// <returns>success: true or false</returns>
239 public int cmSetWindlightScene(LSL_List rules)
240 {
241 if (!m_CMFunctionsEnabled)
242 {
243 CMShoutError("Careminster functions are not enabled.");
244 return 0;
245 }
246 int success = 0;
247 m_host.AddScriptLPS(1);
248 if (Meta7WindlightModule.EnableWindlight)
249 {
250 RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
251
252 LSL_List values = new LSL_List();
253 int idx = 0;
254 success = 1;
255 while (idx < rules.Length)
256 {
257 uint rule = (uint)rules.GetLSLIntegerItem(idx);
258 LSL_Types.Quaternion iQ;
259 LSL_Types.Vector3 iV;
260 switch (rule)
261 {
262 case (int)ScriptBaseClass.WL_AMBIENT:
263 idx++;
264 iQ = rules.GetQuaternionItem(idx);
265 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
266 break;
267 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
268 idx++;
269 iV = rules.GetVector3Item(idx);
270 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
271 break;
272 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
273 idx++;
274 iQ = rules.GetQuaternionItem(idx);
275 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
276 break;
277 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
278 idx++;
279 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
280 break;
281 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
282 idx++;
283 iQ = rules.GetQuaternionItem(idx);
284 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
285 break;
286 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
287 idx++;
288 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
289 break;
290 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
291 idx++;
292 iV = rules.GetVector3Item(idx);
293 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
294 break;
295 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
296 idx++;
297 wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
298 break;
299 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
300 idx++;
301 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
302 break;
303 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
304 idx++;
305 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
306 break;
307 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
308 idx++;
309 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
310 break;
311 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
312 idx++;
313 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
314 break;
315 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
316 idx++;
317 iV = rules.GetVector3Item(idx);
318 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
319 break;
320 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
321 idx++;
322 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
323 break;
324 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
325 idx++;
326 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
327 break;
328 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
329 idx++;
330 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
331 break;
332 case (int)ScriptBaseClass.WL_EAST_ANGLE:
333 idx++;
334 wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
335 break;
336 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
337 idx++;
338 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
339 break;
340 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
341 idx++;
342 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
343 break;
344 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
345 idx++;
346 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
347 break;
348 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
349 idx++;
350 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
351 break;
352 case (int)ScriptBaseClass.WL_HORIZON:
353 idx++;
354 iQ = rules.GetQuaternionItem(idx);
355 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
356 break;
357 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
358 idx++;
359 iV = rules.GetVector3Item(idx);
360 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
361 break;
362 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
363 idx++;
364 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
365 break;
366 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
367 idx++;
368 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
369 break;
370 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
371 idx++;
372 iV = rules.GetVector3Item(idx);
373 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
374 break;
375 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
376 idx++;
377 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
378 break;
379 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
380 idx++;
381 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
382 break;
383 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
384 idx++;
385 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
386 break;
387 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
388 idx++;
389 wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
390 break;
391 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
392 idx++;
393 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
394 break;
395 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
396 idx++;
397 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
398 break;
399 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
400 idx++;
401 iQ = rules.GetQuaternionItem(idx);
402 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
403 break;
404 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
405 idx++;
406 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
407 break;
408 case (int)ScriptBaseClass.WL_WATER_COLOR:
409 idx++;
410 iV = rules.GetVector3Item(idx);
411 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
412 break;
413 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
414 idx++;
415 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
416 break;
417 default:
418 success = 0;
419 break;
420 }
421 idx++;
422 }
423 m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
424
425 }
426 return success;
427 }
428
429 }
430}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 33c67d5..836f276 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -42,7 +42,6 @@ using OpenSim.Region.CoreModules.Avatar.NPC;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44using OpenSim.Region.Framework.Scenes.Hypergrid; 44using OpenSim.Region.Framework.Scenes.Hypergrid;
45using OpenSim.Region.CoreModules.World.Meta7Windlight;
46using OpenSim.Region.ScriptEngine.Shared; 45using OpenSim.Region.ScriptEngine.Shared;
47using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; 46using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
48using OpenSim.Region.ScriptEngine.Shared.ScriptBase; 47using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
@@ -1974,338 +1973,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1974 } 1973 }
1975 return ret; 1974 return ret;
1976 } 1975 }
1977
1978 /// <summary>
1979 /// Get the current Windlight scene
1980 /// </summary>
1981 /// <returns>List of windlight parameters</returns>
1982 public LSL_List osGetWindlightScene(LSL_List rules)
1983 {
1984 CheckThreatLevel(ThreatLevel.Low, "osGetWindlightScene");
1985 m_host.AddScriptLPS(1);
1986 RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
1987
1988 LSL_List values = new LSL_List();
1989 int idx = 0;
1990 while (idx < rules.Length)
1991 {
1992 uint rule = (uint)rules.GetLSLIntegerItem(idx);
1993 LSL_List toadd = new LSL_List();
1994
1995 switch (rule)
1996 {
1997 case (int)ScriptBaseClass.WL_AMBIENT:
1998 toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
1999 break;
2000 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
2001 toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
2002 break;
2003 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
2004 toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
2005 break;
2006 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
2007 toadd.Add(new LSL_Float(wl.blurMultiplier));
2008 break;
2009 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
2010 toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
2011 break;
2012 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
2013 toadd.Add(new LSL_Float(wl.cloudCoverage));
2014 break;
2015 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
2016 toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
2017 break;
2018 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
2019 toadd.Add(new LSL_Float(wl.cloudScale));
2020 break;
2021 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
2022 toadd.Add(new LSL_Float(wl.cloudScrollX));
2023 break;
2024 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
2025 toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
2026 break;
2027 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
2028 toadd.Add(new LSL_Float(wl.cloudScrollY));
2029 break;
2030 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
2031 toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
2032 break;
2033 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
2034 toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
2035 break;
2036 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
2037 toadd.Add(new LSL_Float(wl.densityMultiplier));
2038 break;
2039 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
2040 toadd.Add(new LSL_Float(wl.distanceMultiplier));
2041 break;
2042 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
2043 toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
2044 break;
2045 case (int)ScriptBaseClass.WL_EAST_ANGLE:
2046 toadd.Add(new LSL_Float(wl.eastAngle));
2047 break;
2048 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
2049 toadd.Add(new LSL_Float(wl.fresnelOffset));
2050 break;
2051 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
2052 toadd.Add(new LSL_Float(wl.fresnelScale));
2053 break;
2054 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
2055 toadd.Add(new LSL_Float(wl.hazeDensity));
2056 break;
2057 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
2058 toadd.Add(new LSL_Float(wl.hazeHorizon));
2059 break;
2060 case (int)ScriptBaseClass.WL_HORIZON:
2061 toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
2062 break;
2063 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
2064 toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
2065 break;
2066 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
2067 toadd.Add(new LSL_Integer(wl.maxAltitude));
2068 break;
2069 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
2070 toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
2071 break;
2072 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
2073 toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
2074 break;
2075 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
2076 toadd.Add(new LSL_Float(wl.refractScaleAbove));
2077 break;
2078 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
2079 toadd.Add(new LSL_Float(wl.refractScaleBelow));
2080 break;
2081 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
2082 toadd.Add(new LSL_Float(wl.sceneGamma));
2083 break;
2084 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
2085 toadd.Add(new LSL_Float(wl.starBrightness));
2086 break;
2087 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
2088 toadd.Add(new LSL_Float(wl.sunGlowFocus));
2089 break;
2090 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
2091 toadd.Add(new LSL_Float(wl.sunGlowSize));
2092 break;
2093 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
2094 toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
2095 break;
2096 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
2097 toadd.Add(new LSL_Float(wl.underwaterFogModifier));
2098 break;
2099 case (int)ScriptBaseClass.WL_WATER_COLOR:
2100 toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
2101 break;
2102 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
2103 toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
2104 break;
2105 }
2106
2107 if (toadd.Length > 0)
2108 {
2109 values.Add(rule);
2110 values.Add(toadd.Data[0]);
2111 }
2112 idx++;
2113 }
2114
2115
2116 return values;
2117
2118 }
2119
2120 /// <summary>
2121 /// Set the current Windlight scene
2122 /// </summary>
2123 /// <param name="rules"></param>
2124 /// <returns>success: true or false</returns>
2125 public int osSetWindlightScene(LSL_List rules)
2126 {
2127 CheckThreatLevel(ThreatLevel.High, "osSetWindlightScene");
2128 int success = 0;
2129 m_host.AddScriptLPS(1);
2130 if (Meta7WindlightModule.EnableWindlight)
2131 {
2132 RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
2133
2134 LSL_List values = new LSL_List();
2135 int idx = 0;
2136 success = 1;
2137 while (idx < rules.Length)
2138 {
2139 uint rule = (uint)rules.GetLSLIntegerItem(idx);
2140 LSL_Types.Quaternion iQ;
2141 LSL_Types.Vector3 iV;
2142 switch (rule)
2143 {
2144 case (int)ScriptBaseClass.WL_AMBIENT:
2145 idx++;
2146 iQ = rules.GetQuaternionItem(idx);
2147 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
2148 break;
2149 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
2150 idx++;
2151 iV = rules.GetVector3Item(idx);
2152 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
2153 break;
2154 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
2155 idx++;
2156 iQ = rules.GetQuaternionItem(idx);
2157 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
2158 break;
2159 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
2160 idx++;
2161 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
2162 break;
2163 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
2164 idx++;
2165 iQ = rules.GetQuaternionItem(idx);
2166 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
2167 break;
2168 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
2169 idx++;
2170 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
2171 break;
2172 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
2173 idx++;
2174 iV = rules.GetVector3Item(idx);
2175 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
2176 break;
2177 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
2178 idx++;
2179 wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
2180 break;
2181 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
2182 idx++;
2183 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
2184 break;
2185 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
2186 idx++;
2187 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
2188 break;
2189 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
2190 idx++;
2191 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
2192 break;
2193 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
2194 idx++;
2195 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
2196 break;
2197 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
2198 idx++;
2199 iV = rules.GetVector3Item(idx);
2200 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
2201 break;
2202 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
2203 idx++;
2204 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
2205 break;
2206 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
2207 idx++;
2208 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
2209 break;
2210 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
2211 idx++;
2212 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
2213 break;
2214 case (int)ScriptBaseClass.WL_EAST_ANGLE:
2215 idx++;
2216 wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
2217 break;
2218 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
2219 idx++;
2220 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
2221 break;
2222 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
2223 idx++;
2224 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
2225 break;
2226 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
2227 idx++;
2228 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
2229 break;
2230 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
2231 idx++;
2232 wl.hazeHorizon= (float)rules.GetLSLFloatItem(idx);
2233 break;
2234 case (int)ScriptBaseClass.WL_HORIZON:
2235 idx++;
2236 iQ = rules.GetQuaternionItem(idx);
2237 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
2238 break;
2239 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
2240 idx++;
2241 iV = rules.GetVector3Item(idx);
2242 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
2243 break;
2244 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
2245 idx++;
2246 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
2247 break;
2248 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
2249 idx++;
2250 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
2251 break;
2252 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
2253 idx++;
2254 iV = rules.GetVector3Item(idx);
2255 wl.reflectionWaveletScale= new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
2256 break;
2257 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
2258 idx++;
2259 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
2260 break;
2261 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
2262 idx++;
2263 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
2264 break;
2265 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
2266 idx++;
2267 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
2268 break;
2269 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
2270 idx++;
2271 wl.starBrightness= (float)rules.GetLSLFloatItem(idx);
2272 break;
2273 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
2274 idx++;
2275 wl.sunGlowFocus= (float)rules.GetLSLFloatItem(idx);
2276 break;
2277 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
2278 idx++;
2279 wl.sunGlowSize= (float)rules.GetLSLFloatItem(idx);
2280 break;
2281 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
2282 idx++;
2283 iQ = rules.GetQuaternionItem(idx);
2284 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
2285 break;
2286 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
2287 idx++;
2288 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
2289 break;
2290 case (int)ScriptBaseClass.WL_WATER_COLOR:
2291 idx++;
2292 iV = rules.GetVector3Item(idx);
2293 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
2294 break;
2295 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
2296 idx++;
2297 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
2298 break;
2299 default:
2300 success = 0;
2301 break;
2302 }
2303 idx++;
2304 }
2305 m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
2306
2307 }
2308 return success;
2309 }
2310 } 1976 }
2311} 1977}