diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | 75 |
1 files changed, 53 insertions, 22 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs index 75cf786..c6cb392 100644 --- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs | |||
@@ -52,15 +52,21 @@ namespace OpenSim.Region.Environment.Modules | |||
52 | private bool ready = false; | 52 | private bool ready = false; |
53 | 53 | ||
54 | // Configurable values | 54 | // Configurable values |
55 | private string m_mode = "SL"; | ||
55 | private int m_frame_mod = 0; | 56 | private int m_frame_mod = 0; |
56 | private double m_day_length = 0; | 57 | private double m_day_length = 0; |
57 | private int m_year_length = 0; | 58 | private int m_year_length = 0; |
58 | private double m_day_night = 0; | 59 | private double m_day_night = 0; |
60 | private double m_longitude = 0; | ||
61 | private double m_latitude = 0; | ||
59 | // Configurable defaults Defaults close to SL | 62 | // Configurable defaults Defaults close to SL |
63 | private string d_mode = "SL"; | ||
60 | private int d_frame_mod = 100; // Every 10 seconds (actually less) | 64 | private int d_frame_mod = 100; // Every 10 seconds (actually less) |
61 | private double d_day_length = 4; // A VW day is 4 RW hours long | 65 | private double d_day_length = 4; // A VW day is 4 RW hours long |
62 | private int d_year_length = 60; // There are 60 VW days in a VW year | 66 | private int d_year_length = 60; // There are 60 VW days in a VW year |
63 | private double d_day_night = 0.45; // axis offset: ratio of light-to-dark, approx 1:3 | 67 | private double d_day_night = 0.45; // axis offset: ratio of light-to-dark, approx 1:3 |
68 | private double d_longitude = -73.53; | ||
69 | private double d_latitude = 41.29; | ||
64 | 70 | ||
65 | // Frame counter | 71 | // Frame counter |
66 | private uint m_frame = 0; | 72 | private uint m_frame = 0; |
@@ -114,6 +120,12 @@ namespace OpenSim.Region.Environment.Modules | |||
114 | // Just in case they don't have the stanzas | 120 | // Just in case they don't have the stanzas |
115 | try | 121 | try |
116 | { | 122 | { |
123 | // Mode: determines how the sun is handled | ||
124 | m_mode = config.Configs["Sun"].GetString("mode", d_mode); | ||
125 | // Mode: determines how the sun is handled | ||
126 | m_latitude = config.Configs["Sun"].GetDouble("latitude", d_latitude); | ||
127 | // Mode: determines how the sun is handled | ||
128 | m_longitude = config.Configs["Sun"].GetDouble("longitude", d_longitude); | ||
117 | // Day length in decimal hours | 129 | // Day length in decimal hours |
118 | m_year_length = config.Configs["Sun"].GetInt("year_length", d_year_length); | 130 | m_year_length = config.Configs["Sun"].GetInt("year_length", d_year_length); |
119 | // Day length in decimal hours | 131 | // Day length in decimal hours |
@@ -126,43 +138,58 @@ namespace OpenSim.Region.Environment.Modules | |||
126 | catch (Exception e) | 138 | catch (Exception e) |
127 | { | 139 | { |
128 | m_log.Debug("[SUN] Configuration access failed, using defaults. Reason: "+e.Message); | 140 | m_log.Debug("[SUN] Configuration access failed, using defaults. Reason: "+e.Message); |
141 | m_mode = d_mode; | ||
129 | m_year_length = d_year_length; | 142 | m_year_length = d_year_length; |
130 | m_day_length = d_day_length; | 143 | m_day_length = d_day_length; |
131 | m_day_night = d_day_night; | 144 | m_day_night = d_day_night; |
132 | m_frame_mod = d_frame_mod; | 145 | m_frame_mod = d_frame_mod; |
146 | m_latitude = d_latitude; | ||
147 | m_longitude = d_longitude; | ||
133 | } | 148 | } |
134 | 149 | ||
135 | // Time taken to complete a cycle (day and season) | 150 | switch(m_mode) |
151 | { | ||
152 | |||
153 | case "T1" : | ||
154 | |||
155 | default : | ||
136 | 156 | ||
137 | SecondsPerSunCycle = (uint) (m_day_length * 60 * 60); | 157 | case "SL" : |
138 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_year_length); | 158 | // Time taken to complete a cycle (day and season) |
139 | 159 | ||
140 | // Ration of real-to-virtual time | 160 | SecondsPerSunCycle = (uint) (m_day_length * 60 * 60); |
161 | SecondsPerYear = (uint) (SecondsPerSunCycle*m_year_length); | ||
141 | 162 | ||
142 | VWTimeRatio = 24/m_day_length; | 163 | // Ration of real-to-virtual time |
143 | 164 | ||
144 | // Speed of rotation needed to complete a cycle in the | 165 | VWTimeRatio = 24/m_day_length; |
145 | // designated period (day and season) | ||
146 | 166 | ||
147 | SunSpeed = SunCycle/SecondsPerSunCycle; | 167 | // Speed of rotation needed to complete a cycle in the |
148 | SeasonSpeed = SeasonalCycle/SecondsPerYear; | 168 | // designated period (day and season) |
149 | 169 | ||
150 | // Horizon translation | 170 | SunSpeed = SunCycle/SecondsPerSunCycle; |
171 | SeasonSpeed = SeasonalCycle/SecondsPerYear; | ||
151 | 172 | ||
152 | HorizonShift = m_day_night; // Z axis translation | 173 | // Horizon translation |
153 | HoursToRadians = (SunCycle/24)*VWTimeRatio; | ||
154 | 174 | ||
155 | // Insert our event handling hooks | 175 | HorizonShift = m_day_night; // Z axis translation |
176 | HoursToRadians = (SunCycle/24)*VWTimeRatio; | ||
156 | 177 | ||
157 | scene.EventManager.OnFrame += SunUpdate; | 178 | // Insert our event handling hooks |
158 | scene.EventManager.OnNewClient += SunToClient; | ||
159 | 179 | ||
160 | ready = true; | 180 | scene.EventManager.OnFrame += SunUpdate; |
181 | scene.EventManager.OnNewClient += SunToClient; | ||
161 | 182 | ||
162 | m_log.Debug("[SUN] Initialization completed. Day is "+SecondsPerSunCycle+" seconds, and year is "+m_year_length+" days"); | 183 | ready = true; |
163 | m_log.Debug("[SUN] Axis offset is "+m_day_night); | ||
164 | m_log.Debug("[SUN] Positional data updated every "+m_frame_mod+" frames"); | ||
165 | 184 | ||
185 | m_log.Debug("[SUN] Mode is "+m_mode); | ||
186 | m_log.Debug("[SUN] Initialization completed. Day is "+SecondsPerSunCycle+" seconds, and year is "+m_year_length+" days"); | ||
187 | m_log.Debug("[SUN] Axis offset is "+m_day_night); | ||
188 | m_log.Debug("[SUN] Positional data updated every "+m_frame_mod+" frames"); | ||
189 | |||
190 | break; | ||
191 | |||
192 | } | ||
166 | } | 193 | } |
167 | 194 | ||
168 | public void PostInitialise() | 195 | public void PostInitialise() |
@@ -189,10 +216,14 @@ namespace OpenSim.Region.Environment.Modules | |||
189 | 216 | ||
190 | public void SunToClient(IClientAPI client) | 217 | public void SunToClient(IClientAPI client) |
191 | { | 218 | { |
192 | if(ready) | 219 | if(m_mode != "T1") |
193 | { | 220 | { |
194 | GenSunPos(); // Generate shared values once | 221 | if(ready) |
195 | client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); | 222 | { |
223 | GenSunPos(); // Generate shared values once | ||
224 | client.SendSunPos(Position, Velocity, CurrentTime, SecondsPerSunCycle, SecondsPerYear, OrbitalPosition); | ||
225 | m_log.Debug("[SUN] Initial update for new client"); | ||
226 | } | ||
196 | } | 227 | } |
197 | } | 228 | } |
198 | 229 | ||