aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Client/MXP/ClientStack/MXPClientView.cs143
-rw-r--r--OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs2
2 files changed, 140 insertions, 5 deletions
diff --git a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
index 0a9b6e6..8075d1b 100644
--- a/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
+++ b/OpenSim/Client/MXP/ClientStack/MXPClientView.cs
@@ -40,6 +40,7 @@ using OpenSim.Framework.Client;
40using Packet=OpenMetaverse.Packets.Packet; 40using Packet=OpenMetaverse.Packets.Packet;
41using MXP.Extentions.OpenMetaverseFragments.Proto; 41using MXP.Extentions.OpenMetaverseFragments.Proto;
42using MXP.Util; 42using MXP.Util;
43using MXP.Fragments;
43 44
44namespace OpenSim.Client.MXP.ClientStack 45namespace OpenSim.Client.MXP.ClientStack
45{ 46{
@@ -47,6 +48,15 @@ namespace OpenSim.Client.MXP.ClientStack
47 { 48 {
48 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 50
51 #region Constants
52 private Vector3 FORWARD = new Vector3(1, 0, 0);
53 private Vector3 BACKWARD = new Vector3(-1, 0, 0);
54 private Vector3 LEFT = new Vector3(0, 1, 0);
55 private Vector3 RIGHT = new Vector3(0, -1, 0);
56 private Vector3 UP = new Vector3(0, 0, 1);
57 private Vector3 DOWN = new Vector3(0, 0, -1);
58 #endregion
59
50 #region Fields 60 #region Fields
51 private readonly Session m_session; 61 private readonly Session m_session;
52 private readonly UUID m_sessionID; 62 private readonly UUID m_sessionID;
@@ -163,14 +173,119 @@ namespace OpenSim.Client.MXP.ClientStack
163 173
164 #region MXP Incoming Message Processing 174 #region MXP Incoming Message Processing
165 175
166 public bool ProcessMXPPacket(Message msg) 176 public void MXPPRocessMessage(Message message)
167 { 177 {
168 if (m_debugLevel > 0) 178 if (message.GetType() == typeof(ModifyRequestMessage))
179 {
180 MXPProcessModifyRequest((ModifyRequestMessage)message);
181 }
182 else
169 { 183 {
170 m_log.Warn("[MXP] Received messaged unhandled: " + msg); 184 m_log.Warn("[MXP] Received messaged unhandled: " + message);
171 } 185 }
186 }
172 187
173 return false; 188 private void MXPProcessModifyRequest(ModifyRequestMessage modifyRequest)
189 {
190 m_log.Debug("Received modify request for: " + modifyRequest.ObjectFragment.ObjectName);
191
192 ObjectFragment objectFragment=modifyRequest.ObjectFragment;
193 if (objectFragment.ObjectId == m_userID.Guid)
194 {
195 OmAvatarExt avatarExt = modifyRequest.GetExtension<OmAvatarExt>();
196
197 AgentUpdateArgs agentUpdate = new AgentUpdateArgs();
198 agentUpdate.AgentID = new UUID(objectFragment.ObjectId);
199 agentUpdate.SessionID = m_sessionID;
200 agentUpdate.State = (byte)avatarExt.State;
201
202 Quaternion avatarOrientation = FromOmQuaternion(objectFragment.Orientation);
203 if (avatarOrientation.X == 0 && avatarOrientation.Y == 0 && avatarOrientation.Z == 0 && avatarOrientation.W == 0)
204 {
205 avatarOrientation = Quaternion.Identity;
206 }
207 Vector3 avatarLocation=FromOmVector(objectFragment.Location);
208
209 if (avatarExt.MovementDirection != null)
210 {
211 Vector3 direction = FromOmVector(avatarExt.MovementDirection);
212
213 direction = direction * Quaternion.Inverse(avatarOrientation);
214
215 if ((direction - FORWARD).Length() < 0.5)
216 {
217 agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
218 }
219 if ((direction - BACKWARD).Length() < 0.5)
220 {
221 agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG;
222 }
223 if ((direction - LEFT).Length() < 0.5)
224 {
225 agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
226 }
227 if ((direction - RIGHT).Length() < 0.5)
228 {
229 agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;
230 }
231 if ((direction - UP).Length() < 0.5)
232 {
233 agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
234 }
235 if ((direction - DOWN).Length() < 0.5)
236 {
237 agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG;
238 }
239
240 }
241 if (avatarExt.TargetOrientation != null)
242 {
243 agentUpdate.BodyRotation = FromOmQuaternion(avatarExt.TargetOrientation);
244 }
245 else
246 {
247 agentUpdate.BodyRotation = FromOmQuaternion(objectFragment.Orientation);
248 }
249
250 if (avatarExt.Body != null)
251 {
252 agentUpdate.HeadRotation = FromOmQuaternion(avatarExt.Body.HeadOrientation);
253 }
254 else
255 {
256 agentUpdate.HeadRotation = Quaternion.Identity;
257 }
258
259 if (avatarExt.Camera != null)
260 {
261 Quaternion cameraOrientation = FromOmQuaternion(avatarExt.Camera.Orientation);
262 agentUpdate.CameraCenter = FromOmVector(avatarExt.Camera.Location);
263 agentUpdate.CameraAtAxis = FORWARD * cameraOrientation;
264 agentUpdate.CameraLeftAxis = LEFT * cameraOrientation;
265 agentUpdate.CameraUpAxis = UP * cameraOrientation;
266 }
267 else
268 {
269 agentUpdate.CameraCenter = avatarLocation;
270 agentUpdate.CameraAtAxis = FORWARD * avatarOrientation;
271 agentUpdate.CameraLeftAxis = LEFT * avatarOrientation;
272 agentUpdate.CameraUpAxis = UP * avatarOrientation;
273 }
274
275 OnAgentUpdate(this, agentUpdate);
276
277 ModifyResponseMessage modifyResponse = new ModifyResponseMessage();
278 modifyResponse.FailureCode = MxpResponseCodes.SUCCESS;
279 modifyResponse.RequestMessageId = modifyRequest.MessageId;
280 m_session.Send(modifyResponse);
281 }
282 else
283 {
284 ModifyResponseMessage modifyResponse = new ModifyResponseMessage();
285 modifyResponse.FailureCode = MxpResponseCodes.UNAUTHORIZED_OPERATION;
286 modifyResponse.RequestMessageId = modifyRequest.MessageId;
287 m_session.Send(modifyResponse);
288 }
174 } 289 }
175 290
176 #endregion 291 #endregion
@@ -326,6 +441,26 @@ namespace OpenSim.Client.MXP.ClientStack
326 return encodedValue; 441 return encodedValue;
327 } 442 }
328 443
444 private Vector3 FromOmVector(OmVector3f vector)
445 {
446 return new Vector3(vector.X, vector.Y, vector.Z);
447 }
448
449 private Vector3 FromOmVector(float[] vector)
450 {
451 return new Vector3(vector[0], vector[1], vector[2]);
452 }
453
454 private Quaternion FromOmQuaternion(OmQuaternion4f quaternion)
455 {
456 return new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
457 }
458
459 private Quaternion FromOmQuaternion(float[] quaternion)
460 {
461 return new Quaternion(quaternion[0], quaternion[1], quaternion[2], quaternion[3]);
462 }
463
329 private OmColor4f ToOmColor(byte[] value) 464 private OmColor4f ToOmColor(byte[] value)
330 { 465 {
331 OmColor4f encodedValue = new OmColor4f(); 466 OmColor4f encodedValue = new OmColor4f();
diff --git a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
index 2f26ae3..46d0594 100644
--- a/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
+++ b/OpenSim/Client/MXP/PacketHandler/MXPPacketServer.cs
@@ -412,7 +412,7 @@ namespace OpenSim.Client.MXP.PacketHandler
412 } 412 }
413 else 413 else
414 { 414 {
415 clientView.ProcessMXPPacket(message); 415 clientView.MXPPRocessMessage(message);
416 } 416 }
417 417
418 MessageFactory.Current.ReleaseMessage(message); 418 MessageFactory.Current.ReleaseMessage(message);