diff options
author | Dahlia Trimble | 2008-10-15 04:42:28 +0000 |
---|---|---|
committer | Dahlia Trimble | 2008-10-15 04:42:28 +0000 |
commit | 901acddbdd38c441426f43cbfa78c422a19cec17 (patch) | |
tree | 32303dcebf039c840ebae0430bc57e0aa895f5ef | |
parent | * Send an avatar update to other clients when an avatar rotates, as well as w... (diff) | |
download | opensim-SC_OLD-901acddbdd38c441426f43cbfa78c422a19cec17.zip opensim-SC_OLD-901acddbdd38c441426f43cbfa78c422a19cec17.tar.gz opensim-SC_OLD-901acddbdd38c441426f43cbfa78c422a19cec17.tar.bz2 opensim-SC_OLD-901acddbdd38c441426f43cbfa78c422a19cec17.tar.xz |
Thanks to M. Igarashi and nlin for a patch that implements llGetCameraRot().
-rw-r--r-- | OpenSim/Framework/Util.cs | 54 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/ScenePresence.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 16 |
3 files changed, 74 insertions, 1 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 57c1601..28c818a 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -116,6 +116,60 @@ namespace OpenSim.Framework | |||
116 | 116 | ||
117 | # endregion | 117 | # endregion |
118 | 118 | ||
119 | public static Quaternion Axes2Rot(Vector3 fwd, Vector3 left, Vector3 up) | ||
120 | { | ||
121 | float s; | ||
122 | float tr = (float) (fwd.X + left.Y + up.Z + 1.0); | ||
123 | |||
124 | if (tr >= 1.0) | ||
125 | { | ||
126 | s = (float) (0.5 / Math.Sqrt(tr)); | ||
127 | return new Quaternion( | ||
128 | (left.Z - up.Y) * s, | ||
129 | (up.X - fwd.Z) * s, | ||
130 | (fwd.Y - left.X) * s, | ||
131 | (float) 0.25 / s); | ||
132 | } | ||
133 | else | ||
134 | { | ||
135 | float max = (left.Y > up.Z) ? left.Y : up.Z; | ||
136 | |||
137 | if (max < fwd.X) | ||
138 | { | ||
139 | s = (float) (Math.Sqrt(fwd.X - (left.Y + up.Z) + 1.0)); | ||
140 | float x = (float) (s * 0.5); | ||
141 | s = (float) (0.5 / s); | ||
142 | return new Quaternion( | ||
143 | x, | ||
144 | (fwd.Y + left.X) * s, | ||
145 | (up.X + fwd.Z) * s, | ||
146 | (left.Z - up.Y) * s); | ||
147 | } | ||
148 | else if (max == left.Y) | ||
149 | { | ||
150 | s = (float) (Math.Sqrt(left.Y - (up.Z + fwd.X) + 1.0)); | ||
151 | float y = (float) (s * 0.5); | ||
152 | s = (float) (0.5 / s); | ||
153 | return new Quaternion( | ||
154 | (fwd.Y + left.X) * s, | ||
155 | y, | ||
156 | (left.Z + up.Y) * s, | ||
157 | (up.X - fwd.Z) * s); | ||
158 | } | ||
159 | else | ||
160 | { | ||
161 | s = (float) (Math.Sqrt(up.Z - (fwd.X + left.Y) + 1.0)); | ||
162 | float z = (float) (s * 0.5); | ||
163 | s = (float) (0.5 / s); | ||
164 | return new Quaternion( | ||
165 | (up.X + fwd.Z) * s, | ||
166 | (left.Z + up.Y) * s, | ||
167 | z, | ||
168 | (fwd.Y - left.X) * s); | ||
169 | } | ||
170 | } | ||
171 | } | ||
172 | |||
119 | public static Random RandomClass | 173 | public static Random RandomClass |
120 | { | 174 | { |
121 | get { return randomClass; } | 175 | get { return randomClass; } |
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index d87a7e2..6f5372a 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs | |||
@@ -252,6 +252,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
252 | get { return m_CameraCenter; } | 252 | get { return m_CameraCenter; } |
253 | } | 253 | } |
254 | 254 | ||
255 | public Quaternion CameraRotation | ||
256 | { | ||
257 | get { return Util.Axes2Rot(m_CameraAtAxis, m_CameraLeftAxis, m_CameraUpAxis); } | ||
258 | } | ||
259 | |||
255 | public Vector3 Lookat | 260 | public Vector3 Lookat |
256 | { | 261 | { |
257 | get | 262 | get |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7993d95..826324f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -7531,7 +7531,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7531 | public LSL_Rotation llGetCameraRot() | 7531 | public LSL_Rotation llGetCameraRot() |
7532 | { | 7532 | { |
7533 | m_host.AddScriptLPS(1); | 7533 | m_host.AddScriptLPS(1); |
7534 | NotImplemented("llGetCameraRot"); | 7534 | UUID invItemID=InventorySelf(); |
7535 | if (invItemID == UUID.Zero) | ||
7536 | return new LSL_Rotation(); | ||
7537 | if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero) | ||
7538 | return new LSL_Rotation(); | ||
7539 | if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) | ||
7540 | { | ||
7541 | ShoutError("No permissions to track the camera"); | ||
7542 | return new LSL_Rotation(); | ||
7543 | } | ||
7544 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | ||
7545 | if (presence != null) | ||
7546 | { | ||
7547 | return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); | ||
7548 | } | ||
7535 | return new LSL_Rotation(); | 7549 | return new LSL_Rotation(); |
7536 | } | 7550 | } |
7537 | 7551 | ||