MXPClientView.cs 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658
  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 MoneyTransferRequest OnMoneyTransferRequest;
  594. public event EconomyDataRequest OnEconomyDataRequest;
  595. public event MoneyBalanceRequest OnMoneyBalanceRequest;
  596. public event UpdateAvatarProperties OnUpdateAvatarProperties;
  597. public event ParcelBuy OnParcelBuy;
  598. public event RequestPayPrice OnRequestPayPrice;
  599. public event ObjectSaleInfo OnObjectSaleInfo;
  600. public event ObjectBuy OnObjectBuy;
  601. public event BuyObjectInventory OnBuyObjectInventory;
  602. public event RequestTerrain OnRequestTerrain;
  603. public event RequestTerrain OnUploadTerrain;
  604. public event ObjectIncludeInSearch OnObjectIncludeInSearch;
  605. public event UUIDNameRequest OnTeleportHomeRequest;
  606. public event ScriptAnswer OnScriptAnswer;
  607. public event AgentSit OnUndo;
  608. public event ForceReleaseControls OnForceReleaseControls;
  609. public event GodLandStatRequest OnLandStatRequest;
  610. public event DetailedEstateDataRequest OnDetailedEstateDataRequest;
  611. public event SetEstateFlagsRequest OnSetEstateFlagsRequest;
  612. public event SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture;
  613. public event SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture;
  614. public event SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights;
  615. public event CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest;
  616. public event SetRegionTerrainSettings OnSetRegionTerrainSettings;
  617. public event EstateRestartSimRequest OnEstateRestartSimRequest;
  618. public event EstateChangeCovenantRequest OnEstateChangeCovenantRequest;
  619. public event UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest;
  620. public event SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest;
  621. public event EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest;
  622. public event EstateDebugRegionRequest OnEstateDebugRegionRequest;
  623. public event EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest;
  624. public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
  625. public event UUIDNameRequest OnUUIDGroupNameRequest;
  626. public event RegionHandleRequest OnRegionHandleRequest;
  627. public event ParcelInfoRequest OnParcelInfoRequest;
  628. public event RequestObjectPropertiesFamily OnObjectGroupRequest;
  629. public event ScriptReset OnScriptReset;
  630. public event GetScriptRunning OnGetScriptRunning;
  631. public event SetScriptRunning OnSetScriptRunning;
  632. public event UpdateVector OnAutoPilotGo;
  633. public event TerrainUnacked OnUnackedTerrain;
  634. public event ActivateGesture OnActivateGesture;
  635. public event DeactivateGesture OnDeactivateGesture;
  636. public event ObjectOwner OnObjectOwner;
  637. public event DirPlacesQuery OnDirPlacesQuery;
  638. public event DirFindQuery OnDirFindQuery;
  639. public event DirLandQuery OnDirLandQuery;
  640. public event DirPopularQuery OnDirPopularQuery;
  641. public event DirClassifiedQuery OnDirClassifiedQuery;
  642. public event EventInfoRequest OnEventInfoRequest;
  643. public event ParcelSetOtherCleanTime OnParcelSetOtherCleanTime;
  644. public event MapItemRequest OnMapItemRequest;
  645. public event OfferCallingCard OnOfferCallingCard;
  646. public event AcceptCallingCard OnAcceptCallingCard;
  647. public event DeclineCallingCard OnDeclineCallingCard;
  648. public event SoundTrigger OnSoundTrigger;
  649. public event StartLure OnStartLure;
  650. public event TeleportLureRequest OnTeleportLureRequest;
  651. public event NetworkStats OnNetworkStatsUpdate;
  652. public event ClassifiedInfoRequest OnClassifiedInfoRequest;
  653. public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
  654. public event ClassifiedDelete OnClassifiedDelete;
  655. public event ClassifiedDelete OnClassifiedGodDelete;
  656. public event EventNotificationAddRequest OnEventNotificationAddRequest;
  657. public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
  658. public event EventGodDelete OnEventGodDelete;
  659. public event ParcelDwellRequest OnParcelDwellRequest;
  660. public event UserInfoRequest OnUserInfoRequest;
  661. public event UpdateUserInfo OnUpdateUserInfo;
  662. public event ViewerEffectEventHandler OnViewerEffect;
  663. public event Action<IClientAPI> OnLogout;
  664. public event Action<IClientAPI> OnConnectionClosed;
  665. public event RetrieveInstantMessages OnRetrieveInstantMessages;
  666. public event PickDelete OnPickDelete;
  667. public event PickGodDelete OnPickGodDelete;
  668. public event PickInfoUpdate OnPickInfoUpdate;
  669. public event AvatarNotesUpdate OnAvatarNotesUpdate;
  670. public event MuteListRequest OnMuteListRequest;
  671. public event AvatarInterestUpdate OnAvatarInterestUpdate;
  672. public event PlacesQuery OnPlacesQuery;
  673. #pragma warning restore 67
  674. #endregion
  675. #region OpenSim ClientView Public Methods
  676. // Do we need this?
  677. public bool SendLogoutPacketWhenClosing
  678. {
  679. set { }
  680. }
  681. public uint CircuitCode
  682. {
  683. get { return m_sessionID.CRC(); }
  684. }
  685. public IPEndPoint RemoteEndPoint
  686. {
  687. get { return Session.RemoteEndPoint; }
  688. }
  689. public void SetDebugPacketLevel(int newDebug)
  690. {
  691. //m_debugLevel = newDebug;
  692. }
  693. public void InPacket(object NewPack)
  694. {
  695. //throw new System.NotImplementedException();
  696. }
  697. public void ProcessInPacket(Packet NewPack)
  698. {
  699. //throw new System.NotImplementedException();
  700. }
  701. public void OnClean()
  702. {
  703. if (OnLogout != null)
  704. OnLogout(this);
  705. if (OnConnectionClosed != null)
  706. OnConnectionClosed(this);
  707. }
  708. public void Close()
  709. {
  710. m_log.Info("[MXP ClientStack] Close Called");
  711. // Tell the client to go
  712. SendLogoutPacket();
  713. // Let MXPPacketServer clean it up
  714. if (Session.SessionState != SessionState.Disconnected)
  715. {
  716. Session.SetStateDisconnected();
  717. }
  718. }
  719. public void Kick(string message)
  720. {
  721. Close();
  722. }
  723. public void Start()
  724. {
  725. Scene.AddNewClient(this);
  726. // Mimicking LLClientView which gets always set appearance from client.
  727. OpenSim.Region.Framework.Scenes.Scene scene=(OpenSim.Region.Framework.Scenes.Scene)Scene;
  728. AvatarAppearance appearance;
  729. scene.GetAvatarAppearance(this,out appearance);
  730. OnSetAppearance(appearance.Texture, (byte[])appearance.VisualParams.Clone());
  731. }
  732. public void Stop()
  733. {
  734. // Nor this
  735. }
  736. public void SendWearables(AvatarWearable[] wearables, int serial)
  737. {
  738. // Need to translate to MXP somehow
  739. }
  740. public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
  741. {
  742. // Need to translate to MXP somehow
  743. }
  744. public void SendStartPingCheck(byte seq)
  745. {
  746. // Need to translate to MXP somehow
  747. }
  748. public void SendKillObject(ulong regionHandle, uint localID)
  749. {
  750. DisappearanceEventMessage de = new DisappearanceEventMessage();
  751. de.ObjectIndex = localID;
  752. Session.Send(de);
  753. }
  754. public void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
  755. {
  756. // Need to translate to MXP somehow
  757. }
  758. public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
  759. {
  760. m_log.Info("[MXP ClientStack] Completing Handshake to Region");
  761. if (OnRegionHandShakeReply != null)
  762. {
  763. OnRegionHandShakeReply(this);
  764. }
  765. if (OnCompleteMovementToRegion != null)
  766. {
  767. OnCompleteMovementToRegion();
  768. }
  769. // Need to translate to MXP somehow
  770. }
  771. public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, byte audible)
  772. {
  773. ActionEventMessage chatActionEvent = new ActionEventMessage();
  774. chatActionEvent.ActionFragment.ActionName = "Chat";
  775. chatActionEvent.ActionFragment.SourceObjectId = fromAgentID.Guid;
  776. chatActionEvent.ActionFragment.ObservationRadius = 180.0f;
  777. chatActionEvent.ActionFragment.ExtensionDialect = "TEXT";
  778. chatActionEvent.SetPayloadData(Util.UTF8.GetBytes(message));
  779. Session.Send(chatActionEvent);
  780. }
  781. public void SendInstantMessage(GridInstantMessage im)
  782. {
  783. // Need to translate to MXP somehow
  784. }
  785. public void SendGenericMessage(string method, List<string> message)
  786. {
  787. // Need to translate to MXP somehow
  788. }
  789. public void SendLayerData(float[] map)
  790. {
  791. MXPSendTerrain(map);
  792. }
  793. public void SendLayerData(int px, int py, float[] map)
  794. {
  795. }
  796. public void SendWindData(Vector2[] windSpeeds)
  797. {
  798. // Need to translate to MXP somehow
  799. }
  800. public void SendCloudData(float[] cloudCover)
  801. {
  802. // Need to translate to MXP somehow
  803. }
  804. public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
  805. {
  806. //throw new System.NotImplementedException();
  807. }
  808. public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
  809. {
  810. //throw new System.NotImplementedException();
  811. }
  812. public AgentCircuitData RequestClientInfo()
  813. {
  814. AgentCircuitData clientinfo = new AgentCircuitData();
  815. clientinfo.AgentID = AgentId;
  816. clientinfo.Appearance = new AvatarAppearance();
  817. clientinfo.BaseFolder = UUID.Zero;
  818. clientinfo.CapsPath = "";
  819. clientinfo.child = false;
  820. clientinfo.ChildrenCapSeeds = new Dictionary<ulong, string>();
  821. clientinfo.circuitcode = CircuitCode;
  822. clientinfo.firstname = FirstName;
  823. clientinfo.InventoryFolder = UUID.Zero;
  824. clientinfo.lastname = LastName;
  825. clientinfo.SecureSessionID = SecureSessionId;
  826. clientinfo.SessionID = SessionId;
  827. clientinfo.startpos = StartPos;
  828. return clientinfo;
  829. }
  830. public void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL)
  831. {
  832. // TODO: We'll want to get this one working.
  833. // Need to translate to MXP somehow
  834. }
  835. public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
  836. {
  837. // Need to translate to MXP somehow
  838. }
  839. public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
  840. {
  841. //throw new System.NotImplementedException();
  842. }
  843. public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL)
  844. {
  845. // Need to translate to MXP somehow
  846. }
  847. public void SendTeleportFailed(string reason)
  848. {
  849. // Need to translate to MXP somehow
  850. }
  851. public void SendTeleportLocationStart()
  852. {
  853. // Need to translate to MXP somehow
  854. }
  855. public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance)
  856. {
  857. // Need to translate to MXP somehow
  858. }
  859. public void SendPayPrice(UUID objectID, int[] payPrice)
  860. {
  861. // Need to translate to MXP somehow
  862. }
  863. public void SendAvatarData(SendAvatarData data)
  864. {
  865. //ScenePresence presence=((Scene)this.Scene).GetScenePresence(avatarID);
  866. UUID ownerID = data.AvatarID;
  867. MXPSendAvatarData(data.FirstName + " " + data.LastName, ownerID, UUID.Zero, data.AvatarID, data.AvatarLocalID, data.Position, data.Rotation);
  868. }
  869. public void SendAvatarTerseUpdate(SendAvatarTerseData data)
  870. {
  871. MovementEventMessage me = new MovementEventMessage();
  872. me.ObjectIndex = data.LocalID;
  873. me.Location = ToOmVector(data.Position);
  874. me.Orientation = ToOmQuaternion(data.Rotation);
  875. Session.Send(me);
  876. }
  877. public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
  878. {
  879. // Minimap function, not used.
  880. }
  881. public void AttachObject(uint localID, Quaternion rotation, byte attachPoint, UUID ownerID)
  882. {
  883. // Need to translate to MXP somehow
  884. }
  885. public void SetChildAgentThrottle(byte[] throttle)
  886. {
  887. // Need to translate to MXP somehow
  888. }
  889. public void SendPrimitiveToClient(SendPrimitiveData data)
  890. {
  891. MXPSendPrimitive(data.localID, data.ownerID, data.acc, data.rvel, data.primShape, data.pos, data.objectID, data.vel,
  892. data.rotation, (uint)data.flags, data.text, data.color, data.parentID, data.particleSystem, data.clickAction,
  893. data.material, data.textureanim);
  894. }
  895. public void SendPrimTerseUpdate(SendPrimitiveTerseData data)
  896. {
  897. MovementEventMessage me = new MovementEventMessage();
  898. me.ObjectIndex = data.LocalID;
  899. me.Location = ToOmVector(data.Position);
  900. me.Orientation = ToOmQuaternion(data.Rotation);
  901. Session.Send(me);
  902. }
  903. public void ReprioritizeUpdates(StateUpdateTypes type, UpdatePriorityHandler handler)
  904. {
  905. }
  906. public void FlushPrimUpdates()
  907. {
  908. }
  909. public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, bool fetchFolders, bool fetchItems)
  910. {
  911. // Need to translate to MXP somehow
  912. }
  913. public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
  914. {
  915. // Need to translate to MXP somehow
  916. }
  917. public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
  918. {
  919. // Need to translate to MXP somehow
  920. }
  921. public void SendRemoveInventoryItem(UUID itemID)
  922. {
  923. // Need to translate to MXP somehow
  924. }
  925. public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
  926. {
  927. // Need to translate to MXP somehow
  928. }
  929. public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
  930. {
  931. // Need to translate to MXP somehow
  932. }
  933. public void SendBulkUpdateInventory(InventoryNodeBase node)
  934. {
  935. // Need to translate to MXP somehow
  936. }
  937. public void SendXferPacket(ulong xferID, uint packet, byte[] data)
  938. {
  939. // SL Specific, Ignore. (Remove from IClient)
  940. }
  941. 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)
  942. {
  943. // SL Specific, Ignore. (Remove from IClient)
  944. }
  945. public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
  946. {
  947. // Need to translate to MXP somehow
  948. }
  949. public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
  950. {
  951. // Need to translate to MXP somehow
  952. // TODO: This may need doing - involves displaying the users avatar name
  953. }
  954. public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
  955. {
  956. // Need to translate to MXP somehow
  957. }
  958. public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
  959. {
  960. // Need to translate to MXP somehow
  961. }
  962. public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
  963. {
  964. // Need to translate to MXP somehow
  965. }
  966. public void SendAttachedSoundGainChange(UUID objectID, float gain)
  967. {
  968. // Need to translate to MXP somehow
  969. }
  970. public void SendNameReply(UUID profileId, string firstname, string lastname)
  971. {
  972. // SL Specific
  973. }
  974. public void SendAlertMessage(string message)
  975. {
  976. SendChatMessage(message, 0, Vector3.Zero, "System", UUID.Zero, 0, 0);
  977. }
  978. public void SendAgentAlertMessage(string message, bool modal)
  979. {
  980. SendChatMessage(message, 0, Vector3.Zero, "System" + (modal ? " Notice" : ""), UUID.Zero, 0, 0);
  981. }
  982. public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url)
  983. {
  984. // TODO: Probably can do this better
  985. SendChatMessage("Please visit: " + url, 0, Vector3.Zero, objectname, UUID.Zero, 0, 0);
  986. }
  987. public void SendDialog(string objectname, UUID objectID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels)
  988. {
  989. // TODO: Probably can do this better
  990. SendChatMessage("Dialog: " + msg, 0, Vector3.Zero, objectname, UUID.Zero, 0, 0);
  991. }
  992. public bool AddMoney(int debit)
  993. {
  994. SendChatMessage("You were paid: " + debit, 0, Vector3.Zero, "System", UUID.Zero, 0, 0);
  995. return true;
  996. }
  997. public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
  998. {
  999. // Need to translate to MXP somehow
  1000. // Send a light object?
  1001. }
  1002. public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
  1003. {
  1004. // Need to translate to MXP somehow
  1005. }
  1006. public void SendViewerTime(int phase)
  1007. {
  1008. // Need to translate to MXP somehow
  1009. }
  1010. public UUID GetDefaultAnimation(string name)
  1011. {
  1012. return UUID.Zero;
  1013. }
  1014. public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] charterMember, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID)
  1015. {
  1016. // Need to translate to MXP somehow
  1017. }
  1018. public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
  1019. {
  1020. // Need to translate to MXP somehow
  1021. }
  1022. public void SendHealth(float health)
  1023. {
  1024. // Need to translate to MXP somehow
  1025. }
  1026. public void SendEstateManagersList(UUID invoice, UUID[] EstateManagers, uint estateID)
  1027. {
  1028. // Need to translate to MXP somehow
  1029. }
  1030. public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID)
  1031. {
  1032. // Need to translate to MXP somehow
  1033. }
  1034. public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
  1035. {
  1036. // Need to translate to MXP somehow
  1037. }
  1038. public void SendEstateCovenantInformation(UUID covenant)
  1039. {
  1040. // Need to translate to MXP somehow
  1041. }
  1042. public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner)
  1043. {
  1044. // Need to translate to MXP somehow
  1045. }
  1046. public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
  1047. {
  1048. // Need to translate to MXP somehow
  1049. }
  1050. public void SendLandAccessListData(List<UUID> avatars, uint accessFlag, int localLandID)
  1051. {
  1052. // Need to translate to MXP somehow
  1053. }
  1054. public void SendForceClientSelectObjects(List<uint> objectIDs)
  1055. {
  1056. // Need to translate to MXP somehow
  1057. }
  1058. public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
  1059. {
  1060. // Need to translate to MXP somehow
  1061. }
  1062. public void SendCameraConstraint(Vector4 ConstraintPlane)
  1063. {
  1064. }
  1065. public void SendLandParcelOverlay(byte[] data, int sequence_id)
  1066. {
  1067. // Need to translate to MXP somehow
  1068. }
  1069. public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
  1070. {
  1071. // Need to translate to MXP somehow
  1072. }
  1073. public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight, byte mediaLoop)
  1074. {
  1075. // Need to translate to MXP somehow
  1076. }
  1077. public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
  1078. {
  1079. // Need to translate to MXP somehow
  1080. }
  1081. public void SendConfirmXfer(ulong xferID, uint PacketID)
  1082. {
  1083. // Need to translate to MXP somehow
  1084. }
  1085. public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
  1086. {
  1087. // Need to translate to MXP somehow
  1088. }
  1089. public void SendInitiateDownload(string simFileName, string clientFileName)
  1090. {
  1091. // Need to translate to MXP somehow
  1092. }
  1093. public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
  1094. {
  1095. // Need to translate to MXP somehow
  1096. }
  1097. public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
  1098. {
  1099. // Need to translate to MXP somehow
  1100. }
  1101. public void SendImageNotFound(UUID imageid)
  1102. {
  1103. // Need to translate to MXP somehow
  1104. }
  1105. public void SendShutdownConnectionNotice()
  1106. {
  1107. // Need to translate to MXP somehow
  1108. }
  1109. public void SendSimStats(SimStats stats)
  1110. {
  1111. // Need to translate to MXP somehow
  1112. }
  1113. 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)
  1114. {
  1115. //throw new System.NotImplementedException();
  1116. }
  1117. 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)
  1118. {
  1119. //throw new System.NotImplementedException();
  1120. }
  1121. public void SendAgentOffline(UUID[] agentIDs)
  1122. {
  1123. // Need to translate to MXP somehow (Friends List)
  1124. }
  1125. public void SendAgentOnline(UUID[] agentIDs)
  1126. {
  1127. // Need to translate to MXP somehow (Friends List)
  1128. }
  1129. public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
  1130. {
  1131. // Need to translate to MXP somehow
  1132. }
  1133. public void SendAdminResponse(UUID Token, uint AdminLevel)
  1134. {
  1135. // Need to translate to MXP somehow
  1136. }
  1137. public void SendGroupMembership(GroupMembershipData[] GroupMembership)
  1138. {
  1139. // Need to translate to MXP somehow
  1140. }
  1141. public void SendGroupNameReply(UUID groupLLUID, string GroupName)
  1142. {
  1143. // Need to translate to MXP somehow
  1144. }
  1145. public void SendJoinGroupReply(UUID groupID, bool success)
  1146. {
  1147. // Need to translate to MXP somehow
  1148. }
  1149. public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
  1150. {
  1151. // Need to translate to MXP somehow
  1152. }
  1153. public void SendLeaveGroupReply(UUID groupID, bool success)
  1154. {
  1155. // Need to translate to MXP somehow
  1156. }
  1157. public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
  1158. {
  1159. // Need to translate to MXP somehow
  1160. }
  1161. public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
  1162. {
  1163. // Need to translate to MXP somehow
  1164. }
  1165. public void SendAsset(AssetRequestToClient req)
  1166. {
  1167. // Need to translate to MXP somehow
  1168. }
  1169. public void SendTexture(AssetBase TextureAsset)
  1170. {
  1171. // Need to translate to MXP somehow
  1172. }
  1173. public byte[] GetThrottlesPacked(float multiplier)
  1174. {
  1175. // LL Specific, get out of IClientAPI
  1176. const int singlefloat = 4;
  1177. float tResend = multiplier;
  1178. float tLand = multiplier;
  1179. float tWind = multiplier;
  1180. float tCloud = multiplier;
  1181. float tTask = multiplier;
  1182. float tTexture = multiplier;
  1183. float tAsset = multiplier;
  1184. byte[] throttles = new byte[singlefloat * 7];
  1185. int i = 0;
  1186. Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat * i, singlefloat);
  1187. i++;
  1188. Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat * i, singlefloat);
  1189. i++;
  1190. Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat * i, singlefloat);
  1191. i++;
  1192. Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat * i, singlefloat);
  1193. i++;
  1194. Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat * i, singlefloat);
  1195. i++;
  1196. Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat * i, singlefloat);
  1197. i++;
  1198. Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat * i, singlefloat);
  1199. return throttles;
  1200. }
  1201. public void SendBlueBoxMessage(UUID FromAvatarID, string FromAvatarName, string Message)
  1202. {
  1203. SendChatMessage(Message, 0, Vector3.Zero, FromAvatarName, UUID.Zero, 0, 0);
  1204. }
  1205. public void SendLogoutPacket()
  1206. {
  1207. LeaveRequestMessage lrm = new LeaveRequestMessage();
  1208. Session.Send(lrm);
  1209. }
  1210. public EndPoint GetClientEP()
  1211. {
  1212. return null;
  1213. }
  1214. public ClientInfo GetClientInfo()
  1215. {
  1216. return null;
  1217. //throw new System.NotImplementedException();
  1218. }
  1219. public void SetClientInfo(ClientInfo info)
  1220. {
  1221. //throw new System.NotImplementedException();
  1222. }
  1223. public void SetClientOption(string option, string value)
  1224. {
  1225. // Need to translate to MXP somehow
  1226. }
  1227. public string GetClientOption(string option)
  1228. {
  1229. // Need to translate to MXP somehow
  1230. return "";
  1231. }
  1232. public void Terminate()
  1233. {
  1234. Close();
  1235. }
  1236. public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
  1237. {
  1238. // Need to translate to MXP somehow
  1239. }
  1240. public void SendClearFollowCamProperties(UUID objectID)
  1241. {
  1242. // Need to translate to MXP somehow
  1243. }
  1244. public void SendRegionHandle(UUID regoinID, ulong handle)
  1245. {
  1246. // Need to translate to MXP somehow
  1247. }
  1248. public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
  1249. {
  1250. // Need to translate to MXP somehow
  1251. }
  1252. public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
  1253. {
  1254. // Need to translate to MXP somehow
  1255. }
  1256. public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
  1257. {
  1258. // Need to translate to MXP somehow
  1259. }
  1260. public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
  1261. {
  1262. // Need to translate to MXP somehow
  1263. }
  1264. public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
  1265. {
  1266. // Need to translate to MXP somehow
  1267. }
  1268. public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
  1269. {
  1270. // Need to translate to MXP somehow
  1271. }
  1272. public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
  1273. {
  1274. // Need to translate to MXP somehow
  1275. }
  1276. public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
  1277. {
  1278. // Need to translate to MXP somehow
  1279. }
  1280. public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
  1281. {
  1282. // Need to translate to MXP somehow
  1283. }
  1284. public void SendEventInfoReply(EventData info)
  1285. {
  1286. // Need to translate to MXP somehow
  1287. }
  1288. public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
  1289. {
  1290. // Need to translate to MXP somehow
  1291. }
  1292. public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
  1293. {
  1294. // Need to translate to MXP somehow
  1295. }
  1296. public void SendOfferCallingCard(UUID srcID, UUID transactionID)
  1297. {
  1298. // Need to translate to MXP somehow
  1299. }
  1300. public void SendAcceptCallingCard(UUID transactionID)
  1301. {
  1302. // Need to translate to MXP somehow
  1303. }
  1304. public void SendDeclineCallingCard(UUID transactionID)
  1305. {
  1306. // Need to translate to MXP somehow
  1307. }
  1308. public void SendTerminateFriend(UUID exFriendID)
  1309. {
  1310. // Need to translate to MXP somehow
  1311. }
  1312. public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
  1313. {
  1314. // Need to translate to MXP somehow
  1315. }
  1316. 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)
  1317. {
  1318. // Need to translate to MXP somehow
  1319. }
  1320. public void SendAgentDropGroup(UUID groupID)
  1321. {
  1322. // Need to translate to MXP somehow
  1323. }
  1324. public void SendAvatarNotesReply(UUID targetID, string text)
  1325. {
  1326. // Need to translate to MXP somehow
  1327. }
  1328. public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
  1329. {
  1330. // Need to translate to MXP somehow
  1331. }
  1332. public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
  1333. {
  1334. // Need to translate to MXP somehow
  1335. }
  1336. public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
  1337. {
  1338. // Need to translate to MXP somehow
  1339. }
  1340. public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
  1341. {
  1342. // Need to translate to MXP somehow
  1343. }
  1344. public void KillEndDone()
  1345. {
  1346. Stop();
  1347. }
  1348. public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
  1349. {
  1350. // Need to translate to MXP somehow
  1351. return true;
  1352. }
  1353. #endregion
  1354. #region IClientCore
  1355. public bool TryGet<T>(out T iface)
  1356. {
  1357. iface = default(T);
  1358. return false;
  1359. }
  1360. public T Get<T>()
  1361. {
  1362. return default(T);
  1363. }
  1364. public void Disconnect(string reason)
  1365. {
  1366. Kick(reason);
  1367. Close();
  1368. }
  1369. public void Disconnect()
  1370. {
  1371. Close();
  1372. }
  1373. #endregion
  1374. public void SendCreateGroupReply(UUID groupID, bool success, string message)
  1375. {
  1376. }
  1377. public void RefreshGroupMembership()
  1378. {
  1379. }
  1380. public void SendUseCachedMuteList()
  1381. {
  1382. }
  1383. public void SendMuteListUpdate(string filename)
  1384. {
  1385. }
  1386. 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)
  1387. {
  1388. }
  1389. public void SendRebakeAvatarTextures(UUID textureID)
  1390. {
  1391. }
  1392. }
  1393. }