diff options
author | Justin Clark-Casey (justincc) | 2012-01-24 20:36:16 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-01-24 20:36:16 +0000 |
commit | a704d444f2f1a4887598cd9eb2f59c0b4c595f2b (patch) | |
tree | 066a47464322b9e73687f60d8308e34efbb45568 /OpenSim/Framework/RegionSettings.cs | |
parent | Restrict accessible of ODECharacter Shell and Body. Add method doc and some ... (diff) | |
parent | Teleport routing, part 1 (diff) | |
download | opensim-SC_OLD-a704d444f2f1a4887598cd9eb2f59c0b4c595f2b.zip opensim-SC_OLD-a704d444f2f1a4887598cd9eb2f59c0b4c595f2b.tar.gz opensim-SC_OLD-a704d444f2f1a4887598cd9eb2f59c0b4c595f2b.tar.bz2 opensim-SC_OLD-a704d444f2f1a4887598cd9eb2f59c0b4c595f2b.tar.xz |
Merge branch 'master' of ssh://opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Framework/RegionSettings.cs')
-rw-r--r-- | OpenSim/Framework/RegionSettings.cs | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/OpenSim/Framework/RegionSettings.cs b/OpenSim/Framework/RegionSettings.cs index 673cf20..e115432 100644 --- a/OpenSim/Framework/RegionSettings.cs +++ b/OpenSim/Framework/RegionSettings.cs | |||
@@ -26,11 +26,53 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.IO; | 30 | using System.IO; |
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
31 | 32 | ||
32 | namespace OpenSim.Framework | 33 | namespace OpenSim.Framework |
33 | { | 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 = point - pos; | ||
46 | Distance = Vector3.Mag(offset); | ||
47 | |||
48 | // Next we need to rotate this vector into the spawn point's | ||
49 | // coordinate system | ||
50 | rot.W = -rot.W; | ||
51 | offset = offset * rot; | ||
52 | |||
53 | Vector3 dir = Vector3.Normalize(offset); | ||
54 | |||
55 | // Get the bearing (yaw) | ||
56 | Yaw = (float)Math.Atan2(dir.Y, dir.X); | ||
57 | |||
58 | // Get the elevation (pitch) | ||
59 | Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y)); | ||
60 | } | ||
61 | |||
62 | public Vector3 GetLocation(Vector3 pos, Quaternion rot) | ||
63 | { | ||
64 | Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw); | ||
65 | Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0); | ||
66 | |||
67 | Vector3 dir = new Vector3(1, 0, 0) * p * y; | ||
68 | Vector3 offset = dir * (float)Distance; | ||
69 | |||
70 | offset *= rot; | ||
71 | |||
72 | return pos + offset; | ||
73 | } | ||
74 | } | ||
75 | |||
34 | public class RegionSettings | 76 | public class RegionSettings |
35 | { | 77 | { |
36 | public delegate void SaveDelegate(RegionSettings rs); | 78 | public delegate void SaveDelegate(RegionSettings rs); |
@@ -397,5 +439,49 @@ namespace OpenSim.Framework | |||
397 | set { m_LoadedCreationID = value; } | 439 | set { m_LoadedCreationID = value; } |
398 | } | 440 | } |
399 | 441 | ||
442 | // Connected Telehub object | ||
443 | private UUID m_TelehubObject; | ||
444 | public UUID TelehubObject | ||
445 | { | ||
446 | get | ||
447 | { | ||
448 | return m_TelehubObject; | ||
449 | } | ||
450 | set | ||
451 | { | ||
452 | m_TelehubObject = value; | ||
453 | } | ||
454 | } | ||
455 | |||
456 | // Our Connected Telehub's SpawnPoints | ||
457 | public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>(); | ||
458 | |||
459 | // Add a SpawnPoint | ||
460 | // ** These are not region coordinates ** | ||
461 | // They are relative to the Telehub coordinates | ||
462 | // | ||
463 | public void AddSpawnPoint(SpawnPoint point) | ||
464 | { | ||
465 | l_SpawnPoints.Add(point); | ||
466 | } | ||
467 | |||
468 | // Remove a SpawnPoint | ||
469 | public void RemoveSpawnPoint(int point_index) | ||
470 | { | ||
471 | l_SpawnPoints.RemoveAt(point_index); | ||
472 | } | ||
473 | |||
474 | // Return the List of SpawnPoints | ||
475 | public List<SpawnPoint> SpawnPoints() | ||
476 | { | ||
477 | return l_SpawnPoints; | ||
478 | |||
479 | } | ||
480 | |||
481 | // Clear the SpawnPoints List of all entries | ||
482 | public void ClearSpawnPoints() | ||
483 | { | ||
484 | l_SpawnPoints.Clear(); | ||
485 | } | ||
400 | } | 486 | } |
401 | } | 487 | } |