aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/RegionSettings.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/RegionSettings.cs523
1 files changed, 523 insertions, 0 deletions
diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs
new file mode 100644
index 0000000..a895c40
--- /dev/null
+++ b/OpenSim/Framework/RegionSettings.cs
@@ -0,0 +1,523 @@
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
28using System;
29using System.Collections.Generic;
30using System.IO;
31using OpenMetaverse;
32using System.Runtime.Serialization;
33
34namespace OpenSim.Framework
35{
36 public struct SpawnPoint
37 {
38 public float Yaw;
39 public float Pitch;
40 public float Distance;
41
42 public void SetLocation(Vector3 pos, Quaternion rot, Vector3 point)
43 {
44 // The point is an absolute position, so we need the relative
45 // location to the spawn point
46 Vector3 offset = point - pos;
47 Distance = Vector3.Mag(offset);
48
49 // Next we need to rotate this vector into the spawn point's
50 // coordinate system
51 rot.W = -rot.W;
52 offset = offset * rot;
53
54 Vector3 dir = Vector3.Normalize(offset);
55
56 // Get the bearing (yaw)
57 Yaw = (float)Math.Atan2(dir.Y, dir.X);
58
59 // Get the elevation (pitch)
60 Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y));
61 }
62
63 public Vector3 GetLocation(Vector3 pos, Quaternion rot)
64 {
65 Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw);
66 Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0);
67
68 Vector3 dir = new Vector3(1, 0, 0) * p * y;
69 Vector3 offset = dir * (float)Distance;
70
71 offset *= rot;
72
73 return pos + offset;
74 }
75
76 /// <summary>
77 /// Returns a string representation of this SpawnPoint.
78 /// </summary>
79 /// <returns></returns>
80 public override string ToString()
81 {
82 return string.Format("{0},{1},{2}", Yaw, Pitch, Distance);
83 }
84
85 /// <summary>
86 /// Generate a SpawnPoint from a string
87 /// </summary>
88 /// <param name="str"></param>
89 public static SpawnPoint Parse(string str)
90 {
91 string[] parts = str.Split(',');
92 if (parts.Length != 3)
93 throw new ArgumentException("Invalid string: " + str);
94
95 SpawnPoint sp = new SpawnPoint();
96 sp.Yaw = float.Parse(parts[0]);
97 sp.Pitch = float.Parse(parts[1]);
98 sp.Distance = float.Parse(parts[2]);
99 return sp;
100 }
101 }
102
103 public class RegionSettings
104 {
105 public delegate void SaveDelegate(RegionSettings rs);
106
107 public event SaveDelegate OnSave;
108
109 /// <value>
110 /// These appear to be terrain textures that are shipped with the client.
111 /// </value>
112 public static readonly UUID DEFAULT_TERRAIN_TEXTURE_1 = new UUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
113 public static readonly UUID DEFAULT_TERRAIN_TEXTURE_2 = new UUID("abb783e6-3e93-26c0-248a-247666855da3");
114 public static readonly UUID DEFAULT_TERRAIN_TEXTURE_3 = new UUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
115 public static readonly UUID DEFAULT_TERRAIN_TEXTURE_4 = new UUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
116
117 public void Save()
118 {
119 if (OnSave != null)
120 OnSave(this);
121 }
122
123 private UUID m_RegionUUID = UUID.Zero;
124
125 public UUID RegionUUID
126 {
127 get { return m_RegionUUID; }
128 set { m_RegionUUID = value; }
129 }
130
131 private bool m_BlockTerraform = false;
132
133 public bool BlockTerraform
134 {
135 get { return m_BlockTerraform; }
136 set { m_BlockTerraform = value; }
137 }
138
139 private bool m_BlockFly = false;
140
141 public bool BlockFly
142 {
143 get { return m_BlockFly; }
144 set { m_BlockFly = value; }
145 }
146
147 private bool m_AllowDamage = false;
148
149 public bool AllowDamage
150 {
151 get { return m_AllowDamage; }
152 set { m_AllowDamage = value; }
153 }
154
155 private bool m_RestrictPushing = false;
156
157 public bool RestrictPushing
158 {
159 get { return m_RestrictPushing; }
160 set { m_RestrictPushing = value; }
161 }
162
163 private bool m_AllowLandResell = true;
164
165 public bool AllowLandResell
166 {
167 get { return m_AllowLandResell; }
168 set { m_AllowLandResell = value; }
169 }
170
171 private bool m_AllowLandJoinDivide = true;
172
173 public bool AllowLandJoinDivide
174 {
175 get { return m_AllowLandJoinDivide; }
176 set { m_AllowLandJoinDivide = value; }
177 }
178
179 private bool m_BlockShowInSearch = false;
180
181 public bool BlockShowInSearch
182 {
183 get { return m_BlockShowInSearch; }
184 set { m_BlockShowInSearch = value; }
185 }
186
187 private int m_AgentLimit = 40;
188
189 public int AgentLimit
190 {
191 get { return m_AgentLimit; }
192 set { m_AgentLimit = value; }
193 }
194
195 private double m_ObjectBonus = 1.0;
196
197 public double ObjectBonus
198 {
199 get { return m_ObjectBonus; }
200 set { m_ObjectBonus = value; }
201 }
202
203 private int m_Maturity = 0;
204
205 public int Maturity
206 {
207 get { return m_Maturity; }
208 set { m_Maturity = value; }
209 }
210
211 private bool m_DisableScripts = false;
212
213 public bool DisableScripts
214 {
215 get { return m_DisableScripts; }
216 set { m_DisableScripts = value; }
217 }
218
219 private bool m_DisableCollisions = false;
220
221 public bool DisableCollisions
222 {
223 get { return m_DisableCollisions; }
224 set { m_DisableCollisions = value; }
225 }
226
227 private bool m_DisablePhysics = false;
228
229 public bool DisablePhysics
230 {
231 get { return m_DisablePhysics; }
232 set { m_DisablePhysics = value; }
233 }
234
235 private UUID m_TerrainTexture1 = UUID.Zero;
236
237 public UUID TerrainTexture1
238 {
239 get { return m_TerrainTexture1; }
240 set
241 {
242 if (value == UUID.Zero)
243 m_TerrainTexture1 = DEFAULT_TERRAIN_TEXTURE_1;
244 else
245 m_TerrainTexture1 = value;
246 }
247 }
248
249 private UUID m_TerrainTexture2 = UUID.Zero;
250
251 public UUID TerrainTexture2
252 {
253 get { return m_TerrainTexture2; }
254 set
255 {
256 if (value == UUID.Zero)
257 m_TerrainTexture2 = DEFAULT_TERRAIN_TEXTURE_2;
258 else
259 m_TerrainTexture2 = value;
260 }
261 }
262
263 private UUID m_TerrainTexture3 = UUID.Zero;
264
265 public UUID TerrainTexture3
266 {
267 get { return m_TerrainTexture3; }
268 set
269 {
270 if (value == UUID.Zero)
271 m_TerrainTexture3 = DEFAULT_TERRAIN_TEXTURE_3;
272 else
273 m_TerrainTexture3 = value;
274 }
275 }
276
277 private UUID m_TerrainTexture4 = UUID.Zero;
278
279 public UUID TerrainTexture4
280 {
281 get { return m_TerrainTexture4; }
282 set
283 {
284 if (value == UUID.Zero)
285 m_TerrainTexture4 = DEFAULT_TERRAIN_TEXTURE_4;
286 else
287 m_TerrainTexture4 = value;
288 }
289 }
290
291 private double m_Elevation1NW = 10;
292
293 public double Elevation1NW
294 {
295 get { return m_Elevation1NW; }
296 set { m_Elevation1NW = value; }
297 }
298
299 private double m_Elevation2NW = 60;
300
301 public double Elevation2NW
302 {
303 get { return m_Elevation2NW; }
304 set { m_Elevation2NW = value; }
305 }
306
307 private double m_Elevation1NE = 10;
308
309 public double Elevation1NE
310 {
311 get { return m_Elevation1NE; }
312 set { m_Elevation1NE = value; }
313 }
314
315 private double m_Elevation2NE = 60;
316
317 public double Elevation2NE
318 {
319 get { return m_Elevation2NE; }
320 set { m_Elevation2NE = value; }
321 }
322
323 private double m_Elevation1SE = 10;
324
325 public double Elevation1SE
326 {
327 get { return m_Elevation1SE; }
328 set { m_Elevation1SE = value; }
329 }
330
331 private double m_Elevation2SE = 60;
332
333 public double Elevation2SE
334 {
335 get { return m_Elevation2SE; }
336 set { m_Elevation2SE = value; }
337 }
338
339 private double m_Elevation1SW = 10;
340
341 public double Elevation1SW
342 {
343 get { return m_Elevation1SW; }
344 set { m_Elevation1SW = value; }
345 }
346
347 private double m_Elevation2SW = 60;
348
349 public double Elevation2SW
350 {
351 get { return m_Elevation2SW; }
352 set { m_Elevation2SW = value; }
353 }
354
355 private double m_WaterHeight = 20;
356
357 public double WaterHeight
358 {
359 get { return m_WaterHeight; }
360 set { m_WaterHeight = value; }
361 }
362
363 private double m_TerrainRaiseLimit = 100;
364
365 public double TerrainRaiseLimit
366 {
367 get { return m_TerrainRaiseLimit; }
368 set { m_TerrainRaiseLimit = value; }
369 }
370
371 private double m_TerrainLowerLimit = -100;
372
373 public double TerrainLowerLimit
374 {
375 get { return m_TerrainLowerLimit; }
376 set { m_TerrainLowerLimit = value; }
377 }
378
379 private bool m_UseEstateSun = true;
380
381 public bool UseEstateSun
382 {
383 get { return m_UseEstateSun; }
384 set { m_UseEstateSun = value; }
385 }
386
387 private bool m_Sandbox = false;
388
389 public bool Sandbox
390 {
391 get { return m_Sandbox; }
392 set { m_Sandbox = value; }
393 }
394
395 private Vector3 m_SunVector;
396
397 public Vector3 SunVector
398 {
399 get { return m_SunVector; }
400 set { m_SunVector = value; }
401 }
402
403 private UUID m_ParcelImageID;
404
405 public UUID ParcelImageID
406 {
407 get { return m_ParcelImageID; }
408 set { m_ParcelImageID = value; }
409 }
410
411 private UUID m_TerrainImageID;
412
413 public UUID TerrainImageID
414 {
415 get { return m_TerrainImageID; }
416 set { m_TerrainImageID = value; }
417 }
418
419 private bool m_FixedSun = false;
420
421 public bool FixedSun
422 {
423 get { return m_FixedSun; }
424 set { m_FixedSun = value; }
425 }
426
427 private double m_SunPosition = 0.0;
428
429 public double SunPosition
430 {
431 get { return m_SunPosition; }
432 set { m_SunPosition = value; }
433 }
434
435 private UUID m_Covenant = UUID.Zero;
436
437 public UUID Covenant
438 {
439 get { return m_Covenant; }
440 set { m_Covenant = value; }
441 }
442
443 private int m_CovenantChanged = 0;
444
445 public int CovenantChangedDateTime
446 {
447 get { return m_CovenantChanged; }
448 set { m_CovenantChanged = value; }
449 }
450
451 private int m_LoadedCreationDateTime;
452 public int LoadedCreationDateTime
453 {
454 get { return m_LoadedCreationDateTime; }
455 set { m_LoadedCreationDateTime = value; }
456 }
457
458 public String LoadedCreationDate
459 {
460 get
461 {
462 TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime);
463 DateTime stamp = new DateTime(1970, 1, 1) + ts;
464 return stamp.ToLongDateString();
465 }
466 }
467
468 public String LoadedCreationTime
469 {
470 get
471 {
472 TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime);
473 DateTime stamp = new DateTime(1970, 1, 1) + ts;
474 return stamp.ToLongTimeString();
475 }
476 }
477
478 private String m_LoadedCreationID;
479 public String LoadedCreationID
480 {
481 get { return m_LoadedCreationID; }
482 set { m_LoadedCreationID = value; }
483 }
484
485 /// <summary>
486 /// Connected Telehub object
487 /// </summary>
488 public UUID TelehubObject { get; set; }
489
490 /// <summary>
491 /// Our connected Telehub's SpawnPoints
492 /// </summary>
493 public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>();
494
495 // Add a SpawnPoint
496 // ** These are not region coordinates **
497 // They are relative to the Telehub coordinates
498 //
499 public void AddSpawnPoint(SpawnPoint point)
500 {
501 l_SpawnPoints.Add(point);
502 }
503
504 // Remove a SpawnPoint
505 public void RemoveSpawnPoint(int point_index)
506 {
507 l_SpawnPoints.RemoveAt(point_index);
508 }
509
510 // Return the List of SpawnPoints
511 public List<SpawnPoint> SpawnPoints()
512 {
513 return l_SpawnPoints;
514
515 }
516
517 // Clear the SpawnPoints List of all entries
518 public void ClearSpawnPoints()
519 {
520 l_SpawnPoints.Clear();
521 }
522 }
523} \ No newline at end of file