opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ |
||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
||
4 | * |
||
5 | * Redistribution and use in source and binary forms, with or without |
||
6 | * modification, are permitted provided that the following conditions are met: |
||
7 | * * Redistributions of source code must retain the above copyright |
||
8 | * notice, this list of conditions and the following disclaimer. |
||
9 | * * Redistributions in binary form must reproduce the above copyright |
||
10 | * notice, this list of conditions and the following disclaimer in the |
||
11 | * documentation and/or other materials provided with the distribution. |
||
12 | * * Neither the name of the OpenSimulator Project nor the |
||
13 | * names of its contributors may be used to endorse or promote products |
||
14 | * derived from this software without specific prior written permission. |
||
15 | * |
||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
26 | */ |
||
27 | |||
28 | using System; |
||
29 | using System.Reflection; |
||
30 | using System.Collections; |
||
31 | using System.Collections.Generic; |
||
32 | using System.Runtime.Remoting.Lifetime; |
||
33 | using System.Threading; |
||
34 | using OpenMetaverse; |
||
35 | using Nini.Config; |
||
36 | using OpenSim; |
||
37 | using OpenSim.Framework; |
||
38 | using OpenSim.Region.CoreModules.World.LightShare; |
||
39 | using OpenSim.Region.Framework.Interfaces; |
||
40 | using OpenSim.Region.Framework.Scenes; |
||
41 | using OpenSim.Region.ScriptEngine.Shared; |
||
42 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; |
||
43 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; |
||
44 | using OpenSim.Region.ScriptEngine.Interfaces; |
||
45 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; |
||
46 | |||
47 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
||
48 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; |
||
49 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
||
50 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; |
||
51 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; |
||
52 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; |
||
53 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; |
||
54 | |||
55 | namespace OpenSim.Region.ScriptEngine.Shared.Api |
||
56 | { |
||
57 | [Serializable] |
||
58 | public class LS_Api : MarshalByRefObject, ILS_Api, IScriptApi |
||
59 | { |
||
60 | internal IScriptEngine m_ScriptEngine; |
||
61 | internal SceneObjectPart m_host; |
||
62 | internal bool m_LSFunctionsEnabled = false; |
||
63 | internal IScriptModuleComms m_comms = null; |
||
64 | |||
65 | public void Initialize( |
||
66 | IScriptEngine scriptEngine, SceneObjectPart host, TaskInventoryItem item, WaitHandle coopSleepHandle) |
||
67 | { |
||
68 | m_ScriptEngine = scriptEngine; |
||
69 | m_host = host; |
||
70 | |||
71 | if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false)) |
||
72 | m_LSFunctionsEnabled = true; |
||
73 | |||
74 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); |
||
75 | if (m_comms == null) |
||
76 | m_LSFunctionsEnabled = false; |
||
77 | } |
||
78 | |||
79 | public override Object InitializeLifetimeService() |
||
80 | { |
||
81 | ILease lease = (ILease)base.InitializeLifetimeService(); |
||
82 | |||
83 | if (lease.CurrentState == LeaseState.Initial) |
||
84 | { |
||
85 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); |
||
86 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); |
||
87 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); |
||
88 | } |
||
89 | return lease; |
||
90 | } |
||
91 | |||
92 | public Scene World |
||
93 | { |
||
94 | get { return m_ScriptEngine.World; } |
||
95 | } |
||
96 | |||
97 | /// <summary> |
||
98 | /// Dumps an error message on the debug console. |
||
99 | /// </summary> |
||
100 | internal void LSShoutError(string message) |
||
101 | { |
||
102 | if (message.Length > 1023) |
||
103 | message = message.Substring(0, 1023); |
||
104 | |||
105 | World.SimChat(Utils.StringToBytes(message), |
||
106 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); |
||
107 | |||
108 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); |
||
109 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); |
||
110 | } |
||
111 | |||
112 | /// <summary> |
||
113 | /// Get the current Windlight scene |
||
114 | /// </summary> |
||
115 | /// <returns>List of windlight parameters</returns> |
||
116 | public LSL_List lsGetWindlightScene(LSL_List rules) |
||
117 | { |
||
118 | if (!m_LSFunctionsEnabled) |
||
119 | { |
||
120 | LSShoutError("LightShare functions are not enabled."); |
||
121 | return new LSL_List(); |
||
122 | } |
||
123 | m_host.AddScriptLPS(1); |
||
124 | RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; |
||
125 | |||
126 | LSL_List values = new LSL_List(); |
||
127 | int idx = 0; |
||
128 | while (idx < rules.Length) |
||
129 | { |
||
130 | LSL_Integer ruleInt = rules.GetLSLIntegerItem(idx); |
||
131 | uint rule = (uint)ruleInt; |
||
132 | LSL_List toadd = new LSL_List(); |
||
133 | |||
134 | switch (rule) |
||
135 | { |
||
136 | case (int)ScriptBaseClass.WL_AMBIENT: |
||
137 | toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); |
||
138 | break; |
||
139 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: |
||
140 | toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); |
||
141 | break; |
||
142 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: |
||
143 | toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); |
||
144 | break; |
||
145 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: |
||
146 | toadd.Add(new LSL_Float(wl.blurMultiplier)); |
||
147 | break; |
||
148 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: |
||
149 | toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); |
||
150 | break; |
||
151 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: |
||
152 | toadd.Add(new LSL_Float(wl.cloudCoverage)); |
||
153 | break; |
||
154 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: |
||
155 | toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); |
||
156 | break; |
||
157 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: |
||
158 | toadd.Add(new LSL_Float(wl.cloudScale)); |
||
159 | break; |
||
160 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: |
||
161 | toadd.Add(new LSL_Float(wl.cloudScrollX)); |
||
162 | break; |
||
163 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: |
||
164 | toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); |
||
165 | break; |
||
166 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: |
||
167 | toadd.Add(new LSL_Float(wl.cloudScrollY)); |
||
168 | break; |
||
169 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: |
||
170 | toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); |
||
171 | break; |
||
172 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: |
||
173 | toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); |
||
174 | break; |
||
175 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: |
||
176 | toadd.Add(new LSL_Float(wl.densityMultiplier)); |
||
177 | break; |
||
178 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: |
||
179 | toadd.Add(new LSL_Float(wl.distanceMultiplier)); |
||
180 | break; |
||
181 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: |
||
182 | toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); |
||
183 | break; |
||
184 | case (int)ScriptBaseClass.WL_EAST_ANGLE: |
||
185 | toadd.Add(new LSL_Float(wl.eastAngle)); |
||
186 | break; |
||
187 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: |
||
188 | toadd.Add(new LSL_Float(wl.fresnelOffset)); |
||
189 | break; |
||
190 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: |
||
191 | toadd.Add(new LSL_Float(wl.fresnelScale)); |
||
192 | break; |
||
193 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: |
||
194 | toadd.Add(new LSL_Float(wl.hazeDensity)); |
||
195 | break; |
||
196 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: |
||
197 | toadd.Add(new LSL_Float(wl.hazeHorizon)); |
||
198 | break; |
||
199 | case (int)ScriptBaseClass.WL_HORIZON: |
||
200 | toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); |
||
201 | break; |
||
202 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: |
||
203 | toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); |
||
204 | break; |
||
205 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: |
||
206 | toadd.Add(new LSL_Integer(wl.maxAltitude)); |
||
207 | break; |
||
208 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: |
||
209 | toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); |
||
210 | break; |
||
211 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: |
||
212 | toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); |
||
213 | break; |
||
214 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: |
||
215 | toadd.Add(new LSL_Float(wl.refractScaleAbove)); |
||
216 | break; |
||
217 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: |
||
218 | toadd.Add(new LSL_Float(wl.refractScaleBelow)); |
||
219 | break; |
||
220 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: |
||
221 | toadd.Add(new LSL_Float(wl.sceneGamma)); |
||
222 | break; |
||
223 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: |
||
224 | toadd.Add(new LSL_Float(wl.starBrightness)); |
||
225 | break; |
||
226 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: |
||
227 | toadd.Add(new LSL_Float(wl.sunGlowFocus)); |
||
228 | break; |
||
229 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: |
||
230 | toadd.Add(new LSL_Float(wl.sunGlowSize)); |
||
231 | break; |
||
232 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: |
||
233 | toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); |
||
234 | break; |
||
235 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: |
||
236 | toadd.Add(new LSL_Float(wl.sunMoonPosition)); |
||
237 | break; |
||
238 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: |
||
239 | toadd.Add(new LSL_Float(wl.underwaterFogModifier)); |
||
240 | break; |
||
241 | case (int)ScriptBaseClass.WL_WATER_COLOR: |
||
242 | toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); |
||
243 | break; |
||
244 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: |
||
245 | toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); |
||
246 | break; |
||
247 | } |
||
248 | |||
249 | if (toadd.Length > 0) |
||
250 | { |
||
251 | values.Add(ruleInt); |
||
252 | values.Add(toadd.Data[0]); |
||
253 | } |
||
254 | idx++; |
||
255 | } |
||
256 | |||
257 | return values; |
||
258 | } |
||
259 | |||
260 | private RegionLightShareData getWindlightProfileFromRules(LSL_List rules) |
||
261 | { |
||
262 | RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); |
||
263 | |||
264 | // LSL_List values = new LSL_List(); |
||
265 | int idx = 0; |
||
266 | while (idx < rules.Length) |
||
267 | { |
||
268 | uint rule = (uint)rules.GetLSLIntegerItem(idx); |
||
269 | LSL_Types.Quaternion iQ; |
||
270 | LSL_Types.Vector3 iV; |
||
271 | switch (rule) |
||
272 | { |
||
273 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: |
||
274 | idx++; |
||
275 | wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); |
||
276 | break; |
||
277 | case (int)ScriptBaseClass.WL_AMBIENT: |
||
278 | idx++; |
||
279 | iQ = rules.GetQuaternionItem(idx); |
||
280 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
||
281 | break; |
||
282 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: |
||
283 | idx++; |
||
284 | iV = rules.GetVector3Item(idx); |
||
285 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); |
||
286 | break; |
||
287 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: |
||
288 | idx++; |
||
289 | iQ = rules.GetQuaternionItem(idx); |
||
290 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
||
291 | break; |
||
292 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: |
||
293 | idx++; |
||
294 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); |
||
295 | break; |
||
296 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: |
||
297 | idx++; |
||
298 | iQ = rules.GetQuaternionItem(idx); |
||
299 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
||
300 | break; |
||
301 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: |
||
302 | idx++; |
||
303 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); |
||
304 | break; |
||
305 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: |
||
306 | idx++; |
||
307 | iV = rules.GetVector3Item(idx); |
||
308 | wl.cloudDetailXYDensity = iV; |
||
309 | break; |
||
310 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: |
||
311 | idx++; |
||
312 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); |
||
313 | break; |
||
314 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: |
||
315 | idx++; |
||
316 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); |
||
317 | break; |
||
318 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: |
||
319 | idx++; |
||
320 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; |
||
321 | break; |
||
322 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: |
||
323 | idx++; |
||
324 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); |
||
325 | break; |
||
326 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: |
||
327 | idx++; |
||
328 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; |
||
329 | break; |
||
330 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: |
||
331 | idx++; |
||
332 | iV = rules.GetVector3Item(idx); |
||
333 | wl.cloudXYDensity = iV; |
||
334 | break; |
||
335 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: |
||
336 | idx++; |
||
337 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); |
||
338 | break; |
||
339 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: |
||
340 | idx++; |
||
341 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); |
||
342 | break; |
||
343 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: |
||
344 | idx++; |
||
345 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; |
||
346 | break; |
||
347 | case (int)ScriptBaseClass.WL_EAST_ANGLE: |
||
348 | idx++; |
||
349 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); |
||
350 | break; |
||
351 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: |
||
352 | idx++; |
||
353 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); |
||
354 | break; |
||
355 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: |
||
356 | idx++; |
||
357 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); |
||
358 | break; |
||
359 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: |
||
360 | idx++; |
||
361 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); |
||
362 | break; |
||
363 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: |
||
364 | idx++; |
||
365 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); |
||
366 | break; |
||
367 | case (int)ScriptBaseClass.WL_HORIZON: |
||
368 | idx++; |
||
369 | iQ = rules.GetQuaternionItem(idx); |
||
370 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
||
371 | break; |
||
372 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: |
||
373 | idx++; |
||
374 | iV = rules.GetVector3Item(idx); |
||
375 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); |
||
376 | break; |
||
377 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: |
||
378 | idx++; |
||
379 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; |
||
380 | break; |
||
381 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: |
||
382 | idx++; |
||
383 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); |
||
384 | break; |
||
385 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: |
||
386 | idx++; |
||
387 | iV = rules.GetVector3Item(idx); |
||
388 | wl.reflectionWaveletScale = iV; |
||
389 | break; |
||
390 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: |
||
391 | idx++; |
||
392 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); |
||
393 | break; |
||
394 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: |
||
395 | idx++; |
||
396 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); |
||
397 | break; |
||
398 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: |
||
399 | idx++; |
||
400 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); |
||
401 | break; |
||
402 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: |
||
403 | idx++; |
||
404 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); |
||
405 | break; |
||
406 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: |
||
407 | idx++; |
||
408 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); |
||
409 | break; |
||
410 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: |
||
411 | idx++; |
||
412 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); |
||
413 | break; |
||
414 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: |
||
415 | idx++; |
||
416 | iQ = rules.GetQuaternionItem(idx); |
||
417 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); |
||
418 | break; |
||
419 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: |
||
420 | idx++; |
||
421 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); |
||
422 | break; |
||
423 | case (int)ScriptBaseClass.WL_WATER_COLOR: |
||
424 | idx++; |
||
425 | iV = rules.GetVector3Item(idx); |
||
426 | wl.waterColor = iV; |
||
427 | break; |
||
428 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: |
||
429 | idx++; |
||
430 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); |
||
431 | break; |
||
432 | } |
||
433 | idx++; |
||
434 | } |
||
435 | return wl; |
||
436 | } |
||
437 | |||
438 | /// <summary> |
||
439 | /// Set the current Windlight scene |
||
440 | /// </summary> |
||
441 | /// <param name="rules"></param> |
||
442 | /// <returns>success: true or false</returns> |
||
443 | public int lsSetWindlightScene(LSL_List rules) |
||
444 | { |
||
445 | if (!m_LSFunctionsEnabled) |
||
446 | { |
||
447 | LSShoutError("LightShare functions are not enabled."); |
||
448 | return 0; |
||
449 | } |
||
450 | |||
451 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID)) |
||
452 | { |
||
453 | ScenePresence sp = World.GetScenePresence(m_host.OwnerID); |
||
454 | |||
455 | if (sp == null || sp.GodLevel < 200) |
||
456 | { |
||
457 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
||
458 | return 0; |
||
459 | } |
||
460 | } |
||
461 | |||
462 | int success = 0; |
||
463 | m_host.AddScriptLPS(1); |
||
464 | |||
465 | if (LightShareModule.EnableWindlight) |
||
466 | { |
||
467 | RegionLightShareData wl = getWindlightProfileFromRules(rules); |
||
468 | wl.valid = true; |
||
469 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); |
||
470 | success = 1; |
||
471 | } |
||
472 | else |
||
473 | { |
||
474 | LSShoutError("Windlight module is disabled"); |
||
475 | return 0; |
||
476 | } |
||
477 | |||
478 | return success; |
||
479 | } |
||
480 | |||
481 | public void lsClearWindlightScene() |
||
482 | { |
||
483 | if (!m_LSFunctionsEnabled) |
||
484 | { |
||
485 | LSShoutError("LightShare functions are not enabled."); |
||
486 | return; |
||
487 | } |
||
488 | |||
489 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID)) |
||
490 | { |
||
491 | ScenePresence sp = World.GetScenePresence(m_host.OwnerID); |
||
492 | |||
493 | if (sp == null || sp.GodLevel < 200) |
||
494 | { |
||
495 | LSShoutError("lsSetWindlightScene can only be used by estate managers or owners."); |
||
496 | return; |
||
497 | } |
||
498 | } |
||
499 | |||
500 | m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.valid = false; |
||
501 | if (m_host.ParentGroup.Scene.SimulationDataService != null) |
||
502 | m_host.ParentGroup.Scene.SimulationDataService.RemoveRegionWindlightSettings(m_host.ParentGroup.Scene.RegionInfo.RegionID); |
||
503 | |||
504 | m_host.ParentGroup.Scene.EventManager.TriggerOnSaveNewWindlightProfile(); |
||
505 | } |
||
506 | |||
507 | /// <summary> |
||
508 | /// Set the current Windlight scene to a target avatar |
||
509 | /// </summary> |
||
510 | /// <param name="rules"></param> |
||
511 | /// <returns>success: true or false</returns> |
||
512 | public int lsSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) |
||
513 | { |
||
514 | if (!m_LSFunctionsEnabled) |
||
515 | { |
||
516 | LSShoutError("LightShare functions are not enabled."); |
||
517 | return 0; |
||
518 | } |
||
519 | |||
520 | if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID)) |
||
521 | { |
||
522 | ScenePresence sp = World.GetScenePresence(m_host.OwnerID); |
||
523 | |||
524 | if (sp == null || sp.GodLevel < 200) |
||
525 | { |
||
526 | LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners."); |
||
527 | return 0; |
||
528 | } |
||
529 | } |
||
530 | |||
531 | int success = 0; |
||
532 | m_host.AddScriptLPS(1); |
||
533 | |||
534 | if (LightShareModule.EnableWindlight) |
||
535 | { |
||
536 | RegionLightShareData wl = getWindlightProfileFromRules(rules); |
||
537 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); |
||
538 | success = 1; |
||
539 | } |
||
540 | else |
||
541 | { |
||
542 | LSShoutError("Windlight module is disabled"); |
||
543 | return 0; |
||
544 | } |
||
545 | |||
546 | return success; |
||
547 | } |
||
548 | } |
||
549 | } |