diff options
Diffstat (limited to '')
5 files changed, 707 insertions, 0 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..880ca1b --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/CM_Api.cs | |||
@@ -0,0 +1,504 @@ | |||
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 OpenMetaverse; | ||
34 | using Nini.Config; | ||
35 | using OpenSim; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.CoreModules.World.LightShare; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Region.ScriptEngine.Shared; | ||
41 | using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; | ||
42 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
43 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
44 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
45 | |||
46 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
47 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
48 | using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
49 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
50 | using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
51 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
52 | using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
53 | |||
54 | namespace OpenSim.Region.ScriptEngine.Shared.Api | ||
55 | { | ||
56 | [Serializable] | ||
57 | public class CM_Api : MarshalByRefObject, ICM_Api, IScriptApi | ||
58 | { | ||
59 | internal IScriptEngine m_ScriptEngine; | ||
60 | internal SceneObjectPart m_host; | ||
61 | internal uint m_localID; | ||
62 | internal UUID m_itemID; | ||
63 | internal bool m_CMFunctionsEnabled = false; | ||
64 | internal IScriptModuleComms m_comms = null; | ||
65 | |||
66 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID) | ||
67 | { | ||
68 | m_ScriptEngine = ScriptEngine; | ||
69 | m_host = host; | ||
70 | m_localID = localID; | ||
71 | m_itemID = itemID; | ||
72 | |||
73 | if (m_ScriptEngine.Config.GetBoolean("AllowCareminsterFunctions", false)) | ||
74 | m_CMFunctionsEnabled = true; | ||
75 | |||
76 | m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>(); | ||
77 | if (m_comms == null) | ||
78 | m_CMFunctionsEnabled = false; | ||
79 | } | ||
80 | |||
81 | public override Object InitializeLifetimeService() | ||
82 | { | ||
83 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
84 | |||
85 | if (lease.CurrentState == LeaseState.Initial) | ||
86 | { | ||
87 | lease.InitialLeaseTime = TimeSpan.FromMinutes(0); | ||
88 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0); | ||
89 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0); | ||
90 | } | ||
91 | return lease; | ||
92 | } | ||
93 | |||
94 | public Scene World | ||
95 | { | ||
96 | get { return m_ScriptEngine.World; } | ||
97 | } | ||
98 | |||
99 | // | ||
100 | //Dumps an error message on the debug console. | ||
101 | // | ||
102 | |||
103 | internal void CMShoutError(string message) | ||
104 | { | ||
105 | if (message.Length > 1023) | ||
106 | message = message.Substring(0, 1023); | ||
107 | |||
108 | World.SimChat(Utils.StringToBytes(message), | ||
109 | ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true); | ||
110 | |||
111 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
112 | wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); | ||
113 | } | ||
114 | |||
115 | /// <summary> | ||
116 | /// Get the current Windlight scene | ||
117 | /// </summary> | ||
118 | /// <returns>List of windlight parameters</returns> | ||
119 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
120 | { | ||
121 | if (!m_CMFunctionsEnabled) | ||
122 | { | ||
123 | CMShoutError("Careminster functions are not enabled."); | ||
124 | return new LSL_List(); | ||
125 | } | ||
126 | m_host.AddScriptLPS(1); | ||
127 | RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings; | ||
128 | |||
129 | LSL_List values = new LSL_List(); | ||
130 | int idx = 0; | ||
131 | while (idx < rules.Length) | ||
132 | { | ||
133 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
134 | LSL_List toadd = new LSL_List(); | ||
135 | |||
136 | switch (rule) | ||
137 | { | ||
138 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
139 | toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W)); | ||
140 | break; | ||
141 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
142 | toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f)); | ||
143 | break; | ||
144 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
145 | toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W)); | ||
146 | break; | ||
147 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
148 | toadd.Add(new LSL_Float(wl.blurMultiplier)); | ||
149 | break; | ||
150 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
151 | toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W)); | ||
152 | break; | ||
153 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
154 | toadd.Add(new LSL_Float(wl.cloudCoverage)); | ||
155 | break; | ||
156 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
157 | toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z)); | ||
158 | break; | ||
159 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
160 | toadd.Add(new LSL_Float(wl.cloudScale)); | ||
161 | break; | ||
162 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
163 | toadd.Add(new LSL_Float(wl.cloudScrollX)); | ||
164 | break; | ||
165 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
166 | toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0)); | ||
167 | break; | ||
168 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
169 | toadd.Add(new LSL_Float(wl.cloudScrollY)); | ||
170 | break; | ||
171 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
172 | toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0)); | ||
173 | break; | ||
174 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
175 | toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z)); | ||
176 | break; | ||
177 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
178 | toadd.Add(new LSL_Float(wl.densityMultiplier)); | ||
179 | break; | ||
180 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
181 | toadd.Add(new LSL_Float(wl.distanceMultiplier)); | ||
182 | break; | ||
183 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
184 | toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0)); | ||
185 | break; | ||
186 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
187 | toadd.Add(new LSL_Float(wl.eastAngle)); | ||
188 | break; | ||
189 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
190 | toadd.Add(new LSL_Float(wl.fresnelOffset)); | ||
191 | break; | ||
192 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
193 | toadd.Add(new LSL_Float(wl.fresnelScale)); | ||
194 | break; | ||
195 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
196 | toadd.Add(new LSL_Float(wl.hazeDensity)); | ||
197 | break; | ||
198 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
199 | toadd.Add(new LSL_Float(wl.hazeHorizon)); | ||
200 | break; | ||
201 | case (int)ScriptBaseClass.WL_HORIZON: | ||
202 | toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W)); | ||
203 | break; | ||
204 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
205 | toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f)); | ||
206 | break; | ||
207 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
208 | toadd.Add(new LSL_Integer(wl.maxAltitude)); | ||
209 | break; | ||
210 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
211 | toadd.Add(new LSL_Key(wl.normalMapTexture.ToString())); | ||
212 | break; | ||
213 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
214 | toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z)); | ||
215 | break; | ||
216 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
217 | toadd.Add(new LSL_Float(wl.refractScaleAbove)); | ||
218 | break; | ||
219 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
220 | toadd.Add(new LSL_Float(wl.refractScaleBelow)); | ||
221 | break; | ||
222 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
223 | toadd.Add(new LSL_Float(wl.sceneGamma)); | ||
224 | break; | ||
225 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
226 | toadd.Add(new LSL_Float(wl.starBrightness)); | ||
227 | break; | ||
228 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
229 | toadd.Add(new LSL_Float(wl.sunGlowFocus)); | ||
230 | break; | ||
231 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
232 | toadd.Add(new LSL_Float(wl.sunGlowSize)); | ||
233 | break; | ||
234 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
235 | toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W)); | ||
236 | break; | ||
237 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
238 | toadd.Add(new LSL_Float(wl.underwaterFogModifier)); | ||
239 | break; | ||
240 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
241 | toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z)); | ||
242 | break; | ||
243 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
244 | toadd.Add(new LSL_Float(wl.waterFogDensityExponent)); | ||
245 | break; | ||
246 | } | ||
247 | |||
248 | if (toadd.Length > 0) | ||
249 | { | ||
250 | values.Add(rule); | ||
251 | values.Add(toadd.Data[0]); | ||
252 | } | ||
253 | idx++; | ||
254 | } | ||
255 | |||
256 | |||
257 | return values; | ||
258 | |||
259 | } | ||
260 | |||
261 | private RegionLightShareData getWindlightProfileFromRules(LSL_List rules) | ||
262 | { | ||
263 | RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); | ||
264 | |||
265 | LSL_List values = new LSL_List(); | ||
266 | int idx = 0; | ||
267 | while (idx < rules.Length) | ||
268 | { | ||
269 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | ||
270 | LSL_Types.Quaternion iQ; | ||
271 | LSL_Types.Vector3 iV; | ||
272 | switch (rule) | ||
273 | { | ||
274 | case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: | ||
275 | idx++; | ||
276 | wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); | ||
277 | break; | ||
278 | case (int)ScriptBaseClass.WL_AMBIENT: | ||
279 | idx++; | ||
280 | iQ = rules.GetQuaternionItem(idx); | ||
281 | wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
282 | break; | ||
283 | case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION: | ||
284 | idx++; | ||
285 | iV = rules.GetVector3Item(idx); | ||
286 | wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
287 | break; | ||
288 | case (int)ScriptBaseClass.WL_BLUE_DENSITY: | ||
289 | idx++; | ||
290 | iQ = rules.GetQuaternionItem(idx); | ||
291 | wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
292 | break; | ||
293 | case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER: | ||
294 | idx++; | ||
295 | wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
296 | break; | ||
297 | case (int)ScriptBaseClass.WL_CLOUD_COLOR: | ||
298 | idx++; | ||
299 | iQ = rules.GetQuaternionItem(idx); | ||
300 | wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
301 | break; | ||
302 | case (int)ScriptBaseClass.WL_CLOUD_COVERAGE: | ||
303 | idx++; | ||
304 | wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx); | ||
305 | break; | ||
306 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | ||
307 | idx++; | ||
308 | iV = rules.GetVector3Item(idx); | ||
309 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
310 | break; | ||
311 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | ||
312 | idx++; | ||
313 | wl.cloudScale = (float)rules.GetLSLFloatItem(idx); | ||
314 | break; | ||
315 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X: | ||
316 | idx++; | ||
317 | wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx); | ||
318 | break; | ||
319 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK: | ||
320 | idx++; | ||
321 | wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
322 | break; | ||
323 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y: | ||
324 | idx++; | ||
325 | wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx); | ||
326 | break; | ||
327 | case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK: | ||
328 | idx++; | ||
329 | wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
330 | break; | ||
331 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | ||
332 | idx++; | ||
333 | iV = rules.GetVector3Item(idx); | ||
334 | wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
335 | break; | ||
336 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | ||
337 | idx++; | ||
338 | wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
339 | break; | ||
340 | case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER: | ||
341 | idx++; | ||
342 | wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx); | ||
343 | break; | ||
344 | case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS: | ||
345 | idx++; | ||
346 | wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false; | ||
347 | break; | ||
348 | case (int)ScriptBaseClass.WL_EAST_ANGLE: | ||
349 | idx++; | ||
350 | wl.eastAngle = (float)rules.GetLSLFloatItem(idx); | ||
351 | break; | ||
352 | case (int)ScriptBaseClass.WL_FRESNEL_OFFSET: | ||
353 | idx++; | ||
354 | wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx); | ||
355 | break; | ||
356 | case (int)ScriptBaseClass.WL_FRESNEL_SCALE: | ||
357 | idx++; | ||
358 | wl.fresnelScale = (float)rules.GetLSLFloatItem(idx); | ||
359 | break; | ||
360 | case (int)ScriptBaseClass.WL_HAZE_DENSITY: | ||
361 | idx++; | ||
362 | wl.hazeDensity = (float)rules.GetLSLFloatItem(idx); | ||
363 | break; | ||
364 | case (int)ScriptBaseClass.WL_HAZE_HORIZON: | ||
365 | idx++; | ||
366 | wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx); | ||
367 | break; | ||
368 | case (int)ScriptBaseClass.WL_HORIZON: | ||
369 | idx++; | ||
370 | iQ = rules.GetQuaternionItem(idx); | ||
371 | wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
372 | break; | ||
373 | case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION: | ||
374 | idx++; | ||
375 | iV = rules.GetVector3Item(idx); | ||
376 | wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y); | ||
377 | break; | ||
378 | case (int)ScriptBaseClass.WL_MAX_ALTITUDE: | ||
379 | idx++; | ||
380 | wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value; | ||
381 | break; | ||
382 | case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE: | ||
383 | idx++; | ||
384 | wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string); | ||
385 | break; | ||
386 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | ||
387 | idx++; | ||
388 | iV = rules.GetVector3Item(idx); | ||
389 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
390 | break; | ||
391 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | ||
392 | idx++; | ||
393 | wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx); | ||
394 | break; | ||
395 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW: | ||
396 | idx++; | ||
397 | wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx); | ||
398 | break; | ||
399 | case (int)ScriptBaseClass.WL_SCENE_GAMMA: | ||
400 | idx++; | ||
401 | wl.sceneGamma = (float)rules.GetLSLFloatItem(idx); | ||
402 | break; | ||
403 | case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS: | ||
404 | idx++; | ||
405 | wl.starBrightness = (float)rules.GetLSLFloatItem(idx); | ||
406 | break; | ||
407 | case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS: | ||
408 | idx++; | ||
409 | wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx); | ||
410 | break; | ||
411 | case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE: | ||
412 | idx++; | ||
413 | wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx); | ||
414 | break; | ||
415 | case (int)ScriptBaseClass.WL_SUN_MOON_COLOR: | ||
416 | idx++; | ||
417 | iQ = rules.GetQuaternionItem(idx); | ||
418 | wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s); | ||
419 | break; | ||
420 | case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER: | ||
421 | idx++; | ||
422 | wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx); | ||
423 | break; | ||
424 | case (int)ScriptBaseClass.WL_WATER_COLOR: | ||
425 | idx++; | ||
426 | iV = rules.GetVector3Item(idx); | ||
427 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | ||
428 | break; | ||
429 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | ||
430 | idx++; | ||
431 | wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx); | ||
432 | break; | ||
433 | } | ||
434 | idx++; | ||
435 | } | ||
436 | return wl; | ||
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 cmSetWindlightScene(LSL_List rules) | ||
444 | { | ||
445 | if (!m_CMFunctionsEnabled) | ||
446 | { | ||
447 | CMShoutError("Careminster functions are not enabled."); | ||
448 | return 0; | ||
449 | } | ||
450 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
451 | { | ||
452 | CMShoutError("cmSetWindlightScene can only be used by estate managers or owners."); | ||
453 | return 0; | ||
454 | } | ||
455 | int success = 0; | ||
456 | m_host.AddScriptLPS(1); | ||
457 | if (LightShareModule.EnableWindlight) | ||
458 | { | ||
459 | RegionLightShareData wl = getWindlightProfileFromRules(rules); | ||
460 | m_host.ParentGroup.Scene.StoreWindlightProfile(wl); | ||
461 | success = 1; | ||
462 | } | ||
463 | else | ||
464 | { | ||
465 | CMShoutError("Windlight module is disabled"); | ||
466 | return 0; | ||
467 | } | ||
468 | return success; | ||
469 | } | ||
470 | /// <summary> | ||
471 | /// Set the current Windlight scene to a target avatar | ||
472 | /// </summary> | ||
473 | /// <param name="rules"></param> | ||
474 | /// <returns>success: true or false</returns> | ||
475 | public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target) | ||
476 | { | ||
477 | if (!m_CMFunctionsEnabled) | ||
478 | { | ||
479 | CMShoutError("Careminster functions are not enabled."); | ||
480 | return 0; | ||
481 | } | ||
482 | if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) | ||
483 | { | ||
484 | CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners."); | ||
485 | return 0; | ||
486 | } | ||
487 | int success = 0; | ||
488 | m_host.AddScriptLPS(1); | ||
489 | if (LightShareModule.EnableWindlight) | ||
490 | { | ||
491 | RegionLightShareData wl = getWindlightProfileFromRules(rules); | ||
492 | World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string)); | ||
493 | success = 1; | ||
494 | } | ||
495 | else | ||
496 | { | ||
497 | CMShoutError("Windlight module is disabled"); | ||
498 | return 0; | ||
499 | } | ||
500 | return success; | ||
501 | } | ||
502 | |||
503 | } | ||
504 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs new file mode 100644 index 0000000..f13b6e5 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ICM_Api.cs | |||
@@ -0,0 +1,48 @@ | |||
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.Collections; | ||
29 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
30 | |||
31 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
32 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
33 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
34 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
35 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
36 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
37 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
38 | |||
39 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | ||
40 | { | ||
41 | public interface ICM_Api | ||
42 | { | ||
43 | // Windlight Functions | ||
44 | LSL_List cmGetWindlightScene(LSL_List rules); | ||
45 | int cmSetWindlightScene(LSL_List rules); | ||
46 | int cmSetWindlightSceneTargeted(LSL_List rules, key target); | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs new file mode 100644 index 0000000..f94ef4a --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Constants.cs | |||
@@ -0,0 +1,77 @@ | |||
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 vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
30 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
31 | using LSLInteger = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
34 | { | ||
35 | public partial class ScriptBaseClass | ||
36 | { | ||
37 | // Constants for cmWindlight* | ||
38 | public const int WL_WATER_COLOR = 0; | ||
39 | public const int WL_WATER_FOG_DENSITY_EXPONENT = 1; | ||
40 | public const int WL_UNDERWATER_FOG_MODIFIER = 2; | ||
41 | public const int WL_REFLECTION_WAVELET_SCALE = 3; | ||
42 | public const int WL_FRESNEL_SCALE = 4; | ||
43 | public const int WL_FRESNEL_OFFSET = 5; | ||
44 | public const int WL_REFRACT_SCALE_ABOVE = 6; | ||
45 | public const int WL_REFRACT_SCALE_BELOW = 7; | ||
46 | public const int WL_BLUR_MULTIPLIER = 8; | ||
47 | public const int WL_BIG_WAVE_DIRECTION = 9; | ||
48 | public const int WL_LITTLE_WAVE_DIRECTION = 10; | ||
49 | public const int WL_NORMAL_MAP_TEXTURE = 11; | ||
50 | public const int WL_HORIZON = 12; | ||
51 | public const int WL_HAZE_HORIZON = 13; | ||
52 | public const int WL_BLUE_DENSITY = 14; | ||
53 | public const int WL_HAZE_DENSITY = 15; | ||
54 | public const int WL_DENSITY_MULTIPLIER = 16; | ||
55 | public const int WL_DISTANCE_MULTIPLIER = 17; | ||
56 | public const int WL_MAX_ALTITUDE = 18; | ||
57 | public const int WL_SUN_MOON_COLOR = 19; | ||
58 | public const int WL_AMBIENT = 20; | ||
59 | public const int WL_EAST_ANGLE = 21; | ||
60 | public const int WL_SUN_GLOW_FOCUS = 22; | ||
61 | public const int WL_SUN_GLOW_SIZE = 23; | ||
62 | public const int WL_SCENE_GAMMA = 24; | ||
63 | public const int WL_STAR_BRIGHTNESS = 25; | ||
64 | public const int WL_CLOUD_COLOR = 26; | ||
65 | public const int WL_CLOUD_XY_DENSITY = 27; | ||
66 | public const int WL_CLOUD_COVERAGE = 28; | ||
67 | public const int WL_CLOUD_SCALE = 29; | ||
68 | public const int WL_CLOUD_DETAIL_XY_DENSITY = 30; | ||
69 | public const int WL_CLOUD_SCROLL_X = 31; | ||
70 | public const int WL_CLOUD_SCROLL_Y = 32; | ||
71 | public const int WL_CLOUD_SCROLL_Y_LOCK = 33; | ||
72 | public const int WL_CLOUD_SCROLL_X_LOCK = 34; | ||
73 | public const int WL_DRAW_CLASSIC_CLOUDS = 35; | ||
74 | public const int WL_SUN_MOON_POSITION = 36; | ||
75 | |||
76 | } | ||
77 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs new file mode 100644 index 0000000..c0edaae --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/CM_Stub.cs | |||
@@ -0,0 +1,76 @@ | |||
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.Runtime.Remoting.Lifetime; | ||
30 | using System.Threading; | ||
31 | using System.Reflection; | ||
32 | using System.Collections; | ||
33 | using System.Collections.Generic; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.ScriptEngine.Interfaces; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | ||
38 | using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
39 | using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; | ||
40 | using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; | ||
41 | using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
42 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
43 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
44 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
45 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
46 | |||
47 | namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | ||
48 | { | ||
49 | public partial class ScriptBaseClass : MarshalByRefObject | ||
50 | { | ||
51 | public ICM_Api m_CM_Functions; | ||
52 | |||
53 | public void ApiTypeCM(IScriptApi api) | ||
54 | { | ||
55 | if (!(api is ICM_Api)) | ||
56 | return; | ||
57 | |||
58 | m_CM_Functions = (ICM_Api)api; | ||
59 | } | ||
60 | |||
61 | public LSL_List cmGetWindlightScene(LSL_List rules) | ||
62 | { | ||
63 | return m_CM_Functions.cmGetWindlightScene(rules); | ||
64 | } | ||
65 | |||
66 | public int cmSetWindlightScene(LSL_List rules) | ||
67 | { | ||
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); | ||
74 | } | ||
75 | } | ||
76 | } | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp index 98bbc68..23138ef 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OpenSim.Region.ScriptEngine.Shared.Api.Runtime.mdp | |||
@@ -17,6 +17,8 @@ | |||
17 | <excludeFiles /> | 17 | <excludeFiles /> |
18 | </DeploymentInformation> | 18 | </DeploymentInformation> |
19 | <Contents> | 19 | <Contents> |
20 | <File name="./CM_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
21 | <File name="./CM_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | ||
20 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 22 | <File name="./Executor.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
21 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 23 | <File name="./LSL_Constants.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |
22 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> | 24 | <File name="./LSL_Stub.cs" subtype="Code" buildaction="Compile" dependson="" data="" /> |