aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs401
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs3
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs5
3 files changed, 229 insertions, 180 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
index 4cc2f0a..d4250c1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs
@@ -229,8 +229,181 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
229 229
230 return values; 230 return values;
231 231
232 } 232 }
233
234 private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules)
235 {
236 RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
233 237
238 LSL_List values = new LSL_List();
239 int idx = 0;
240 while (idx < rules.Length)
241 {
242 uint rule = (uint)rules.GetLSLIntegerItem(idx);
243 LSL_Types.Quaternion iQ;
244 LSL_Types.Vector3 iV;
245 switch (rule)
246 {
247 case (int)ScriptBaseClass.WL_AMBIENT:
248 idx++;
249 iQ = rules.GetQuaternionItem(idx);
250 wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
251 break;
252 case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
253 idx++;
254 iV = rules.GetVector3Item(idx);
255 wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
256 break;
257 case (int)ScriptBaseClass.WL_BLUE_DENSITY:
258 idx++;
259 iQ = rules.GetQuaternionItem(idx);
260 wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
261 break;
262 case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
263 idx++;
264 wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
265 break;
266 case (int)ScriptBaseClass.WL_CLOUD_COLOR:
267 idx++;
268 iQ = rules.GetQuaternionItem(idx);
269 wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
270 break;
271 case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
272 idx++;
273 wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
274 break;
275 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
276 idx++;
277 iV = rules.GetVector3Item(idx);
278 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
279 break;
280 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
281 idx++;
282 wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
283 break;
284 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
285 idx++;
286 wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
287 break;
288 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
289 idx++;
290 wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
291 break;
292 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
293 idx++;
294 wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
295 break;
296 case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
297 idx++;
298 wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
299 break;
300 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
301 idx++;
302 iV = rules.GetVector3Item(idx);
303 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
304 break;
305 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
306 idx++;
307 wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
308 break;
309 case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
310 idx++;
311 wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
312 break;
313 case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
314 idx++;
315 wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
316 break;
317 case (int)ScriptBaseClass.WL_EAST_ANGLE:
318 idx++;
319 wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
320 break;
321 case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
322 idx++;
323 wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
324 break;
325 case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
326 idx++;
327 wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
328 break;
329 case (int)ScriptBaseClass.WL_HAZE_DENSITY:
330 idx++;
331 wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
332 break;
333 case (int)ScriptBaseClass.WL_HAZE_HORIZON:
334 idx++;
335 wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
336 break;
337 case (int)ScriptBaseClass.WL_HORIZON:
338 idx++;
339 iQ = rules.GetQuaternionItem(idx);
340 wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
341 break;
342 case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
343 idx++;
344 iV = rules.GetVector3Item(idx);
345 wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
346 break;
347 case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
348 idx++;
349 wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
350 break;
351 case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
352 idx++;
353 wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
354 break;
355 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
356 idx++;
357 iV = rules.GetVector3Item(idx);
358 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
359 break;
360 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
361 idx++;
362 wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
363 break;
364 case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
365 idx++;
366 wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
367 break;
368 case (int)ScriptBaseClass.WL_SCENE_GAMMA:
369 idx++;
370 wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
371 break;
372 case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
373 idx++;
374 wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
375 break;
376 case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
377 idx++;
378 wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
379 break;
380 case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
381 idx++;
382 wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
383 break;
384 case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
385 idx++;
386 iQ = rules.GetQuaternionItem(idx);
387 wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
388 break;
389 case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
390 idx++;
391 wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
392 break;
393 case (int)ScriptBaseClass.WL_WATER_COLOR:
394 idx++;
395 iV = rules.GetVector3Item(idx);
396 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
397 break;
398 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
399 idx++;
400 wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
401 break;
402 }
403 idx++;
404 }
405 return wl;
406 }
234 /// <summary> 407 /// <summary>
235 /// Set the current Windlight scene 408 /// Set the current Windlight scene
236 /// </summary> 409 /// </summary>
@@ -242,188 +415,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
242 { 415 {
243 CMShoutError("Careminster functions are not enabled."); 416 CMShoutError("Careminster functions are not enabled.");
244 return 0; 417 return 0;
418 }
419 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
420 {
421 CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
422 return 0;
245 } 423 }
246 int success = 0; 424 int success = 0;
247 m_host.AddScriptLPS(1); 425 m_host.AddScriptLPS(1);
248 if (Meta7WindlightModule.EnableWindlight) 426 if (Meta7WindlightModule.EnableWindlight)
249 { 427 {
250 RegionMeta7WindlightData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; 428 RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
251 429 m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
252 LSL_List values = new LSL_List(); 430 success = 1;
253 int idx = 0; 431 }
254 success = 1; 432 else
255 while (idx < rules.Length) 433 {
256 { 434 CMShoutError("Windlight module is disabled");
257 uint rule = (uint)rules.GetLSLIntegerItem(idx); 435 return 0;
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 } 436 }
426 return success; 437 return success;
438 }
439 /// <summary>
440 /// Set the current Windlight scene to a target avatar
441 /// </summary>
442 /// <param name="rules"></param>
443 /// <returns>success: true or false</returns>
444 public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
445 {
446 if (!m_CMFunctionsEnabled)
447 {
448 CMShoutError("Careminster functions are not enabled.");
449 return 0;
450 }
451 if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
452 {
453 CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
454 return 0;
455 }
456 int success = 0;
457 m_host.AddScriptLPS(1);
458 if (Meta7WindlightModule.EnableWindlight)
459 {
460 RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
461 World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
462 success = 1;
463 }
464 else
465 {
466 CMShoutError("Windlight module is disabled");
467 return 0;
468 }
469 return success;
427 } 470 }
428 471
429 } 472 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
index 9dd0b73..ef990a1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs
@@ -15,6 +15,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
15 { 15 {
16 // Windlight Functions 16 // Windlight Functions
17 LSL_List cmGetWindlightScene(LSL_List rules); 17 LSL_List cmGetWindlightScene(LSL_List rules);
18 int cmSetWindlightScene(LSL_List rules); 18 int cmSetWindlightScene(LSL_List rules);
19 int cmSetWindlightSceneTargeted(LSL_List rules, key target);
19 } 20 }
20} 21}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
index e85d41e..5bc3a88 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs
@@ -66,6 +66,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
66 public int cmSetWindlightScene(LSL_List rules) 66 public int cmSetWindlightScene(LSL_List rules)
67 { 67 {
68 return m_CM_Functions.cmSetWindlightScene(rules); 68 return m_CM_Functions.cmSetWindlightScene(rules);
69 }
70
71 public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
72 {
73 return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
69 } 74 }
70 } 75 }
71} 76}