diff options
author | Melanie Thielker | 2009-03-20 22:42:21 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-03-20 22:42:21 +0000 |
commit | c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e (patch) | |
tree | edc6448e13492d2691aba97ae8d6f9561c1a3da4 | |
parent | * Ignored some gens (diff) | |
download | opensim-SC-c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e.zip opensim-SC-c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e.tar.gz opensim-SC-c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e.tar.bz2 opensim-SC-c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e.tar.xz |
Thank you, mcortez, for patch to add functionality to the sun module.
Fixes Mantis #3313
4 files changed, 338 insertions, 26 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index 3c950c1..2ab8d4c 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs | |||
@@ -37,7 +37,7 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 37 | ||
38 | namespace OpenSim.Region.CoreModules | 38 | namespace OpenSim.Region.CoreModules |
39 | { | 39 | { |
40 | public class SunModule : IRegionModule | 40 | public class SunModule : ISunModule |
41 | { | 41 | { |
42 | /// <summary> | 42 | /// <summary> |
43 | /// Note: Sun Hour can be a little deceaving. Although it's based on a 24 hour clock | 43 | /// Note: Sun Hour can be a little deceaving. Although it's based on a 24 hour clock |
@@ -47,6 +47,7 @@ namespace OpenSim.Region.CoreModules | |||
47 | 47 | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | |||
50 | // | 51 | // |
51 | // Global Constants used to determine where in the sky the sun is | 52 | // Global Constants used to determine where in the sky the sun is |
52 | // | 53 | // |
@@ -61,7 +62,6 @@ namespace OpenSim.Region.CoreModules | |||
61 | 62 | ||
62 | private bool ready = false; | 63 | private bool ready = false; |
63 | 64 | ||
64 | |||
65 | // This solves a chick before the egg problem | 65 | // This solves a chick before the egg problem |
66 | // the local SunFixedHour and SunFixed variables MUST be updated | 66 | // the local SunFixedHour and SunFixed variables MUST be updated |
67 | // at least once with the proper Region Settings before we start | 67 | // at least once with the proper Region Settings before we start |
@@ -82,7 +82,10 @@ namespace OpenSim.Region.CoreModules | |||
82 | 82 | ||
83 | // Ratio of Daylight hours to Night time hours. This is accomplished by shifting the | 83 | // Ratio of Daylight hours to Night time hours. This is accomplished by shifting the |
84 | // sun's orbit above the horizon | 84 | // sun's orbit above the horizon |
85 | private double m_RatioDayNightHoizonShift = 0; | 85 | private double m_HorizonShift = 0; |
86 | |||
87 | // Used to scale current and positional time to adjust length of an hour during day vs night. | ||
88 | private double m_DayTimeSunHourScale; | ||
86 | 89 | ||
87 | // private double m_longitude = 0; | 90 | // private double m_longitude = 0; |
88 | // private double m_latitude = 0; | 91 | // private double m_latitude = 0; |
@@ -92,7 +95,9 @@ namespace OpenSim.Region.CoreModules | |||
92 | private double d_day_length = 4; // A VW day is 4 RW hours long | 95 | private double d_day_length = 4; // A VW day is 4 RW hours long |
93 | private int d_year_length = 60; // There are 60 VW days in a VW year | 96 | private int d_year_length = 60; // There are 60 VW days in a VW year |
94 | private double d_day_night = 0.5; // axis offset: Default Hoizon shift to try and closely match the sun model in LL Viewer | 97 | private double d_day_night = 0.5; // axis offset: Default Hoizon shift to try and closely match the sun model in LL Viewer |
95 | 98 | private double d_DayTimeSunHourScale = 0.5; // Day/Night hours are equal | |
99 | |||
100 | |||
96 | // private double d_longitude = -73.53; | 101 | // private double d_longitude = -73.53; |
97 | // private double d_latitude = 41.29; | 102 | // private double d_latitude = 41.29; |
98 | 103 | ||
@@ -144,6 +149,8 @@ namespace OpenSim.Region.CoreModules | |||
144 | // Time in seconds since UTC to use to calculate sun position. | 149 | // Time in seconds since UTC to use to calculate sun position. |
145 | ulong PosTime = 0; | 150 | ulong PosTime = 0; |
146 | 151 | ||
152 | |||
153 | |||
147 | /// <summary> | 154 | /// <summary> |
148 | /// Calculate the sun's orbital position and its velocity. | 155 | /// Calculate the sun's orbital position and its velocity. |
149 | /// </summary> | 156 | /// </summary> |
@@ -172,6 +179,31 @@ namespace OpenSim.Region.CoreModules | |||
172 | // Fixed Sun Hour needs to be scaled to reflect the user configured Seconds Per Sun Cycle | 179 | // Fixed Sun Hour needs to be scaled to reflect the user configured Seconds Per Sun Cycle |
173 | PosTime += (ulong)((m_SunFixedHour / 24.0) * (ulong)SecondsPerSunCycle); | 180 | PosTime += (ulong)((m_SunFixedHour / 24.0) * (ulong)SecondsPerSunCycle); |
174 | } | 181 | } |
182 | else | ||
183 | { | ||
184 | if (m_DayTimeSunHourScale != 0.5f) | ||
185 | { | ||
186 | ulong CurDaySeconds = CurrentTime % SecondsPerSunCycle; | ||
187 | double CurDayPercentage = (double)CurDaySeconds / SecondsPerSunCycle; | ||
188 | |||
189 | ulong DayLightSeconds = (ulong)(m_DayTimeSunHourScale * SecondsPerSunCycle); | ||
190 | ulong NightSeconds = SecondsPerSunCycle - DayLightSeconds; | ||
191 | |||
192 | PosTime = CurrentTime / SecondsPerSunCycle; | ||
193 | PosTime *= SecondsPerSunCycle; | ||
194 | |||
195 | if (CurDayPercentage < 0.5) | ||
196 | { | ||
197 | PosTime += (ulong)((CurDayPercentage / .5) * DayLightSeconds); | ||
198 | } | ||
199 | else | ||
200 | { | ||
201 | PosTime += DayLightSeconds; | ||
202 | PosTime += (ulong)(((CurDayPercentage - 0.5) / .5) * NightSeconds); | ||
203 | } | ||
204 | } | ||
205 | |||
206 | } | ||
175 | 207 | ||
176 | TotalDistanceTravelled = SunSpeed * PosTime; // distance measured in radians | 208 | TotalDistanceTravelled = SunSpeed * PosTime; // distance measured in radians |
177 | 209 | ||
@@ -232,32 +264,18 @@ namespace OpenSim.Region.CoreModules | |||
232 | if (receivedEstateToolsSunUpdate) | 264 | if (receivedEstateToolsSunUpdate) |
233 | { | 265 | { |
234 | m_scene.RegionInfo.RegionSettings.SunVector = Position; | 266 | m_scene.RegionInfo.RegionSettings.SunVector = Position; |
235 | m_scene.RegionInfo.RegionSettings.SunPosition = GetSunHourAsLindenSunHour(); | 267 | m_scene.RegionInfo.RegionSettings.SunPosition = GetCurrentTimeAsLindenSunHour(); |
236 | } | 268 | } |
237 | } | 269 | } |
238 | 270 | ||
239 | /// <summary> | ||
240 | /// Used to calculate the "linden sun hour" which is from 6 to 30, with 6 being "sun rise" | ||
241 | /// on the left most end of the Sun Slider in the client. | ||
242 | /// TODO: Decouple this and send it closer to linden client code. | ||
243 | /// </summary> | ||
244 | private float GetCurrentTimeAsLindenSunHour() | 271 | private float GetCurrentTimeAsLindenSunHour() |
245 | { | 272 | { |
246 | float ticksleftover = ((float)CurrentTime) % ((float)SecondsPerSunCycle); | ||
247 | |||
248 | float hour = (24.0f * (ticksleftover / SecondsPerSunCycle)) + 6.0f; | ||
249 | |||
250 | return hour; | ||
251 | } | ||
252 | |||
253 | private float GetSunHourAsLindenSunHour() | ||
254 | { | ||
255 | if (m_SunFixed) | 273 | if (m_SunFixed) |
256 | { | 274 | { |
257 | return m_SunFixedHour + 6; | 275 | return m_SunFixedHour + 6; |
258 | } | 276 | } |
259 | 277 | ||
260 | return GetCurrentTimeAsLindenSunHour(); | 278 | return GetCurrentSunHour() + 6.0f; |
261 | } | 279 | } |
262 | 280 | ||
263 | #region IRegion Methods | 281 | #region IRegion Methods |
@@ -267,9 +285,20 @@ namespace OpenSim.Region.CoreModules | |||
267 | public void Initialise(Scene scene, IConfigSource config) | 285 | public void Initialise(Scene scene, IConfigSource config) |
268 | { | 286 | { |
269 | m_scene = scene; | 287 | m_scene = scene; |
270 | |||
271 | m_frame = 0; | 288 | m_frame = 0; |
272 | 289 | ||
290 | // This one puts an entry in the main help screen | ||
291 | m_scene.AddCommand(this, String.Empty, "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null); | ||
292 | |||
293 | // This one enables the ability to type just "sun" without any parameters | ||
294 | m_scene.AddCommand(this, "sun", "", "", HandleSunConsoleCommand); | ||
295 | foreach (KeyValuePair<string, string> kvp in GetParamList()) | ||
296 | { | ||
297 | m_scene.AddCommand(this, String.Format("sun {0}", kvp.Key), String.Format("{0} - {1}", kvp.Key, kvp.Value), "", HandleSunConsoleCommand); | ||
298 | } | ||
299 | |||
300 | |||
301 | |||
273 | TimeZone local = TimeZone.CurrentTimeZone; | 302 | TimeZone local = TimeZone.CurrentTimeZone; |
274 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; | 303 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; |
275 | m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset); | 304 | m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset); |
@@ -291,10 +320,18 @@ namespace OpenSim.Region.CoreModules | |||
291 | m_YearLengthDays = config.Configs["Sun"].GetInt("year_length", d_year_length); | 320 | m_YearLengthDays = config.Configs["Sun"].GetInt("year_length", d_year_length); |
292 | // Day length in decimal hours | 321 | // Day length in decimal hours |
293 | m_DayLengthHours = config.Configs["Sun"].GetDouble("day_length", d_day_length); | 322 | m_DayLengthHours = config.Configs["Sun"].GetDouble("day_length", d_day_length); |
294 | // Day to Night Ratio | 323 | |
295 | m_RatioDayNightHoizonShift = config.Configs["Sun"].GetDouble("day_night_offset", d_day_night); | 324 | // Horizon shift, this is used to shift the sun's orbit, this affects the day / night ratio |
325 | // must hard code to ~.5 to match sun position in LL based viewers | ||
326 | m_HorizonShift = config.Configs["Sun"].GetDouble("day_night_offset", d_day_night); | ||
327 | |||
328 | |||
329 | // Scales the sun hours 0...12 vs 12...24, essentially makes daylight hours longer/shorter vs nighttime hours | ||
330 | m_DayTimeSunHourScale = config.Configs["Sun"].GetDouble("day_time_sun_hour_scale", d_DayTimeSunHourScale); | ||
331 | |||
296 | // Update frequency in frames | 332 | // Update frequency in frames |
297 | m_UpdateInterval = config.Configs["Sun"].GetInt("update_interval", d_frame_mod); | 333 | m_UpdateInterval = config.Configs["Sun"].GetInt("update_interval", d_frame_mod); |
334 | |||
298 | } | 335 | } |
299 | catch (Exception e) | 336 | catch (Exception e) |
300 | { | 337 | { |
@@ -302,8 +339,10 @@ namespace OpenSim.Region.CoreModules | |||
302 | m_RegionMode = d_mode; | 339 | m_RegionMode = d_mode; |
303 | m_YearLengthDays = d_year_length; | 340 | m_YearLengthDays = d_year_length; |
304 | m_DayLengthHours = d_day_length; | 341 | m_DayLengthHours = d_day_length; |
305 | m_RatioDayNightHoizonShift = d_day_night; | 342 | m_HorizonShift = d_day_night; |
306 | m_UpdateInterval = d_frame_mod; | 343 | m_UpdateInterval = d_frame_mod; |
344 | m_DayTimeSunHourScale = d_DayTimeSunHourScale; | ||
345 | |||
307 | // m_latitude = d_latitude; | 346 | // m_latitude = d_latitude; |
308 | // m_longitude = d_longitude; | 347 | // m_longitude = d_longitude; |
309 | } | 348 | } |
@@ -330,7 +369,7 @@ namespace OpenSim.Region.CoreModules | |||
330 | 369 | ||
331 | // Horizon translation | 370 | // Horizon translation |
332 | 371 | ||
333 | HorizonShift = m_RatioDayNightHoizonShift; // Z axis translation | 372 | HorizonShift = m_HorizonShift; // Z axis translation |
334 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; | 373 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; |
335 | 374 | ||
336 | // Insert our event handling hooks | 375 | // Insert our event handling hooks |
@@ -344,13 +383,18 @@ namespace OpenSim.Region.CoreModules | |||
344 | 383 | ||
345 | m_log.Debug("[SUN]: Mode is " + m_RegionMode); | 384 | m_log.Debug("[SUN]: Mode is " + m_RegionMode); |
346 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); | 385 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); |
347 | m_log.Debug("[SUN]: Axis offset is " + m_RatioDayNightHoizonShift); | 386 | m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); |
387 | m_log.Debug("[SUN]: Percentage of time for daylight " + m_DayTimeSunHourScale); | ||
348 | m_log.Debug("[SUN]: Positional data updated every " + m_UpdateInterval + " frames"); | 388 | m_log.Debug("[SUN]: Positional data updated every " + m_UpdateInterval + " frames"); |
349 | 389 | ||
350 | break; | 390 | break; |
351 | } | 391 | } |
392 | |||
393 | scene.RegisterModuleInterface<ISunModule>(this); | ||
394 | |||
352 | } | 395 | } |
353 | 396 | ||
397 | |||
354 | public void PostInitialise() | 398 | public void PostInitialise() |
355 | { | 399 | { |
356 | } | 400 | } |
@@ -474,5 +518,159 @@ namespace OpenSim.Region.CoreModules | |||
474 | } | 518 | } |
475 | } | 519 | } |
476 | } | 520 | } |
521 | |||
522 | #region ISunModule Members | ||
523 | |||
524 | public double GetSunParameter(string param) | ||
525 | { | ||
526 | switch (param.ToLower()) | ||
527 | { | ||
528 | case "year_length": | ||
529 | return m_YearLengthDays; | ||
530 | |||
531 | case "day_length": | ||
532 | return m_DayLengthHours; | ||
533 | |||
534 | case "day_night_offset": | ||
535 | return m_HorizonShift; | ||
536 | |||
537 | case "day_time_sun_hour_scale": | ||
538 | return m_DayTimeSunHourScale; | ||
539 | |||
540 | case "update_interval": | ||
541 | return m_UpdateInterval; | ||
542 | |||
543 | default: | ||
544 | throw new Exception("Unknown sun parameter."); | ||
545 | } | ||
546 | } | ||
547 | |||
548 | public void SetSunParameter(string param, double value) | ||
549 | { | ||
550 | HandleSunConsoleCommand("sun", new string[] {param, value.ToString() }); | ||
551 | } | ||
552 | |||
553 | public float GetCurrentSunHour() | ||
554 | { | ||
555 | float ticksleftover = CurrentTime % SecondsPerSunCycle; | ||
556 | |||
557 | |||
558 | return (24.0f * (ticksleftover / SecondsPerSunCycle)); | ||
559 | } | ||
560 | |||
561 | #endregion | ||
562 | |||
563 | public void HandleSunConsoleCommand(string module, string[] cmdparams) | ||
564 | { | ||
565 | if (m_scene.ConsoleScene() == null) | ||
566 | { | ||
567 | // FIXME: If console region is root then this will be printed by every module. Currently, there is no | ||
568 | // way to prevent this, short of making the entire module shared (which is complete overkill). | ||
569 | // One possibility is to return a bool to signal whether the module has completely handled the command | ||
570 | m_log.InfoFormat("[Sun]: Please change to a specific region in order to set Sun parameters."); | ||
571 | return; | ||
572 | } | ||
573 | |||
574 | if (m_scene.ConsoleScene() != m_scene) | ||
575 | { | ||
576 | m_log.InfoFormat("[Sun]: Console Scene is not my scene."); | ||
577 | return; | ||
578 | } | ||
579 | |||
580 | m_log.InfoFormat("[Sun]: Processing command."); | ||
581 | |||
582 | foreach (string output in ParseCmdParams(cmdparams)) | ||
583 | { | ||
584 | m_log.Info("[SUN] " + output); | ||
585 | } | ||
586 | } | ||
587 | |||
588 | private Dictionary<string, string> GetParamList() | ||
589 | { | ||
590 | Dictionary<string, string> Params = new Dictionary<string, string>(); | ||
591 | |||
592 | Params.Add("year_length", "number of days to a year"); | ||
593 | Params.Add("day_length", "number of seconds to a day"); | ||
594 | Params.Add("day_night_offset", "induces a horizon shift"); | ||
595 | Params.Add("update_interval", "how often to update the sun's position in frames"); | ||
596 | Params.Add("day_time_sun_hour_scale", "scales day light vs nite hours to change day/night ratio"); | ||
597 | |||
598 | return Params; | ||
599 | } | ||
600 | |||
601 | private List<string> ParseCmdParams(string[] args) | ||
602 | { | ||
603 | List<string> Output = new List<string>(); | ||
604 | |||
605 | if ((args.Length == 1) || (args[1].ToLower() == "help") || (args[1].ToLower() == "list")) | ||
606 | { | ||
607 | Output.Add("The following parameters can be changed or viewed:"); | ||
608 | foreach (KeyValuePair<string, string> kvp in GetParamList()) | ||
609 | { | ||
610 | Output.Add(String.Format("{0} - {1}",kvp.Key, kvp.Value)); | ||
611 | } | ||
612 | return Output; | ||
613 | } | ||
614 | |||
615 | if (args.Length == 2) | ||
616 | { | ||
617 | try | ||
618 | { | ||
619 | double value = GetSunParameter(args[1]); | ||
620 | Output.Add(String.Format("Parameter {0} is {1}.", args[1], value.ToString())); | ||
621 | } | ||
622 | catch (Exception) | ||
623 | { | ||
624 | Output.Add(String.Format("Unknown parameter {0}.", args[1])); | ||
625 | } | ||
626 | |||
627 | } | ||
628 | else if (args.Length == 3) | ||
629 | { | ||
630 | float value = 0.0f; | ||
631 | if (!float.TryParse(args[2], out value)) | ||
632 | { | ||
633 | Output.Add(String.Format("The parameter value {0} is not a valid number.", args[2])); | ||
634 | } | ||
635 | |||
636 | switch (args[1].ToLower()) | ||
637 | { | ||
638 | case "year_length": | ||
639 | m_YearLengthDays = (int)value; | ||
640 | break; | ||
641 | |||
642 | case "day_length": | ||
643 | m_DayLengthHours = value; | ||
644 | break; | ||
645 | |||
646 | case "day_night_offset": | ||
647 | m_HorizonShift = value; | ||
648 | break; | ||
649 | |||
650 | case "day_time_sun_hour_scale": | ||
651 | m_DayTimeSunHourScale = value; | ||
652 | break; | ||
653 | |||
654 | case "update_interval": | ||
655 | m_UpdateInterval = (int)value; | ||
656 | break; | ||
657 | |||
658 | default: | ||
659 | Output.Add(String.Format("Unknown parameter {0}.", args[1])); | ||
660 | return Output; | ||
661 | } | ||
662 | |||
663 | Output.Add(String.Format("Parameter {0} set to {1}.", args[1], value.ToString())); | ||
664 | |||
665 | // Generate shared values | ||
666 | GenSunPos(); | ||
667 | |||
668 | // When sun settings are updated, we should update all clients with new settings. | ||
669 | SunUpdateToAllClients(); | ||
670 | |||
671 | } | ||
672 | |||
673 | return Output; | ||
674 | } | ||
477 | } | 675 | } |
478 | } | 676 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f4be267..8776524 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -807,6 +807,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
807 | //World.Permissions.GenericEstatePermission( | 807 | //World.Permissions.GenericEstatePermission( |
808 | if (World.Permissions.IsGod(m_host.OwnerID)) | 808 | if (World.Permissions.IsGod(m_host.OwnerID)) |
809 | { | 809 | { |
810 | while (sunHour > 24.0) | ||
811 | sunHour -= 24.0; | ||
812 | |||
813 | while (sunHour < 0) | ||
814 | sunHour += 24.0; | ||
815 | |||
816 | |||
810 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; | 817 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; |
811 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 | 818 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 |
812 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; | 819 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; |
@@ -816,6 +823,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
816 | } | 823 | } |
817 | } | 824 | } |
818 | 825 | ||
826 | /// <summary> | ||
827 | /// Changes the Estate Sun Settings, then Triggers a Sun Update | ||
828 | /// </summary> | ||
829 | /// <param name="sunFixed">True to keep the sun stationary, false to use global time</param> | ||
830 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> | ||
831 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) | ||
832 | { | ||
833 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); | ||
834 | |||
835 | m_host.AddScriptLPS(1); | ||
836 | //Check to make sure that the script's owner is the estate manager/master | ||
837 | //World.Permissions.GenericEstatePermission( | ||
838 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
839 | { | ||
840 | while (sunHour > 24.0) | ||
841 | sunHour -= 24.0; | ||
842 | |||
843 | while (sunHour < 0) | ||
844 | sunHour += 24.0; | ||
845 | |||
846 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; | ||
847 | World.RegionInfo.EstateSettings.SunPosition = sunHour; | ||
848 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
849 | World.RegionInfo.EstateSettings.Save(); | ||
850 | |||
851 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | ||
852 | } | ||
853 | } | ||
854 | |||
855 | /// <summary> | ||
856 | /// Return the current Sun Hour 0...24, with 0 being roughly sun-rise | ||
857 | /// </summary> | ||
858 | /// <returns></returns> | ||
859 | public double osGetCurrentSunHour() | ||
860 | { | ||
861 | CheckThreatLevel(ThreatLevel.None, "osGetCurrentSunHour"); | ||
862 | |||
863 | m_host.AddScriptLPS(1); | ||
864 | |||
865 | // Must adjust for the fact that Region Sun Settings are still LL offset | ||
866 | double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6; | ||
867 | |||
868 | // See if the sun module has registered itself, if so it's authoritative | ||
869 | ISunModule module = World.RequestModuleInterface<ISunModule>(); | ||
870 | if (module != null) | ||
871 | { | ||
872 | sunHour = module.GetCurrentSunHour(); | ||
873 | } | ||
874 | |||
875 | return sunHour; | ||
876 | } | ||
877 | |||
878 | public double osSunGetParam(string param) | ||
879 | { | ||
880 | CheckThreatLevel(ThreatLevel.None, "osSunGetParam"); | ||
881 | m_host.AddScriptLPS(1); | ||
882 | |||
883 | double value = 0.0; | ||
884 | |||
885 | ISunModule module = World.RequestModuleInterface<ISunModule>(); | ||
886 | if (module != null) | ||
887 | { | ||
888 | value = module.GetSunParameter(param); | ||
889 | } | ||
890 | |||
891 | return value; | ||
892 | } | ||
893 | |||
894 | public void osSunSetParam(string param, double value) | ||
895 | { | ||
896 | CheckThreatLevel(ThreatLevel.None, "osSunSetParam"); | ||
897 | m_host.AddScriptLPS(1); | ||
898 | |||
899 | ISunModule module = World.RequestModuleInterface<ISunModule>(); | ||
900 | if (module != null) | ||
901 | { | ||
902 | module.SetSunParameter(param, value); | ||
903 | } | ||
904 | |||
905 | } | ||
906 | |||
819 | 907 | ||
820 | 908 | ||
821 | 909 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 3656f92..7a7b922 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -98,6 +98,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
98 | 98 | ||
99 | void osSetRegionWaterHeight(double height); | 99 | void osSetRegionWaterHeight(double height); |
100 | void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour); | 100 | void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour); |
101 | void osSetEstateSunSettings(bool sunFixed, double sunHour); | ||
102 | double osGetCurrentSunHour(); | ||
103 | double osSunGetParam(string param); | ||
104 | void osSunSetParam(string param, double value); | ||
105 | |||
101 | 106 | ||
102 | string osGetScriptEngineName(); | 107 | string osGetScriptEngineName(); |
103 | string osGetSimulatorVersion(); | 108 | string osGetSimulatorVersion(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index d316ac9..a50b6f2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -67,6 +67,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
67 | m_OSSL_Functions.osSetRegionSunSettings(useEstateSun, sunFixed, sunHour); | 67 | m_OSSL_Functions.osSetRegionSunSettings(useEstateSun, sunFixed, sunHour); |
68 | } | 68 | } |
69 | 69 | ||
70 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) | ||
71 | { | ||
72 | m_OSSL_Functions.osSetEstateSunSettings(sunFixed, sunHour); | ||
73 | } | ||
74 | |||
75 | public double osGetCurrentSunHour() | ||
76 | { | ||
77 | return m_OSSL_Functions.osGetCurrentSunHour(); | ||
78 | } | ||
79 | |||
80 | public double osSunGetParam(string param) | ||
81 | { | ||
82 | return m_OSSL_Functions.osSunGetParam(param); | ||
83 | } | ||
84 | |||
85 | public void osSunSetParam(string param, double value) | ||
86 | { | ||
87 | m_OSSL_Functions.osSunSetParam(param, value); | ||
88 | } | ||
89 | |||
90 | |||
70 | public double osList2Double(LSL_Types.list src, int index) | 91 | public double osList2Double(LSL_Types.list src, int index) |
71 | { | 92 | { |
72 | return m_OSSL_Functions.osList2Double(src, index); | 93 | return m_OSSL_Functions.osList2Double(src, index); |