MXPClientView.cs 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702
  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. using System;
  28. using System.Collections.Generic;
  29. using System.Net;
  30. using System.Reflection;
  31. using System.Text;
  32. using log4net;
  33. using MXP;
  34. using MXP.Messages;
  35. using OpenMetaverse;
  36. using OpenMetaverse.Packets;
  37. using OpenSim.Framework;
  38. using OpenSim.Framework.Client;
  39. using Packet=OpenMetaverse.Packets.Packet;
  40. using MXP.Extentions.OpenMetaverseFragments.Proto;
  41. using MXP.Util;
  42. using MXP.Fragments;
  43. using MXP.Common.Proto;
  44. using OpenSim.Region.Framework.Scenes;
  45. namespace OpenSim.Client.MXP.ClientStack
  46. {
  47. public class MXPClientView : IClientAPI, IClientCore
  48. {
  49. internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
  50. #region Constants
  51. private Vector3 FORWARD = new Vector3(1, 0, 0);
  52. private Vector3 BACKWARD = new Vector3(-1, 0, 0);
  53. private Vector3 LEFT = new Vector3(0, 1, 0);
  54. private Vector3 RIGHT = new Vector3(0, -1, 0);
  55. private Vector3 UP = new Vector3(0, 0, 1);
  56. private Vector3 DOWN = new Vector3(0, 0, -1);
  57. #endregion
  58. #region Fields
  59. private readonly Session m_session;
  60. private readonly UUID m_sessionID;
  61. private readonly UUID m_userID;
  62. private readonly IScene m_scene;
  63. private readonly string m_firstName;
  64. private readonly string m_lastName;
  65. private int m_objectsToSynchronize = 0;
  66. private int m_objectsSynchronized = -1;
  67. private Vector3 m_startPosition=new Vector3(128f, 128f, 128f);
  68. #endregion
  69. #region Properties
  70. public Session Session
  71. {
  72. get { return m_session; }
  73. }
  74. public Vector3 StartPos
  75. {
  76. get { return m_startPosition; }
  77. set { m_startPosition = value; }
  78. }
  79. public UUID AgentId
  80. {
  81. get { return m_userID; }
  82. }
  83. public UUID SessionId
  84. {
  85. get { return m_sessionID; }
  86. }
  87. public UUID SecureSessionId
  88. {
  89. get { return m_sessionID; }
  90. }
  91. public UUID ActiveGroupId
  92. {
  93. get { return UUID.Zero; }
  94. }
  95. public string ActiveGroupName
  96. {
  97. get { return ""; }
  98. }
  99. public ulong ActiveGroupPowers
  100. {
  101. get { return 0; }
  102. }
  103. public ulong GetGroupPowers(UUID groupID)
  104. {
  105. return 0;
  106. }
  107. public bool IsGroupMember(UUID GroupID)
  108. {
  109. return false;
  110. }
  111. public string FirstName
  112. {
  113. get { return m_firstName; }
  114. }
  115. public string LastName
  116. {
  117. get { return m_lastName; }
  118. }
  119. public IScene Scene
  120. {
  121. get { return m_scene; }
  122. }
  123. public int NextAnimationSequenceNumber
  124. {
  125. get { return 0; }
  126. }
  127. public string Name
  128. {
  129. get { return FirstName; }
  130. }
  131. public bool IsActive
  132. {
  133. get { return Session.SessionState == SessionState.Connected; }
  134. set
  135. {
  136. if (!value)
  137. Stop();
  138. }
  139. }
  140. #endregion
  141. #region Constructors
  142. public MXPClientView(Session mxpSession, UUID mxpSessionID, UUID userID, IScene mxpHostBubble, string mxpFirstName, string mxpLastName)
  143. {
  144. this.m_session = mxpSession;
  145. this.m_userID = userID;
  146. this.m_firstName = mxpFirstName;
  147. this.m_lastName = mxpLastName;
  148. this.m_scene = mxpHostBubble;
  149. this.m_sessionID = mxpSessionID;
  150. }
  151. #endregion
  152. #region MXP Incoming Message Processing
  153. public void MXPPRocessMessage(Message message)
  154. {
  155. if (message.GetType() == typeof(ModifyRequestMessage))
  156. {
  157. MXPProcessModifyRequest((ModifyRequestMessage)message);
  158. }
  159. else
  160. {
  161. m_log.Warn("[MXP ClientStack] Received messaged unhandled: " + message);
  162. }
  163. }
  164. private void MXPProcessModifyRequest(ModifyRequestMessage modifyRequest)
  165. {
  166. ObjectFragment objectFragment=modifyRequest.ObjectFragment;
  167. if (objectFragment.ObjectId == m_userID.Guid)
  168. {
  169. OmAvatarExt avatarExt = modifyRequest.GetExtension<OmAvatarExt>();
  170. AgentUpdateArgs agentUpdate = new AgentUpdateArgs();
  171. agentUpdate.AgentID = new UUID(objectFragment.ObjectId);
  172. agentUpdate.SessionID = m_sessionID;
  173. agentUpdate.State = (byte)avatarExt.State;
  174. Quaternion avatarOrientation = FromOmQuaternion(objectFragment.Orientation);
  175. if (avatarOrientation.X == 0 && avatarOrientation.Y == 0 && avatarOrientation.Z == 0 && avatarOrientation.W == 0)
  176. {
  177. avatarOrientation = Quaternion.Identity;
  178. }
  179. Vector3 avatarLocation=FromOmVector(objectFragment.Location);
  180. if (avatarExt.MovementDirection != null)
  181. {
  182. Vector3 direction = FromOmVector(avatarExt.MovementDirection);
  183. direction = direction * Quaternion.Inverse(avatarOrientation);
  184. if ((direction - FORWARD).Length() < 0.5)
  185. {
  186. agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
  187. }
  188. if ((direction - BACKWARD).Length() < 0.5)
  189. {
  190. agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG;
  191. }
  192. if ((direction - LEFT).Length() < 0.5)
  193. {
  194. agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
  195. }
  196. if ((direction - RIGHT).Length() < 0.5)
  197. {
  198. agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;
  199. }
  200. if ((direction - UP).Length() < 0.5)
  201. {
  202. agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
  203. }
  204. if ((direction - DOWN).Length() < 0.5)
  205. {
  206. agentUpdate.ControlFlags += (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG;
  207. }
  208. }
  209. if (avatarExt.TargetOrientation != null)
  210. {
  211. agentUpdate.BodyRotation = FromOmQuaternion(avatarExt.TargetOrientation);
  212. }
  213. else
  214. {
  215. agentUpdate.BodyRotation = FromOmQuaternion(objectFragment.Orientation);
  216. }
  217. if (avatarExt.Body != null)
  218. {
  219. foreach (OmBipedBoneOrientation boneOrientation in avatarExt.Body.BipedBoneOrientations)
  220. {
  221. if (boneOrientation.Bone == OmBipedBones.Head)
  222. {
  223. agentUpdate.HeadRotation = FromOmQuaternion(boneOrientation.Orientation);
  224. }
  225. }
  226. }
  227. else
  228. {
  229. agentUpdate.HeadRotation = Quaternion.Identity;
  230. }
  231. if (avatarExt.Camera != null)
  232. {
  233. Quaternion cameraOrientation = FromOmQuaternion(avatarExt.Camera.Orientation);
  234. agentUpdate.CameraCenter = FromOmVector(avatarExt.Camera.Location);
  235. agentUpdate.CameraAtAxis = FORWARD * cameraOrientation;
  236. agentUpdate.CameraLeftAxis = LEFT * cameraOrientation;
  237. agentUpdate.CameraUpAxis = UP * cameraOrientation;
  238. }
  239. else
  240. {
  241. agentUpdate.CameraCenter = avatarLocation;
  242. agentUpdate.CameraAtAxis = FORWARD * avatarOrientation;
  243. agentUpdate.CameraLeftAxis = LEFT * avatarOrientation;
  244. agentUpdate.CameraUpAxis = UP * avatarOrientation;
  245. }
  246. OnAgentUpdate(this, agentUpdate);
  247. ModifyResponseMessage modifyResponse = new ModifyResponseMessage();
  248. modifyResponse.FailureCode = MxpResponseCodes.SUCCESS;
  249. modifyResponse.RequestMessageId = modifyRequest.MessageId;
  250. m_session.Send(modifyResponse);
  251. }
  252. else
  253. {
  254. ModifyResponseMessage modifyResponse = new ModifyResponseMessage();
  255. modifyResponse.FailureCode = MxpResponseCodes.UNAUTHORIZED_OPERATION;
  256. modifyResponse.RequestMessageId = modifyRequest.MessageId;
  257. m_session.Send(modifyResponse);
  258. }
  259. }
  260. #endregion
  261. #region MXP Outgoing Message Processing
  262. private void MXPSendPrimitive(uint localID, UUID ownerID, Vector3 acc, Vector3 rvel, PrimitiveBaseShape primShape, Vector3 pos, UUID objectID, Vector3 vel, Quaternion rotation, uint flags, string text, byte[] textColor, uint parentID, byte[] particleSystem, byte clickAction, byte material, byte[] textureanim)
  263. {
  264. String typeName = ToOmType(primShape.PCode);
  265. m_log.Info("[MXP ClientStack] Transmitting Primitive" + typeName);
  266. PerceptionEventMessage pe = new PerceptionEventMessage();
  267. pe.ObjectFragment.ObjectId = objectID.Guid;
  268. pe.ObjectFragment.ParentObjectId = Guid.Empty;
  269. // Resolving parent UUID.
  270. OpenSim.Region.Framework.Scenes.Scene scene = (OpenSim.Region.Framework.Scenes.Scene)Scene;
  271. if (scene.Entities.ContainsKey(parentID))
  272. {
  273. pe.ObjectFragment.ParentObjectId = scene.Entities[parentID].UUID.Guid;
  274. }
  275. pe.ObjectFragment.ObjectIndex = localID;
  276. pe.ObjectFragment.ObjectName = typeName + " Object";
  277. pe.ObjectFragment.OwnerId = ownerID.Guid;
  278. pe.ObjectFragment.TypeId = Guid.Empty;
  279. pe.ObjectFragment.TypeName = typeName;
  280. pe.ObjectFragment.Acceleration = ToOmVector(acc);
  281. pe.ObjectFragment.AngularAcceleration=new MsdQuaternion4f();
  282. pe.ObjectFragment.AngularVelocity = ToOmQuaternion(rvel);
  283. pe.ObjectFragment.BoundingSphereRadius = primShape.Scale.Length();
  284. pe.ObjectFragment.Location = ToOmVector(pos);
  285. pe.ObjectFragment.Mass = 1.0f;
  286. pe.ObjectFragment.Orientation = ToOmQuaternion(rotation);
  287. pe.ObjectFragment.Velocity =ToOmVector(vel);
  288. OmSlPrimitiveExt ext = new OmSlPrimitiveExt();
  289. if (!((primShape.PCode == (byte)PCode.NewTree) || (primShape.PCode == (byte)PCode.Tree) || (primShape.PCode == (byte)PCode.Grass)))
  290. {
  291. ext.PathBegin = primShape.PathBegin;
  292. ext.PathEnd = primShape.PathEnd;
  293. ext.PathScaleX = primShape.PathScaleX;
  294. ext.PathScaleY = primShape.PathScaleY;
  295. ext.PathShearX = primShape.PathShearX;
  296. ext.PathShearY = primShape.PathShearY;
  297. ext.PathSkew = primShape.PathSkew;
  298. ext.ProfileBegin = primShape.ProfileBegin;
  299. ext.ProfileEnd = primShape.ProfileEnd;
  300. ext.PathCurve = primShape.PathCurve;
  301. ext.ProfileCurve = primShape.ProfileCurve;
  302. ext.ProfileHollow = primShape.ProfileHollow;
  303. ext.PathRadiusOffset = primShape.PathRadiusOffset;
  304. ext.PathRevolutions = primShape.PathRevolutions;
  305. ext.PathTaperX = primShape.PathTaperX;
  306. ext.PathTaperY = primShape.PathTaperY;
  307. ext.PathTwist = primShape.PathTwist;
  308. ext.PathTwistBegin = primShape.PathTwistBegin;
  309. }
  310. ext.UpdateFlags = flags;
  311. ext.ExtraParams = primShape.ExtraParams;
  312. ext.State = primShape.State;
  313. ext.TextureEntry = primShape.TextureEntry;
  314. ext.TextureAnim = textureanim;
  315. ext.Scale = ToOmVector(primShape.Scale);
  316. ext.Text = text;
  317. ext.TextColor = ToOmColor(textColor);
  318. ext.PSBlock = particleSystem;
  319. ext.ClickAction = clickAction;
  320. ext.Material = material;
  321. pe.SetExtension<OmSlPrimitiveExt>(ext);
  322. Session.Send(pe);
  323. if (m_objectsSynchronized != -1)
  324. {
  325. m_objectsSynchronized++;
  326. if (m_objectsToSynchronize >= m_objectsSynchronized)
  327. {
  328. SynchronizationEndEventMessage synchronizationEndEventMessage = new SynchronizationEndEventMessage();
  329. Session.Send(synchronizationEndEventMessage);
  330. m_objectsSynchronized = -1;
  331. }
  332. }
  333. }
  334. public void MXPSendAvatarData(string participantName, UUID ownerID, UUID parentId, UUID avatarID, uint avatarLocalID, Vector3 position, Quaternion rotation)
  335. {
  336. m_log.Info("[MXP ClientStack] Transmitting Avatar Data " + participantName);
  337. PerceptionEventMessage pe = new PerceptionEventMessage();
  338. pe.ObjectFragment.ObjectId = avatarID.Guid;
  339. pe.ObjectFragment.ParentObjectId = parentId.Guid;
  340. pe.ObjectFragment.ObjectIndex = avatarLocalID;
  341. pe.ObjectFragment.ObjectName = participantName;
  342. pe.ObjectFragment.OwnerId = ownerID.Guid;
  343. pe.ObjectFragment.TypeId = Guid.Empty;
  344. pe.ObjectFragment.TypeName = "Avatar";
  345. pe.ObjectFragment.Acceleration = new MsdVector3f();
  346. pe.ObjectFragment.AngularAcceleration = new MsdQuaternion4f();
  347. pe.ObjectFragment.AngularVelocity = new MsdQuaternion4f();
  348. pe.ObjectFragment.BoundingSphereRadius = 1.0f; // TODO Fill in appropriate value
  349. pe.ObjectFragment.Location = ToOmVector(position);
  350. pe.ObjectFragment.Mass = 1.0f; // TODO Fill in appropriate value
  351. pe.ObjectFragment.Orientation = ToOmQuaternion(rotation);
  352. pe.ObjectFragment.Velocity = new MsdVector3f();
  353. Session.Send(pe);
  354. }
  355. public void MXPSendTerrain(float[] map)
  356. {
  357. m_log.Info("[MXP ClientStack] Transmitting terrain for " + m_scene.RegionInfo.RegionName);
  358. PerceptionEventMessage pe = new PerceptionEventMessage();
  359. // Hacking terrain object uuid to zero and index to hashcode of regionuuid
  360. pe.ObjectFragment.ObjectId = m_scene.RegionInfo.RegionSettings.RegionUUID.Guid;
  361. pe.ObjectFragment.ObjectIndex = (uint)(m_scene.RegionInfo.RegionSettings.RegionUUID.GetHashCode() + ((long)int.MaxValue) / 2);
  362. pe.ObjectFragment.ParentObjectId = UUID.Zero.Guid;
  363. pe.ObjectFragment.ObjectName = "Terrain of " + m_scene.RegionInfo.RegionName;
  364. pe.ObjectFragment.OwnerId = m_scene.RegionInfo.MasterAvatarAssignedUUID.Guid;
  365. pe.ObjectFragment.TypeId = Guid.Empty;
  366. pe.ObjectFragment.TypeName = "Terrain";
  367. pe.ObjectFragment.Acceleration = new MsdVector3f();
  368. pe.ObjectFragment.AngularAcceleration = new MsdQuaternion4f();
  369. pe.ObjectFragment.AngularVelocity = new MsdQuaternion4f();
  370. pe.ObjectFragment.BoundingSphereRadius = 128f;
  371. pe.ObjectFragment.Location = new MsdVector3f();
  372. pe.ObjectFragment.Mass = 1.0f;
  373. pe.ObjectFragment.Orientation = new MsdQuaternion4f();
  374. pe.ObjectFragment.Velocity = new MsdVector3f();
  375. OmBitmapTerrainExt terrainExt = new OmBitmapTerrainExt();
  376. terrainExt.Width = 256;
  377. terrainExt.Height = 256;
  378. terrainExt.WaterLevel = (float) m_scene.RegionInfo.RegionSettings.WaterHeight;
  379. terrainExt.Offset = 0;
  380. terrainExt.Scale = 10;
  381. terrainExt.HeightMap = CompressUtil.CompressHeightMap(map, 0, 10);
  382. pe.SetExtension<OmBitmapTerrainExt>(terrainExt);
  383. Session.Send(pe);
  384. }
  385. public void MXPSendSynchronizationBegin(int objectCount)
  386. {
  387. m_objectsToSynchronize = objectCount;
  388. m_objectsSynchronized = 0;
  389. SynchronizationBeginEventMessage synchronizationBeginEventMessage = new SynchronizationBeginEventMessage();
  390. synchronizationBeginEventMessage.ObjectCount = (uint)objectCount;
  391. Session.Send(synchronizationBeginEventMessage);
  392. }
  393. #endregion
  394. #region MXP Conversions
  395. private MsdVector3f ToOmVector(Vector3 value)
  396. {
  397. MsdVector3f encodedValue = new MsdVector3f();
  398. encodedValue.X = value.X;
  399. encodedValue.Y = value.Y;
  400. encodedValue.Z = value.Z;
  401. return encodedValue;
  402. }
  403. private MsdQuaternion4f ToOmQuaternion(Vector3 value)
  404. {
  405. Quaternion quaternion=Quaternion.CreateFromEulers(value);
  406. MsdQuaternion4f encodedValue = new MsdQuaternion4f();
  407. encodedValue.X = quaternion.X;
  408. encodedValue.Y = quaternion.Y;
  409. encodedValue.Z = quaternion.Z;
  410. encodedValue.W = quaternion.W;
  411. return encodedValue;
  412. }
  413. private MsdQuaternion4f ToOmQuaternion(Quaternion value)
  414. {
  415. MsdQuaternion4f encodedValue = new MsdQuaternion4f();
  416. encodedValue.X = value.X;
  417. encodedValue.Y = value.Y;
  418. encodedValue.Z = value.Z;
  419. encodedValue.W = value.W;
  420. return encodedValue;
  421. }
  422. private Vector3 FromOmVector(MsdVector3f vector)
  423. {
  424. return new Vector3(vector.X, vector.Y, vector.Z);
  425. }
  426. // private Vector3 FromOmVector(float[] vector)
  427. // {
  428. // return new Vector3(vector[0], vector[1], vector[2]);
  429. // }
  430. private Quaternion FromOmQuaternion(MsdQuaternion4f quaternion)
  431. {
  432. return new Quaternion(quaternion.X, quaternion.Y, quaternion.Z, quaternion.W);
  433. }
  434. // private Quaternion FromOmQuaternion(float[] quaternion)
  435. // {
  436. // return new Quaternion(quaternion[0], quaternion[1], quaternion[2], quaternion[3]);
  437. // }
  438. private MsdColor4f ToOmColor(byte[] value)
  439. {
  440. MsdColor4f encodedValue = new MsdColor4f();
  441. encodedValue.R = value[0];
  442. encodedValue.G = value[1];
  443. encodedValue.B = value[2];
  444. encodedValue.A = value[3];
  445. return encodedValue;
  446. }
  447. private string ToOmType(byte value)
  448. {
  449. if (value == (byte)PCodeEnum.Avatar)
  450. {
  451. return "Avatar";
  452. }
  453. if (value == (byte)PCodeEnum.Grass)
  454. {
  455. return "Grass";
  456. }
  457. if (value == (byte)PCodeEnum.NewTree)
  458. {
  459. return "NewTree";
  460. }
  461. if (value == (byte)PCodeEnum.ParticleSystem)
  462. {
  463. return "ParticleSystem";
  464. }
  465. if (value == (byte)PCodeEnum.Primitive)
  466. {
  467. return "Primitive";
  468. }
  469. if (value == (byte)PCodeEnum.Tree)
  470. {
  471. return "Tree";
  472. }
  473. throw new Exception("Unsupported PCode value: " + value);
  474. }
  475. #endregion
  476. #region OpenSim Event Handlers
  477. #pragma warning disable 67
  478. public event GenericMessage OnGenericMessage;
  479. public event ImprovedInstantMessage OnInstantMessage;
  480. public event ChatMessage OnChatFromClient;
  481. public event TextureRequest OnRequestTexture;
  482. public event RezObject OnRezObject;
  483. public event ModifyTerrain OnModifyTerrain;
  484. public event BakeTerrain OnBakeTerrain;
  485. public event EstateChangeInfo OnEstateChangeInfo;
  486. public event SetAppearance OnSetAppearance;
  487. public event AvatarNowWearing OnAvatarNowWearing;
  488. public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
  489. public event RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv;
  490. public event UUIDNameRequest OnDetachAttachmentIntoInv;
  491. public event ObjectAttach OnObjectAttach;
  492. public event ObjectDeselect OnObjectDetach;
  493. public event ObjectDrop OnObjectDrop;
  494. public event StartAnim OnStartAnim;
  495. public event StopAnim OnStopAnim;
  496. public event LinkObjects OnLinkObjects;
  497. public event DelinkObjects OnDelinkObjects;
  498. public event RequestMapBlocks OnRequestMapBlocks;
  499. public event RequestMapName OnMapNameRequest;
  500. public event TeleportLocationRequest OnTeleportLocationRequest;
  501. public event DisconnectUser OnDisconnectUser;
  502. public event RequestAvatarProperties OnRequestAvatarProperties;
  503. public event SetAlwaysRun OnSetAlwaysRun;
  504. public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
  505. public event DeRezObject OnDeRezObject;
  506. public event Action<IClientAPI> OnRegionHandShakeReply;
  507. public event GenericCall2 OnRequestWearables;
  508. public event GenericCall2 OnCompleteMovementToRegion;
  509. public event UpdateAgent OnAgentUpdate;
  510. public event AgentRequestSit OnAgentRequestSit;
  511. public event AgentSit OnAgentSit;
  512. public event AvatarPickerRequest OnAvatarPickerRequest;
  513. public event Action<IClientAPI> OnRequestAvatarsData;
  514. public event AddNewPrim OnAddPrim;
  515. public event FetchInventory OnAgentDataUpdateRequest;
  516. public event TeleportLocationRequest OnSetStartLocationRequest;
  517. public event RequestGodlikePowers OnRequestGodlikePowers;
  518. public event GodKickUser OnGodKickUser;
  519. public event ObjectDuplicate OnObjectDuplicate;
  520. public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
  521. public event GrabObject OnGrabObject;
  522. public event DeGrabObject OnDeGrabObject;
  523. public event MoveObject OnGrabUpdate;
  524. public event SpinStart OnSpinStart;
  525. public event SpinObject OnSpinUpdate;
  526. public event SpinStop OnSpinStop;
  527. public event UpdateShape OnUpdatePrimShape;
  528. public event ObjectExtraParams OnUpdateExtraParams;
  529. public event ObjectRequest OnObjectRequest;
  530. public event ObjectSelect OnObjectSelect;
  531. public event ObjectDeselect OnObjectDeselect;
  532. public event GenericCall7 OnObjectDescription;
  533. public event GenericCall7 OnObjectName;
  534. public event GenericCall7 OnObjectClickAction;
  535. public event GenericCall7 OnObjectMaterial;
  536. public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
  537. public event UpdatePrimFlags OnUpdatePrimFlags;
  538. public event UpdatePrimTexture OnUpdatePrimTexture;
  539. public event UpdateVector OnUpdatePrimGroupPosition;
  540. public event UpdateVector OnUpdatePrimSinglePosition;
  541. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  542. public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
  543. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  544. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  545. public event UpdateVector OnUpdatePrimScale;
  546. public event UpdateVector OnUpdatePrimGroupScale;
  547. public event StatusChange OnChildAgentStatus;
  548. public event GenericCall2 OnStopMovement;
  549. public event Action<UUID> OnRemoveAvatar;
  550. public event ObjectPermissions OnObjectPermissions;
  551. public event CreateNewInventoryItem OnCreateNewInventoryItem;
  552. public event CreateInventoryFolder OnCreateNewInventoryFolder;
  553. public event UpdateInventoryFolder OnUpdateInventoryFolder;
  554. public event MoveInventoryFolder OnMoveInventoryFolder;
  555. public event FetchInventoryDescendents OnFetchInventoryDescendents;
  556. public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
  557. public event FetchInventory OnFetchInventory;
  558. public event RequestTaskInventory OnRequestTaskInventory;
  559. public event UpdateInventoryItem OnUpdateInventoryItem;
  560. public event CopyInventoryItem OnCopyInventoryItem;
  561. public event MoveInventoryItem OnMoveInventoryItem;
  562. public event RemoveInventoryFolder OnRemoveInventoryFolder;
  563. public event RemoveInventoryItem OnRemoveInventoryItem;
  564. public event UDPAssetUploadRequest OnAssetUploadRequest;
  565. public event XferReceive OnXferReceive;
  566. public event RequestXfer OnRequestXfer;
  567. public event ConfirmXfer OnConfirmXfer;
  568. public event AbortXfer OnAbortXfer;
  569. public event RezScript OnRezScript;
  570. public event UpdateTaskInventory OnUpdateTaskInventory;
  571. public event MoveTaskInventory OnMoveTaskItem;
  572. public event RemoveTaskInventory OnRemoveTaskItem;
  573. public event RequestAsset OnRequestAsset;
  574. public event UUIDNameRequest OnNameFromUUIDRequest;
  575. public event ParcelAccessListRequest OnParcelAccessListRequest;
  576. public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
  577. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  578. public event ParcelDivideRequest OnParcelDivideRequest;
  579. public event ParcelJoinRequest OnParcelJoinRequest;
  580. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  581. public event ParcelSelectObjects OnParcelSelectObjects;
  582. public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
  583. public event ParcelAbandonRequest OnParcelAbandonRequest;
  584. public event ParcelGodForceOwner OnParcelGodForceOwner;
  585. public event ParcelReclaim OnParcelReclaim;
  586. public event ParcelReturnObjectsRequest OnParcelReturnObjectsRequest;
  587. public event ParcelDeedToGroup OnParcelDeedToGroup;
  588. public event RegionInfoRequest OnRegionInfoRequest;
  589. public event EstateCovenantRequest OnEstateCovenantRequest;
  590. public event FriendActionDelegate OnApproveFriendRequest;
  591. public event FriendActionDelegate OnDenyFriendRequest;
  592. public event FriendshipTermination OnTerminateFriendship;
  593. public event GrantUserFriendRights OnGrantUserRights;
  594. public event MoneyTransferRequest OnMoneyTransferRequest;
  595. public event EconomyDataRequest OnEconomyDataRequest;
  596. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  597. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  598. public event ParcelBuy OnParcelBuy;
  599. public event RequestPayPrice OnRequestPayPrice;
  600. public event ObjectSaleInfo OnObjectSaleInfo;
  601. public event ObjectBuy OnObjectBuy;
  602. public event BuyObjectInventory OnBuyObjectInventory;
  603. public event RequestTerrain OnRequestTerrain;
  604. public event RequestTerrain OnUploadTerrain;
  605. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  606. public event UUIDNameRequest OnTeleportHomeRequest;
  607. public event ScriptAnswer OnScriptAnswer;
  608. public event AgentSit OnUndo;
  609. public event ForceReleaseControls OnForceReleaseControls;
  610. public event GodLandStatRequest OnLandStatRequest;
  611. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  612. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  613. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  614. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  615. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  616. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  617. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  618. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  619. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  620. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  621. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  622. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  623. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  624. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  625. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  626. public event UUIDNameRequest OnUUIDGroupNameRequest;
  627. public event RegionHandleRequest OnRegionHandleRequest;
  628. public event ParcelInfoRequest OnParcelInfoRequest;
  629. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  630. public event ScriptReset OnScriptReset;
  631. public event GetScriptRunning OnGetScriptRunning;
  632. public event SetScriptRunning OnSetScriptRunning;
  633. public event UpdateVector OnAutoPilotGo;
  634. public event TerrainUnacked OnUnackedTerrain;
  635. public event ActivateGesture OnActivateGesture;
  636. public event DeactivateGesture OnDeactivateGesture;
  637. public event ObjectOwner OnObjectOwner;
  638. public event DirPlacesQuery OnDirPlacesQuery;
  639. public event DirFindQuery OnDirFindQuery;
  640. public event DirLandQuery OnDirLandQuery;
  641. public event DirPopularQuery OnDirPopularQuery;
  642. public event DirClassifiedQuery OnDirClassifiedQuery;
  643. public event EventInfoRequest OnEventInfoRequest;
  644. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  645. public event MapItemRequest OnMapItemRequest;
  646. public event OfferCallingCard OnOfferCallingCard;
  647. public event AcceptCallingCard OnAcceptCallingCard;
  648. public event DeclineCallingCard OnDeclineCallingCard;
  649. public event SoundTrigger OnSoundTrigger;
  650. public event StartLure OnStartLure;
  651. public event TeleportLureRequest OnTeleportLureRequest;
  652. public event NetworkStats OnNetworkStatsUpdate;
  653. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  654. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  655. public event ClassifiedDelete OnClassifiedDelete;
  656. public event ClassifiedDelete OnClassifiedGodDelete;
  657. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  658. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  659. public event EventGodDelete OnEventGodDelete;
  660. public event ParcelDwellRequest OnParcelDwellRequest;
  661. public event UserInfoRequest OnUserInfoRequest;
  662. public event UpdateUserInfo OnUpdateUserInfo;
  663. public event ViewerEffectEventHandler OnViewerEffect;
  664. public event Action<IClientAPI> OnLogout;
  665. public event Action<IClientAPI> OnConnectionClosed;
  666. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  667. public event PickDelete OnPickDelete;
  668. public event PickGodDelete OnPickGodDelete;
  669. public event PickInfoUpdate OnPickInfoUpdate;
  670. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  671. public event MuteListRequest OnMuteListRequest;
  672. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  673. public event FindAgentUpdate OnFindAgent;
  674. public event TrackAgentUpdate OnTrackAgent;
  675. public event NewUserReport OnUserReport;
  676. public event SaveStateHandler OnSaveState;
  677. public event GroupAccountSummaryRequest OnGroupAccountSummaryRequest;
  678. public event GroupAccountDetailsRequest OnGroupAccountDetailsRequest;
  679. public event GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest;
  680. public event FreezeUserUpdate OnParcelFreezeUser;
  681. public event EjectUserUpdate OnParcelEjectUser;
  682. public event ParcelBuyPass OnParcelBuyPass;
  683. public event ParcelGodMark OnParcelGodMark;
  684. public event GroupActiveProposalsRequest OnGroupActiveProposalsRequest;
  685. public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
  686. public event SimWideDeletesDelegate OnSimWideDeletes;
  687. public event SendPostcard OnSendPostcard;
  688. public event MuteListEntryUpdate OnUpdateMuteListEntry;
  689. public event MuteListEntryRemove OnRemoveMuteListEntry;
  690. public event GodlikeMessage onGodlikeMessage;
  691. public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
  692. public event PlacesQuery OnPlacesQuery;
  693. #pragma warning restore 67
  694. #endregion
  695. #region OpenSim ClientView Public Methods
  696. // Do we need this?
  697. public bool SendLogoutPacketWhenClosing
  698. {
  699. set { }
  700. }
  701. public uint CircuitCode
  702. {
  703. get { return m_sessionID.CRC(); }
  704. }
  705. public IPEndPoint RemoteEndPoint
  706. {
  707. get { return Session.RemoteEndPoint; }
  708. }
  709. public void SetDebugPacketLevel(int newDebug)
  710. {
  711. //m_debugLevel = newDebug;
  712. }
  713. public void InPacket(object NewPack)
  714. {
  715. //throw new System.NotImplementedException();
  716. }
  717. public void ProcessInPacket(Packet NewPack)
  718. {
  719. //throw new System.NotImplementedException();
  720. }
  721. public void OnClean()
  722. {
  723. if (OnLogout != null)
  724. OnLogout(this);
  725. if (OnConnectionClosed != null)
  726. OnConnectionClosed(this);
  727. }
  728. public void Close()
  729. {
  730. m_log.Info("[MXP ClientStack] Close Called");
  731. // Tell the client to go
  732. SendLogoutPacket();
  733. // Let MXPPacketServer clean it up
  734. if (Session.SessionState != SessionState.Disconnected)
  735. {
  736. Session.SetStateDisconnected();
  737. }
  738. }
  739. public void Kick(string message)
  740. {
  741. Close();
  742. }
  743. public void Start()
  744. {
  745. Scene.AddNewClient(this);
  746. // Mimicking LLClientView which gets always set appearance from client.
  747. OpenSim.Region.Framework.Scenes.Scene scene=(OpenSim.Region.Framework.Scenes.Scene)Scene;
  748. AvatarAppearance appearance;
  749. scene.GetAvatarAppearance(this,out appearance);
  750. OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone());
  751. }
  752. public void Stop()
  753. {
  754. // Nor this
  755. }
  756. public void SendWearables(AvatarWearable[] wearables, int serial)
  757. {
  758. // Need to translate to MXP somehow
  759. }
  760. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  761. {
  762. // Need to translate to MXP somehow
  763. }
  764. public void SendStartPingCheck(byte seq)
  765. {
  766. // Need to translate to MXP somehow
  767. }
  768. public void SendKillObject(ulong regionHandle, uint localID)
  769. {
  770. DisappearanceEventMessage de = new DisappearanceEventMessage();
  771. de.ObjectIndex = localID;
  772. Session.Send(de);
  773. }
  774. public void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  775. {
  776. // Need to translate to MXP somehow
  777. }
  778. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  779. {
  780. m_log.Info("[MXP ClientStack] Completing Handshake to Region");
  781. if (OnRegionHandShakeReply != null)
  782. {
  783. OnRegionHandShakeReply(this);
  784. }
  785. if (OnCompleteMovementToRegion != null)
  786. {
  787. OnCompleteMovementToRegion();
  788. }
  789. // Need to translate to MXP somehow
  790. }
  791. public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, byte audible)
  792. {
  793. ActionEventMessage chatActionEvent = new ActionEventMessage();
  794. chatActionEvent.ActionFragment.ActionName = "Chat";
  795. chatActionEvent.ActionFragment.SourceObjectId = fromAgentID.Guid;
  796. chatActionEvent.ActionFragment.ObservationRadius = 180.0f;
  797. chatActionEvent.ActionFragment.ExtensionDialect = "TEXT";
  798. chatActionEvent.SetPayloadData(Util.UTF8.GetBytes(message));
  799. Session.Send(chatActionEvent);
  800. }
  801. public void SendInstantMessage(GridInstantMessage im)
  802. {
  803. // Need to translate to MXP somehow
  804. }
  805. public void SendGenericMessage(string method, List<string> message)
  806. {
  807. // Need to translate to MXP somehow
  808. }
  809. public void SendLayerData(float[] map)
  810. {
  811. MXPSendTerrain(map);
  812. }
  813. public void SendLayerData(int px, int py, float[] map)
  814. {
  815. }
  816. public void SendWindData(Vector2[] windSpeeds)
  817. {
  818. // Need to translate to MXP somehow
  819. }
  820. public void SendCloudData(float[] cloudCover)
  821. {
  822. // Need to translate to MXP somehow
  823. }
  824. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  825. {
  826. //throw new System.NotImplementedException();
  827. }
  828. public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
  829. {
  830. //throw new System.NotImplementedException();
  831. }
  832. public AgentCircuitData RequestClientInfo()
  833. {
  834. AgentCircuitData clientinfo = new AgentCircuitData();
  835. clientinfo.AgentID = AgentId;
  836. clientinfo.Appearance = new AvatarAppearance();
  837. clientinfo.BaseFolder = UUID.Zero;
  838. clientinfo.CapsPath = "";
  839. clientinfo.child = false;
  840. clientinfo.ChildrenCapSeeds = new Dictionary<ulong, string>();
  841. clientinfo.circuitcode = CircuitCode;
  842. clientinfo.firstname = FirstName;
  843. clientinfo.InventoryFolder = UUID.Zero;
  844. clientinfo.lastname = LastName;
  845. clientinfo.SecureSessionID = SecureSessionId;
  846. clientinfo.SessionID = SessionId;
  847. clientinfo.startpos = StartPos;
  848. return clientinfo;
  849. }
  850. public void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL)
  851. {
  852. // TODO: We'll want to get this one working.
  853. // Need to translate to MXP somehow
  854. }
  855. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  856. {
  857. // Need to translate to MXP somehow
  858. }
  859. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  860. {
  861. //throw new System.NotImplementedException();
  862. }
  863. public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL)
  864. {
  865. // Need to translate to MXP somehow
  866. }
  867. public void SendTeleportFailed(string reason)
  868. {
  869. // Need to translate to MXP somehow
  870. }
  871. public void SendTeleportLocationStart()
  872. {
  873. // Need to translate to MXP somehow
  874. }
  875. public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance)
  876. {
  877. // Need to translate to MXP somehow
  878. }
  879. public void SendPayPrice(UUID objectID, int[] payPrice)
  880. {
  881. // Need to translate to MXP somehow
  882. }
  883. public void SendAvatarData(SendAvatarData data)
  884. {
  885. //ScenePresence presence=((Scene)this.Scene).GetScenePresence(avatarID);
  886. UUID ownerID = data.AvatarID;
  887. MXPSendAvatarData(data.FirstName + " " + data.LastName, ownerID, UUID.Zero, data.AvatarID, data.AvatarLocalID, data.Position, data.Rotation);
  888. }
  889. public void SendAvatarTerseUpdate(SendAvatarTerseData data)
  890. {
  891. MovementEventMessage me = new MovementEventMessage();
  892. me.ObjectIndex = data.LocalID;
  893. me.Location = ToOmVector(data.Position);
  894. me.Orientation = ToOmQuaternion(data.Rotation);
  895. Session.Send(me);
  896. }
  897. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  898. {
  899. // Minimap function, not used.
  900. }
  901. public void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID)
  902. {
  903. // Need to translate to MXP somehow
  904. }
  905. public void SetChildAgentThrottle(byte[] throttle)
  906. {
  907. // Need to translate to MXP somehow
  908. }
  909. public void SendPrimitiveToClient(SendPrimitiveData data)
  910. {
  911. MXPSendPrimitive(data.localID, data.ownerID, data.acc, data.rvel, data.primShape, data.pos, data.objectID, data.vel,
  912. data.rotation, (uint)data.flags, data.text, data.color, data.parentID, data.particleSystem, data.clickAction,
  913. data.material, data.textureanim);
  914. }
  915. public void SendPrimTerseUpdate(SendPrimitiveTerseData data)
  916. {
  917. MovementEventMessage me = new MovementEventMessage();
  918. me.ObjectIndex = data.LocalID;
  919. me.Location = ToOmVector(data.Position);
  920. me.Orientation = ToOmQuaternion(data.Rotation);
  921. Session.Send(me);
  922. }
  923. public void ReprioritizeUpdates(StateUpdateTypes type, UpdatePriorityHandler handler)
  924. {
  925. }
  926. public void FlushPrimUpdates()
  927. {
  928. }
  929. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, int version, bool fetchFolders, bool fetchItems)
  930. {
  931. // Need to translate to MXP somehow
  932. }
  933. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  934. {
  935. // Need to translate to MXP somehow
  936. }
  937. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  938. {
  939. // Need to translate to MXP somehow
  940. }
  941. public void SendRemoveInventoryItem(UUID itemID)
  942. {
  943. // Need to translate to MXP somehow
  944. }
  945. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  946. {
  947. // Need to translate to MXP somehow
  948. }
  949. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  950. {
  951. // Need to translate to MXP somehow
  952. }
  953. public void SendBulkUpdateInventory(InventoryNodeBase node)
  954. {
  955. // Need to translate to MXP somehow
  956. }
  957. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  958. {
  959. // SL Specific, Ignore. (Remove from IClient)
  960. }
  961. public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
  962. {
  963. // SL Specific, Ignore. (Remove from IClient)
  964. }
  965. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  966. {
  967. // Need to translate to MXP somehow
  968. }
  969. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  970. {
  971. // Need to translate to MXP somehow
  972. // TODO: This may need doing - involves displaying the users avatar name
  973. }
  974. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  975. {
  976. // Need to translate to MXP somehow
  977. }
  978. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  979. {
  980. // Need to translate to MXP somehow
  981. }
  982. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  983. {
  984. // Need to translate to MXP somehow
  985. }
  986. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  987. {
  988. // Need to translate to MXP somehow
  989. }
  990. public void SendNameReply(UUID profileId, string firstname, string lastname)
  991. {
  992. // SL Specific
  993. }
  994. public void SendAlertMessage(string message)
  995. {
  996. SendChatMessage(message, 0, Vector3.Zero, "System", UUID.Zero, 0, 0);
  997. }
  998. public void SendAgentAlertMessage(string message, bool modal)
  999. {
  1000. SendChatMessage(message, 0, Vector3.Zero, "System" + (modal ? " Notice" : ""), UUID.Zero, 0, 0);
  1001. }
  1002. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url)
  1003. {
  1004. // TODO: Probably can do this better
  1005. SendChatMessage("Please visit: " + url, 0, Vector3.Zero, objectname, UUID.Zero, 0, 0);
  1006. }
  1007. public void SendDialog(string objectname, UUID objectID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels)
  1008. {
  1009. // TODO: Probably can do this better
  1010. SendChatMessage("Dialog: " + msg, 0, Vector3.Zero, objectname, UUID.Zero, 0, 0);
  1011. }
  1012. public bool AddMoney(int debit)
  1013. {
  1014. SendChatMessage("You were paid: " + debit, 0, Vector3.Zero, "System", UUID.Zero, 0, 0);
  1015. return true;
  1016. }
  1017. public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  1018. {
  1019. // Need to translate to MXP somehow
  1020. // Send a light object?
  1021. }
  1022. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  1023. {
  1024. // Need to translate to MXP somehow
  1025. }
  1026. public void SendViewerTime(int phase)
  1027. {
  1028. // Need to translate to MXP somehow
  1029. }
  1030. public UUID GetDefaultAnimation(string name)
  1031. {
  1032. return UUID.Zero;
  1033. }
  1034. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] charterMember, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID)
  1035. {
  1036. // Need to translate to MXP somehow
  1037. }
  1038. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  1039. {
  1040. // Need to translate to MXP somehow
  1041. }
  1042. public void SendHealth(float health)
  1043. {
  1044. // Need to translate to MXP somehow
  1045. }
  1046. public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
  1047. {
  1048. // Need to translate to MXP somehow
  1049. }
  1050. public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID)
  1051. {
  1052. // Need to translate to MXP somehow
  1053. }
  1054. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  1055. {
  1056. // Need to translate to MXP somehow
  1057. }
  1058. public void SendEstateCovenantInformation(UUID covenant)
  1059. {
  1060. // Need to translate to MXP somehow
  1061. }
  1062. public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner)
  1063. {
  1064. // Need to translate to MXP somehow
  1065. }
  1066. public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  1067. {
  1068. // Need to translate to MXP somehow
  1069. }
  1070. public void SendLandAccessListData(List<UUID> avatars, uint accessFlag, int localLandID)
  1071. {
  1072. // Need to translate to MXP somehow
  1073. }
  1074. public void SendForceClientSelectObjects(List<uint> objectIDs)
  1075. {
  1076. // Need to translate to MXP somehow
  1077. }
  1078. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  1079. {
  1080. // Need to translate to MXP somehow
  1081. }
  1082. public void SendCameraConstraint(Vector4 ConstraintPlane)
  1083. {
  1084. }
  1085. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  1086. {
  1087. // Need to translate to MXP somehow
  1088. }
  1089. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  1090. {
  1091. // Need to translate to MXP somehow
  1092. }
  1093. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight, byte mediaLoop)
  1094. {
  1095. // Need to translate to MXP somehow
  1096. }
  1097. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  1098. {
  1099. // Need to translate to MXP somehow
  1100. }
  1101. public void SendConfirmXfer(ulong xferID, uint PacketID)
  1102. {
  1103. // Need to translate to MXP somehow
  1104. }
  1105. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  1106. {
  1107. // Need to translate to MXP somehow
  1108. }
  1109. public void SendInitiateDownload(string simFileName, string clientFileName)
  1110. {
  1111. // Need to translate to MXP somehow
  1112. }
  1113. public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  1114. {
  1115. // Need to translate to MXP somehow
  1116. }
  1117. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  1118. {
  1119. // Need to translate to MXP somehow
  1120. }
  1121. public void SendImageNotFound(UUID imageid)
  1122. {
  1123. // Need to translate to MXP somehow
  1124. }
  1125. public void SendShutdownConnectionNotice()
  1126. {
  1127. // Need to translate to MXP somehow
  1128. }
  1129. public void SendSimStats(SimStats stats)
  1130. {
  1131. // Need to translate to MXP somehow
  1132. }
  1133. public void SendObjectPropertiesFamilyData(uint RequestFlags, UUID ObjectUUID, UUID OwnerID, UUID GroupID, uint BaseMask, uint OwnerMask, uint GroupMask, uint EveryoneMask, uint NextOwnerMask, int OwnershipCost, byte SaleType, int SalePrice, uint Category, UUID LastOwnerID, string ObjectName, string Description)
  1134. {
  1135. //throw new System.NotImplementedException();
  1136. }
  1137. public void SendObjectPropertiesReply(UUID ItemID, ulong CreationDate, UUID CreatorUUID, UUID FolderUUID, UUID FromTaskUUID, UUID GroupUUID, short InventorySerial, UUID LastOwnerUUID, UUID ObjectUUID, UUID OwnerUUID, string TouchTitle, byte[] TextureID, string SitTitle, string ItemName, string ItemDescription, uint OwnerMask, uint NextOwnerMask, uint GroupMask, uint EveryoneMask, uint BaseMask, byte saleType, int salePrice)
  1138. {
  1139. //throw new System.NotImplementedException();
  1140. }
  1141. public void SendAgentOffline(UUID[] agentIDs)
  1142. {
  1143. // Need to translate to MXP somehow (Friends List)
  1144. }
  1145. public void SendAgentOnline(UUID[] agentIDs)
  1146. {
  1147. // Need to translate to MXP somehow (Friends List)
  1148. }
  1149. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  1150. {
  1151. // Need to translate to MXP somehow
  1152. }
  1153. public void SendAdminResponse(UUID Token, uint AdminLevel)
  1154. {
  1155. // Need to translate to MXP somehow
  1156. }
  1157. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  1158. {
  1159. // Need to translate to MXP somehow
  1160. }
  1161. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  1162. {
  1163. // Need to translate to MXP somehow
  1164. }
  1165. public void SendJoinGroupReply(UUID groupID, bool success)
  1166. {
  1167. // Need to translate to MXP somehow
  1168. }
  1169. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  1170. {
  1171. // Need to translate to MXP somehow
  1172. }
  1173. public void SendLeaveGroupReply(UUID groupID, bool success)
  1174. {
  1175. // Need to translate to MXP somehow
  1176. }
  1177. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  1178. {
  1179. // Need to translate to MXP somehow
  1180. }
  1181. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  1182. {
  1183. // Need to translate to MXP somehow
  1184. }
  1185. public void SendAsset(AssetRequestToClient req)
  1186. {
  1187. // Need to translate to MXP somehow
  1188. }
  1189. public void SendTexture(AssetBase TextureAsset)
  1190. {
  1191. // Need to translate to MXP somehow
  1192. }
  1193. public byte[] GetThrottlesPacked(float multiplier)
  1194. {
  1195. // LL Specific, get out of IClientAPI
  1196. const int singlefloat = 4;
  1197. float tResend = multiplier;
  1198. float tLand = multiplier;
  1199. float tWind = multiplier;
  1200. float tCloud = multiplier;
  1201. float tTask = multiplier;
  1202. float tTexture = multiplier;
  1203. float tAsset = multiplier;
  1204. byte[] throttles = new byte[singlefloat * 7];
  1205. int i = 0;
  1206. Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat * i, singlefloat);
  1207. i++;
  1208. Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat * i, singlefloat);
  1209. i++;
  1210. Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat * i, singlefloat);
  1211. i++;
  1212. Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat * i, singlefloat);
  1213. i++;
  1214. Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat * i, singlefloat);
  1215. i++;
  1216. Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat * i, singlefloat);
  1217. i++;
  1218. Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat * i, singlefloat);
  1219. return throttles;
  1220. }
  1221. public void SendBlueBoxMessage(UUID FromAvatarID, string FromAvatarName, string Message)
  1222. {
  1223. SendChatMessage(Message, 0, Vector3.Zero, FromAvatarName, UUID.Zero, 0, 0);
  1224. }
  1225. public void SendLogoutPacket()
  1226. {
  1227. LeaveRequestMessage lrm = new LeaveRequestMessage();
  1228. Session.Send(lrm);
  1229. }
  1230. public EndPoint GetClientEP()
  1231. {
  1232. return null;
  1233. }
  1234. public ClientInfo GetClientInfo()
  1235. {
  1236. return null;
  1237. //throw new System.NotImplementedException();
  1238. }
  1239. public void SetClientInfo(ClientInfo info)
  1240. {
  1241. //throw new System.NotImplementedException();
  1242. }
  1243. public void SetClientOption(string option, string value)
  1244. {
  1245. // Need to translate to MXP somehow
  1246. }
  1247. public string GetClientOption(string option)
  1248. {
  1249. // Need to translate to MXP somehow
  1250. return "";
  1251. }
  1252. public void Terminate()
  1253. {
  1254. Close();
  1255. }
  1256. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  1257. {
  1258. // Need to translate to MXP somehow
  1259. }
  1260. public void SendClearFollowCamProperties(UUID objectID)
  1261. {
  1262. // Need to translate to MXP somehow
  1263. }
  1264. public void SendRegionHandle(UUID regoinID, ulong handle)
  1265. {
  1266. // Need to translate to MXP somehow
  1267. }
  1268. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  1269. {
  1270. // Need to translate to MXP somehow
  1271. }
  1272. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  1273. {
  1274. // Need to translate to MXP somehow
  1275. }
  1276. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  1277. {
  1278. // Need to translate to MXP somehow
  1279. }
  1280. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  1281. {
  1282. // Need to translate to MXP somehow
  1283. }
  1284. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  1285. {
  1286. // Need to translate to MXP somehow
  1287. }
  1288. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  1289. {
  1290. // Need to translate to MXP somehow
  1291. }
  1292. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  1293. {
  1294. // Need to translate to MXP somehow
  1295. }
  1296. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  1297. {
  1298. // Need to translate to MXP somehow
  1299. }
  1300. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  1301. {
  1302. // Need to translate to MXP somehow
  1303. }
  1304. public void SendEventInfoReply(EventData info)
  1305. {
  1306. // Need to translate to MXP somehow
  1307. }
  1308. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  1309. {
  1310. // Need to translate to MXP somehow
  1311. }
  1312. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  1313. {
  1314. // Need to translate to MXP somehow
  1315. }
  1316. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  1317. {
  1318. // Need to translate to MXP somehow
  1319. }
  1320. public void SendAcceptCallingCard(UUID transactionID)
  1321. {
  1322. // Need to translate to MXP somehow
  1323. }
  1324. public void SendDeclineCallingCard(UUID transactionID)
  1325. {
  1326. // Need to translate to MXP somehow
  1327. }
  1328. public void SendTerminateFriend(UUID exFriendID)
  1329. {
  1330. // Need to translate to MXP somehow
  1331. }
  1332. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  1333. {
  1334. // Need to translate to MXP somehow
  1335. }
  1336. public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price)
  1337. {
  1338. // Need to translate to MXP somehow
  1339. }
  1340. public void SendAgentDropGroup(UUID groupID)
  1341. {
  1342. // Need to translate to MXP somehow
  1343. }
  1344. public void SendAvatarNotesReply(UUID targetID, string text)
  1345. {
  1346. // Need to translate to MXP somehow
  1347. }
  1348. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  1349. {
  1350. // Need to translate to MXP somehow
  1351. }
  1352. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  1353. {
  1354. // Need to translate to MXP somehow
  1355. }
  1356. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  1357. {
  1358. // Need to translate to MXP somehow
  1359. }
  1360. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  1361. {
  1362. // Need to translate to MXP somehow
  1363. }
  1364. public void KillEndDone()
  1365. {
  1366. Stop();
  1367. }
  1368. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  1369. {
  1370. // Need to translate to MXP somehow
  1371. return true;
  1372. }
  1373. #endregion
  1374. #region IClientCore
  1375. public bool TryGet<T>(out T iface)
  1376. {
  1377. iface = default(T);
  1378. return false;
  1379. }
  1380. public T Get<T>()
  1381. {
  1382. return default(T);
  1383. }
  1384. public void Disconnect(string reason)
  1385. {
  1386. Kick(reason);
  1387. Close();
  1388. }
  1389. public void Disconnect()
  1390. {
  1391. Close();
  1392. }
  1393. #endregion
  1394. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  1395. {
  1396. }
  1397. public void RefreshGroupMembership()
  1398. {
  1399. }
  1400. public void SendUseCachedMuteList()
  1401. {
  1402. }
  1403. public void SendMuteListUpdate(string filename)
  1404. {
  1405. }
  1406. public void SendPickInfoReply(UUID pickID,UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled)
  1407. {
  1408. }
  1409. public void SendRebakeAvatarTextures(UUID textureID)
  1410. {
  1411. }
  1412. public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
  1413. {
  1414. }
  1415. public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
  1416. {
  1417. }
  1418. public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
  1419. {
  1420. }
  1421. public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt)
  1422. {
  1423. }
  1424. public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
  1425. {
  1426. }
  1427. public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
  1428. {
  1429. }
  1430. }
  1431. }