aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/RegionSettings.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/RegionSettings.cs')
-rw-r--r--OpenSim/Framework/RegionSettings.cs116
1 files changed, 45 insertions, 71 deletions
diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs
index 9b5bbf2..0a59f43 100644
--- a/OpenSim/Framework/RegionSettings.cs
+++ b/OpenSim/Framework/RegionSettings.cs
@@ -32,6 +32,47 @@ using OpenMetaverse;
32 32
33namespace OpenSim.Framework 33namespace OpenSim.Framework
34{ 34{
35 public struct SpawnPoint
36 {
37 public float Yaw;
38 public float Pitch;
39 public float Distance;
40
41 public void SetLocation(Vector3 pos, Quaternion rot, Vector3 point)
42 {
43 // The point is an absolute position, so we need the relative
44 // location to the spawn point
45 Vector3 offset = pos - point;
46 Distance = Vector3.Mag(offset);
47
48 // Next we need to rotate this vector into the spawn point's
49 // coordinate system
50 offset = offset * rot;
51
52 Vector3 dir = Vector3.Normalize(offset);
53
54 // Get the bearing (yaw)
55 Yaw = (float)Math.Atan2(dir.Y, dir.X);
56
57 // Get the elevation (pitch)
58 Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y));
59 }
60
61 public Vector3 GetLocation(Vector3 pos, Quaternion rot)
62 {
63 Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw);
64 Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0);
65
66 Vector3 dir = new Vector3(1, 0, 0) * p * y;
67 Vector3 offset = dir * (float)Distance;
68
69 rot.W = -rot.W;
70 offset *= rot;
71
72 return pos + offset;
73 }
74 }
75
35 public class RegionSettings 76 public class RegionSettings
36 { 77 {
37 public delegate void SaveDelegate(RegionSettings rs); 78 public delegate void SaveDelegate(RegionSettings rs);
@@ -398,28 +439,13 @@ namespace OpenSim.Framework
398 set { m_LoadedCreationID = value; } 439 set { m_LoadedCreationID = value; }
399 } 440 }
400 441
401 // Telehub support
402 private bool m_TelehubEnabled = false;
403 public bool HasTelehub
404 {
405 get { return m_TelehubEnabled; }
406 set { m_TelehubEnabled = value; }
407 }
408
409 // Connected Telehub object 442 // Connected Telehub object
410 private UUID m_TelehubObject; 443 private UUID m_TelehubObject;
411 public UUID TelehubObject 444 public UUID TelehubObject
412 { 445 {
413 get 446 get
414 { 447 {
415 if (HasTelehub) 448 return m_TelehubObject;
416 {
417 return m_TelehubObject;
418 }
419 else
420 {
421 return UUID.Zero;
422 }
423 } 449 }
424 set 450 set
425 { 451 {
@@ -427,66 +453,14 @@ namespace OpenSim.Framework
427 } 453 }
428 } 454 }
429 455
430 // Connected Telehub name
431 private string m_TelehubName;
432 public string TelehubName
433 {
434 get
435 {
436 if (HasTelehub)
437 {
438 return m_TelehubName;
439 }
440 else
441 {
442 return String.Empty;
443 }
444 }
445 set
446 {
447 m_TelehubName = value;
448 }
449 }
450
451 // Connected Telehub position
452 private Vector3 m_TelehubPos;
453 public Vector3 TelehubPos
454 {
455 get
456 {
457 if (HasTelehub)
458 {
459 return m_TelehubPos;
460 }
461 else
462 {
463 return Vector3.Zero;
464 }
465 }
466 set
467 {
468 m_TelehubPos = value;
469 }
470 }
471
472 // Connected Telehub rotation
473 private Quaternion m_TelehubRot;
474 public Quaternion TelehubRot
475 {
476 get
477 { return m_TelehubRot; }
478 set
479 { m_TelehubRot = value; }
480 }
481
482 // Our Connected Telehub's SpawnPoints 456 // Our Connected Telehub's SpawnPoints
483 public List<Vector3> l_SpawnPoints = new List<Vector3>(); 457 public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>();
484 458
485 // Add a SpawnPoint 459 // Add a SpawnPoint
486 // ** These are not region coordinates ** 460 // ** These are not region coordinates **
487 // They are relative to the Telehub coordinates 461 // They are relative to the Telehub coordinates
488 // 462 //
489 public void AddSpawnPoint(Vector3 point) 463 public void AddSpawnPoint(SpawnPoint point)
490 { 464 {
491 l_SpawnPoints.Add(point); 465 l_SpawnPoints.Add(point);
492 } 466 }
@@ -498,7 +472,7 @@ namespace OpenSim.Framework
498 } 472 }
499 473
500 // Return the List of SpawnPoints 474 // Return the List of SpawnPoints
501 public List<Vector3> SpawnPoints() 475 public List<SpawnPoint> SpawnPoints()
502 { 476 {
503 return l_SpawnPoints; 477 return l_SpawnPoints;
504 478