diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Sun')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs index a465a60..a12118e 100644 --- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | |||
@@ -39,15 +39,17 @@ namespace OpenSim.Region.Environment.Modules | |||
39 | { | 39 | { |
40 | //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 40 | //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
41 | 41 | ||
42 | private const double m_real_day = 24.0; | ||
43 | private const int m_default_frame = 100; | 42 | private const int m_default_frame = 100; |
44 | private int m_frame_mod; | 43 | private const double m_real_day = 24.0; |
45 | private double m_day_length; | 44 | private double m_day_length; |
46 | private int m_dilation; | 45 | private int m_dilation; |
47 | private int m_frame; | 46 | private int m_frame; |
48 | private long m_start; | 47 | private int m_frame_mod; |
49 | 48 | ||
50 | private Scene m_scene; | 49 | private Scene m_scene; |
50 | private long m_start; | ||
51 | |||
52 | #region IRegionModule Members | ||
51 | 53 | ||
52 | public void Initialise(Scene scene, IConfigSource config) | 54 | public void Initialise(Scene scene, IConfigSource config) |
53 | { | 55 | { |
@@ -66,7 +68,7 @@ namespace OpenSim.Region.Environment.Modules | |||
66 | m_frame_mod = m_default_frame; | 68 | m_frame_mod = m_default_frame; |
67 | } | 69 | } |
68 | 70 | ||
69 | m_dilation = (int) (m_real_day/m_day_length); | 71 | m_dilation = (int) (m_real_day / m_day_length); |
70 | m_scene = scene; | 72 | m_scene = scene; |
71 | scene.EventManager.OnFrame += SunUpdate; | 73 | scene.EventManager.OnFrame += SunUpdate; |
72 | scene.EventManager.OnNewClient += SunToClient; | 74 | scene.EventManager.OnNewClient += SunToClient; |
@@ -90,6 +92,8 @@ namespace OpenSim.Region.Environment.Modules | |||
90 | get { return false; } | 92 | get { return false; } |
91 | } | 93 | } |
92 | 94 | ||
95 | #endregion | ||
96 | |||
93 | public void SunToClient(IClientAPI client) | 97 | public void SunToClient(IClientAPI client) |
94 | { | 98 | { |
95 | client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); | 99 | client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); |
@@ -121,15 +125,15 @@ namespace OpenSim.Region.Environment.Modules | |||
121 | // ticks don't get out of hand | 125 | // ticks don't get out of hand |
122 | private double HourOfTheDay() | 126 | private double HourOfTheDay() |
123 | { | 127 | { |
124 | long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation; | 128 | long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; |
125 | DateTime dt = new DateTime(m_start + m_addticks); | 129 | DateTime dt = new DateTime(m_start + m_addticks); |
126 | return (double) dt.Hour + ((double) dt.Minute/60.0); | 130 | return (double) dt.Hour + ((double) dt.Minute / 60.0); |
127 | } | 131 | } |
128 | 132 | ||
129 | private LLVector3 SunPos(double hour) | 133 | private LLVector3 SunPos(double hour) |
130 | { | 134 | { |
131 | // now we have our radian position | 135 | // now we have our radian position |
132 | double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0); | 136 | double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0); |
133 | double z = Math.Sin(rad); | 137 | double z = Math.Sin(rad); |
134 | double x = Math.Cos(rad); | 138 | double x = Math.Cos(rad); |
135 | return new LLVector3((float) x, 0f, (float) z); | 139 | return new LLVector3((float) x, 0f, (float) z); |
@@ -192,4 +196,4 @@ namespace OpenSim.Region.Environment.Modules | |||
192 | // // OutPacket(viewertime); | 196 | // // OutPacket(viewertime); |
193 | // } | 197 | // } |
194 | } | 198 | } |
195 | } | 199 | } \ No newline at end of file |