ClientView.API.cs 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122
  1. /*
  2. * Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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. */
  28. using System;
  29. using System.Collections.Generic;
  30. using System.Net;
  31. using System.Text;
  32. using Axiom.Math;
  33. using libsecondlife;
  34. using libsecondlife.Packets;
  35. using OpenSim.Framework.Console;
  36. using OpenSim.Framework.Interfaces;
  37. using OpenSim.Framework.Types;
  38. namespace OpenSim.Region.ClientStack
  39. {
  40. partial class ClientView
  41. {
  42. public event ImprovedInstantMessage OnInstantMessage;
  43. public event ChatFromViewer OnChatFromViewer;
  44. public event RezObject OnRezObject;
  45. public event GenericCall4 OnDeRezObject;
  46. public event ModifyTerrain OnModifyTerrain;
  47. public event GenericCall OnRegionHandShakeReply;
  48. public event GenericCall OnRequestWearables;
  49. public event SetAppearance OnSetAppearance;
  50. public event GenericCall2 OnCompleteMovementToRegion;
  51. public event UpdateAgent OnAgentUpdate;
  52. public event StartAnim OnStartAnim;
  53. public event GenericCall OnRequestAvatarsData;
  54. public event LinkObjects OnLinkObjects;
  55. public event UpdateVector OnGrapObject;
  56. public event ObjectSelect OnDeGrapObject;
  57. public event ObjectDuplicate OnObjectDuplicate;
  58. public event MoveObject OnGrapUpdate;
  59. public event GenericCall4 OnAddPrim;
  60. public event UpdateShape OnUpdatePrimShape;
  61. public event ObjectSelect OnObjectSelect;
  62. public event GenericCall7 OnObjectDescription;
  63. public event GenericCall7 OnObjectName;
  64. public event UpdatePrimFlags OnUpdatePrimFlags;
  65. public event UpdatePrimTexture OnUpdatePrimTexture;
  66. public event UpdateVector OnUpdatePrimGroupPosition;
  67. public event UpdateVector OnUpdatePrimSinglePosition;
  68. public event UpdatePrimRotation OnUpdatePrimGroupRotation;
  69. public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
  70. public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
  71. public event UpdateVector OnUpdatePrimScale;
  72. public event StatusChange OnChildAgentStatus;
  73. public event GenericCall2 OnStopMovement;
  74. public event NewAvatar OnNewAvatar;
  75. public event GenericCall6 OnRemoveAvatar;
  76. public event RequestMapBlocks OnRequestMapBlocks;
  77. public event TeleportLocationRequest OnTeleportLocationRequest;
  78. public event UUIDNameRequest OnNameFromUUIDRequest;
  79. public event ParcelPropertiesRequest OnParcelPropertiesRequest;
  80. public event ParcelDivideRequest OnParcelDivideRequest;
  81. public event ParcelJoinRequest OnParcelJoinRequest;
  82. public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
  83. public event EstateOwnerMessageRequest OnEstateOwnerMessage;
  84. /// <summary>
  85. ///
  86. /// </summary>
  87. public LLVector3 StartPos
  88. {
  89. get
  90. {
  91. return startpos;
  92. }
  93. set
  94. {
  95. startpos = value;
  96. }
  97. }
  98. /// <summary>
  99. ///
  100. /// </summary>
  101. public LLUUID AgentId
  102. {
  103. get
  104. {
  105. return this.AgentID;
  106. }
  107. }
  108. /// <summary>
  109. ///
  110. /// </summary>
  111. public string FirstName
  112. {
  113. get
  114. {
  115. return this.firstName;
  116. }
  117. }
  118. /// <summary>
  119. ///
  120. /// </summary>
  121. public string LastName
  122. {
  123. get
  124. {
  125. return this.lastName;
  126. }
  127. }
  128. #region World/Avatar to Client
  129. /// <summary>
  130. ///
  131. /// </summary>
  132. /// <param name="regionInfo"></param>
  133. public void SendRegionHandshake(RegionInfo regionInfo)
  134. {
  135. Encoding _enc = Encoding.ASCII;
  136. RegionHandshakePacket handshake = new RegionHandshakePacket();
  137. handshake.RegionInfo.BillableFactor = regionInfo.estateSettings.billableFactor;
  138. handshake.RegionInfo.IsEstateManager = false;
  139. handshake.RegionInfo.TerrainHeightRange00 = regionInfo.estateSettings.terrainHeightRange0;
  140. handshake.RegionInfo.TerrainHeightRange01 = regionInfo.estateSettings.terrainHeightRange1;
  141. handshake.RegionInfo.TerrainHeightRange10 = regionInfo.estateSettings.terrainHeightRange2;
  142. handshake.RegionInfo.TerrainHeightRange11 = regionInfo.estateSettings.terrainHeightRange3;
  143. handshake.RegionInfo.TerrainStartHeight00 = regionInfo.estateSettings.terrainStartHeight0;
  144. handshake.RegionInfo.TerrainStartHeight01 = regionInfo.estateSettings.terrainStartHeight1;
  145. handshake.RegionInfo.TerrainStartHeight10 = regionInfo.estateSettings.terrainStartHeight2;
  146. handshake.RegionInfo.TerrainStartHeight11 = regionInfo.estateSettings.terrainStartHeight3;
  147. handshake.RegionInfo.SimAccess = (byte)regionInfo.estateSettings.simAccess;
  148. handshake.RegionInfo.WaterHeight = regionInfo.estateSettings.waterHeight;
  149. handshake.RegionInfo.RegionFlags = (uint)regionInfo.estateSettings.regionFlags;
  150. handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0");
  151. handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID;
  152. handshake.RegionInfo.TerrainBase0 = regionInfo.estateSettings.terrainBase0;
  153. handshake.RegionInfo.TerrainBase1 = regionInfo.estateSettings.terrainBase1;
  154. handshake.RegionInfo.TerrainBase2 = regionInfo.estateSettings.terrainBase2;
  155. handshake.RegionInfo.TerrainBase3 = regionInfo.estateSettings.terrainBase3;
  156. handshake.RegionInfo.TerrainDetail0 = regionInfo.estateSettings.terrainDetail0;
  157. handshake.RegionInfo.TerrainDetail1 = regionInfo.estateSettings.terrainDetail1;
  158. handshake.RegionInfo.TerrainDetail2 = regionInfo.estateSettings.terrainDetail2;
  159. handshake.RegionInfo.TerrainDetail3 = regionInfo.estateSettings.terrainDetail3;
  160. handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting?
  161. this.OutPacket(handshake);
  162. }
  163. /// <summary>
  164. ///
  165. /// </summary>
  166. /// <param name="regInfo"></param>
  167. public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look)
  168. {
  169. AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
  170. mov.AgentData.SessionID = this.SessionID;
  171. mov.AgentData.AgentID = this.AgentID;
  172. mov.Data.RegionHandle = regInfo.RegionHandle;
  173. mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this
  174. if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
  175. {
  176. mov.Data.Position = this.startpos;
  177. }
  178. else
  179. {
  180. mov.Data.Position = pos;
  181. }
  182. mov.Data.LookAt = look;
  183. OutPacket(mov);
  184. }
  185. /// <summary>
  186. ///
  187. /// </summary>
  188. /// <param name="message"></param>
  189. /// <param name="type"></param>
  190. /// <param name="fromPos"></param>
  191. /// <param name="fromName"></param>
  192. /// <param name="fromAgentID"></param>
  193. public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
  194. {
  195. SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID);
  196. }
  197. /// <summary>
  198. ///
  199. /// </summary>
  200. /// <param name="message"></param>
  201. /// <param name="type"></param>
  202. /// <param name="fromPos"></param>
  203. /// <param name="fromName"></param>
  204. /// <param name="fromAgentID"></param>
  205. public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
  206. {
  207. Encoding enc = Encoding.ASCII;
  208. ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
  209. reply.ChatData.Audible = 1;
  210. reply.ChatData.Message = message;
  211. reply.ChatData.ChatType = type;
  212. reply.ChatData.SourceType = 1;
  213. reply.ChatData.Position = fromPos;
  214. reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
  215. reply.ChatData.OwnerID = fromAgentID;
  216. reply.ChatData.SourceID = fromAgentID;
  217. this.OutPacket(reply);
  218. }
  219. /// <summary>
  220. ///
  221. /// </summary>
  222. /// <remarks>TODO</remarks>
  223. /// <param name="message"></param>
  224. /// <param name="target"></param>
  225. public void SendInstantMessage(string message, LLUUID target)
  226. {
  227. ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket();
  228. msg.AgentData.AgentID = this.AgentID;
  229. msg.AgentData.SessionID = this.SessionID;
  230. msg.MessageBlock.Dialog = 0;
  231. msg.MessageBlock.FromGroup = false;
  232. msg.MessageBlock.ID = target.Combine(this.AgentID);
  233. msg.MessageBlock.Offline = 0;
  234. msg.MessageBlock.ParentEstateID = 0;
  235. msg.MessageBlock.Position = new LLVector3();
  236. msg.MessageBlock.RegionID = new LLUUID();
  237. msg.MessageBlock.Timestamp = 0;
  238. msg.MessageBlock.ToAgentID = target;
  239. this.OutPacket(msg);
  240. }
  241. /// <summary>
  242. /// Send the region heightmap to the client
  243. /// </summary>
  244. /// <param name="map">heightmap</param>
  245. public virtual void SendLayerData(float[] map)
  246. {
  247. try
  248. {
  249. int[] patches = new int[4];
  250. for (int y = 0; y < 16; y++)
  251. {
  252. for (int x = 0; x < 16; x = x + 4)
  253. {
  254. patches[0] = x + 0 + y * 16;
  255. patches[1] = x + 1 + y * 16;
  256. patches[2] = x + 2 + y * 16;
  257. patches[3] = x + 3 + y * 16;
  258. Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
  259. OutPacket(layerpack);
  260. }
  261. }
  262. }
  263. catch (Exception e)
  264. {
  265. MainLog.Instance.Warn("ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString());
  266. }
  267. }
  268. /// <summary>
  269. /// Sends a specified patch to a client
  270. /// </summary>
  271. /// <param name="px">Patch coordinate (x) 0..16</param>
  272. /// <param name="py">Patch coordinate (y) 0..16</param>
  273. /// <param name="map">heightmap</param>
  274. public void SendLayerData(int px, int py, float[] map)
  275. {
  276. try
  277. {
  278. int[] patches = new int[1];
  279. int patchx, patchy;
  280. patchx = px / 16;
  281. patchy = py / 16;
  282. patches[0] = patchx + 0 + patchy * 16;
  283. Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
  284. OutPacket(layerpack);
  285. }
  286. catch (Exception e)
  287. {
  288. MainLog.Instance.Warn("ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString());
  289. }
  290. }
  291. /// <summary>
  292. ///
  293. /// </summary>
  294. /// <param name="neighbourHandle"></param>
  295. /// <param name="neighbourIP"></param>
  296. /// <param name="neighbourPort"></param>
  297. public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint )
  298. {
  299. IPAddress neighbourIP = neighbourEndPoint.Address;
  300. ushort neighbourPort = (ushort) neighbourEndPoint.Port;
  301. EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
  302. enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
  303. enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
  304. byte[] byteIP = neighbourIP.GetAddressBytes();
  305. enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
  306. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
  307. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
  308. enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
  309. enablesimpacket.SimulatorInfo.Port = neighbourPort;
  310. OutPacket(enablesimpacket);
  311. }
  312. /// <summary>
  313. ///
  314. /// </summary>
  315. /// <returns></returns>
  316. public AgentCircuitData RequestClientInfo()
  317. {
  318. AgentCircuitData agentData = new AgentCircuitData();
  319. agentData.AgentID = this.AgentId;
  320. agentData.SessionID = this.SessionID;
  321. agentData.SecureSessionID = this.SecureSessionID;
  322. agentData.circuitcode = this.CircuitCode;
  323. agentData.child = false;
  324. agentData.firstname = this.firstName;
  325. agentData.lastname = this.lastName;
  326. return agentData;
  327. }
  328. public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint)
  329. {
  330. LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
  331. CrossedRegionPacket newSimPack = new CrossedRegionPacket();
  332. newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
  333. newSimPack.AgentData.AgentID = this.AgentID;
  334. newSimPack.AgentData.SessionID = this.SessionID;
  335. newSimPack.Info = new CrossedRegionPacket.InfoBlock();
  336. newSimPack.Info.Position = pos;
  337. newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
  338. newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
  339. newSimPack.RegionData.RegionHandle = newRegionHandle;
  340. byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
  341. newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
  342. newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
  343. newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
  344. newSimPack.RegionData.SimIP += (uint)byteIP[0];
  345. newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
  346. newSimPack.RegionData.SeedCapability = new byte[0];
  347. this.OutPacket(newSimPack);
  348. //this.DowngradeClient();
  349. }
  350. public void SendMapBlock(List<MapBlockData> mapBlocks)
  351. {
  352. Encoding _enc = Encoding.ASCII;
  353. MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
  354. mapReply.AgentData.AgentID = this.AgentID;
  355. mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count];
  356. mapReply.AgentData.Flags = 0;
  357. for (int i = 0; i < mapBlocks.Count; i++)
  358. {
  359. mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
  360. mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId;
  361. mapReply.Data[i].X = mapBlocks[i].X;
  362. mapReply.Data[i].Y = mapBlocks[i].Y;
  363. mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight;
  364. mapReply.Data[i].Name = _enc.GetBytes(mapBlocks[i].Name);
  365. mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags;
  366. mapReply.Data[i].Access = mapBlocks[i].Access;
  367. mapReply.Data[i].Agents = mapBlocks[i].Agents;
  368. }
  369. this.OutPacket(mapReply);
  370. }
  371. public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags)
  372. {
  373. TeleportLocalPacket tpLocal = new TeleportLocalPacket();
  374. tpLocal.Info.AgentID = this.AgentID;
  375. tpLocal.Info.TeleportFlags = flags;
  376. tpLocal.Info.LocationID = 2;
  377. tpLocal.Info.LookAt = lookAt;
  378. tpLocal.Info.Position = position;
  379. OutPacket(tpLocal);
  380. }
  381. public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags)
  382. {
  383. TeleportFinishPacket teleport = new TeleportFinishPacket();
  384. teleport.Info.AgentID = this.AgentID;
  385. teleport.Info.RegionHandle = regionHandle;
  386. teleport.Info.SimAccess = simAccess;
  387. teleport.Info.SeedCapability = new byte[0];
  388. IPAddress oIP = newRegionEndPoint.Address;
  389. byte[] byteIP = oIP.GetAddressBytes();
  390. uint ip = (uint)byteIP[3] << 24;
  391. ip += (uint)byteIP[2] << 16;
  392. ip += (uint)byteIP[1] << 8;
  393. ip += (uint)byteIP[0];
  394. teleport.Info.SimIP = ip;
  395. teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
  396. teleport.Info.LocationID = 4;
  397. teleport.Info.TeleportFlags = 1 << 4;
  398. OutPacket(teleport);
  399. }
  400. /// <summary>
  401. ///
  402. /// </summary>
  403. public void SendTeleportCancel()
  404. {
  405. TeleportCancelPacket tpCancel = new TeleportCancelPacket();
  406. tpCancel.Info.SessionID = this.SessionID;
  407. tpCancel.Info.AgentID = this.AgentID;
  408. OutPacket(tpCancel);
  409. }
  410. /// <summary>
  411. ///
  412. /// </summary>
  413. public void SendTeleportLocationStart()
  414. {
  415. TeleportStartPacket tpStart = new TeleportStartPacket();
  416. tpStart.Info.TeleportFlags = 16; // Teleport via location
  417. OutPacket(tpStart);
  418. }
  419. public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance)
  420. {
  421. MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket();
  422. money.MoneyData.AgentID = this.AgentID;
  423. money.MoneyData.TransactionID = transaction;
  424. money.MoneyData.TransactionSuccess = success;
  425. money.MoneyData.Description = description;
  426. money.MoneyData.MoneyBalance = balance;
  427. OutPacket(money);
  428. }
  429. public void SendStartPingCheck(byte seq)
  430. {
  431. StartPingCheckPacket pc = new StartPingCheckPacket();
  432. pc.PingID.PingID = seq;
  433. OutPacket(pc);
  434. }
  435. public void SendKillObject(ulong regionHandle, uint avatarLocalID)
  436. {
  437. KillObjectPacket kill = new KillObjectPacket();
  438. kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
  439. kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
  440. kill.ObjectData[0].ID = avatarLocalID;
  441. OutPacket(kill);
  442. }
  443. #region Appearance/ Wearables Methods
  444. /// <summary>
  445. ///
  446. /// </summary>
  447. /// <param name="wearables"></param>
  448. public void SendWearables(AvatarWearable[] wearables)
  449. {
  450. AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
  451. aw.AgentData.AgentID = this.AgentID;
  452. aw.AgentData.SerialNum = 0;
  453. aw.AgentData.SessionID = this.SessionID;
  454. aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
  455. AgentWearablesUpdatePacket.WearableDataBlock awb;
  456. for (int i = 0; i < wearables.Length; i++)
  457. {
  458. awb = new AgentWearablesUpdatePacket.WearableDataBlock();
  459. awb.WearableType = (byte)i;
  460. awb.AssetID = wearables[i].AssetID;
  461. awb.ItemID = wearables[i].ItemID;
  462. aw.WearableData[i] = awb;
  463. }
  464. this.OutPacket(aw);
  465. }
  466. /// <summary>
  467. ///
  468. /// </summary>
  469. /// <param name="agentID"></param>
  470. /// <param name="visualParams"></param>
  471. /// <param name="textureEntry"></param>
  472. public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry)
  473. {
  474. AvatarAppearancePacket avp = new AvatarAppearancePacket();
  475. avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
  476. avp.ObjectData.TextureEntry = textureEntry;
  477. AvatarAppearancePacket.VisualParamBlock avblock = null;
  478. for (int i = 0; i < visualParams.Length; i++)
  479. {
  480. avblock = new AvatarAppearancePacket.VisualParamBlock();
  481. avblock.ParamValue = visualParams[i];
  482. avp.VisualParam[i] = avblock;
  483. }
  484. avp.Sender.IsTrial = false;
  485. avp.Sender.ID = agentID;
  486. OutPacket(avp);
  487. }
  488. public void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId)
  489. {
  490. AvatarAnimationPacket ani = new AvatarAnimationPacket();
  491. ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
  492. ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
  493. ani.AnimationSourceList[0].ObjectID = sourceAgentId;
  494. ani.Sender = new AvatarAnimationPacket.SenderBlock();
  495. ani.Sender.ID = sourceAgentId;
  496. ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
  497. ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
  498. ani.AnimationList[0].AnimID = animID;
  499. ani.AnimationList[0].AnimSequenceID = seq;
  500. this.OutPacket(ani);
  501. }
  502. #endregion
  503. #region Avatar Packet/data sending Methods
  504. /// <summary>
  505. ///
  506. /// </summary>
  507. /// <param name="regionInfo"></param>
  508. /// <param name="firstName"></param>
  509. /// <param name="lastName"></param>
  510. /// <param name="avatarID"></param>
  511. /// <param name="avatarLocalID"></param>
  512. /// <param name="Pos"></param>
  513. public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry)
  514. {
  515. Encoding _enc = Encoding.ASCII;
  516. //send a objectupdate packet with information about the clients avatar
  517. ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
  518. objupdate.RegionData.RegionHandle = regionHandle;
  519. objupdate.RegionData.TimeDilation = 64096;
  520. objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  521. objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry);
  522. //give this avatar object a local id and assign the user a name
  523. objupdate.ObjectData[0].ID = avatarLocalID;
  524. objupdate.ObjectData[0].FullID = avatarID;
  525. objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName + " \0");
  526. LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z);
  527. byte[] pb = pos2.GetBytes();
  528. Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
  529. OutPacket(objupdate);
  530. }
  531. /// <summary>
  532. ///
  533. /// </summary>
  534. /// <param name="regionHandle"></param>
  535. /// <param name="timeDilation"></param>
  536. /// <param name="localID"></param>
  537. /// <param name="position"></param>
  538. /// <param name="velocity"></param>
  539. public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity)
  540. {
  541. ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity);
  542. ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
  543. terse.RegionData.RegionHandle = regionHandle;
  544. terse.RegionData.TimeDilation = timeDilation;
  545. terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  546. terse.ObjectData[0] = terseBlock;
  547. this.OutPacket(terse);
  548. }
  549. #endregion
  550. #region Primitive Packet/data Sending Methods
  551. /// <summary>
  552. ///
  553. /// </summary>
  554. /// <param name="localID"></param>
  555. /// <param name="rotation"></param>
  556. /// <param name="attachPoint"></param>
  557. public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint)
  558. {
  559. ObjectAttachPacket attach = new ObjectAttachPacket();
  560. attach.AgentData.AgentID = this.AgentID;
  561. attach.AgentData.SessionID = this.SessionID;
  562. attach.AgentData.AttachmentPoint = attachPoint;
  563. attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1];
  564. attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock();
  565. attach.ObjectData[0].ObjectLocalID = localID;
  566. attach.ObjectData[0].Rotation = rotation;
  567. this.OutPacket(attach);
  568. }
  569. /// <summary>
  570. /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
  571. /// or big changes to a existing primitive.
  572. /// </summary>
  573. /// <param name="regionHandle"></param>
  574. /// <param name="timeDilation"></param>
  575. /// <param name="localID"></param>
  576. /// <param name="primData"></param>
  577. /// <param name="pos"></param>
  578. /// <param name="rotation"></param>
  579. /// <param name="textureID"></param>
  580. public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags)
  581. {
  582. ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
  583. outPacket.RegionData.RegionHandle = regionHandle;
  584. outPacket.RegionData.TimeDilation = timeDilation;
  585. outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  586. outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
  587. outPacket.ObjectData[0].ID = localID;
  588. outPacket.ObjectData[0].FullID = primData.FullID;
  589. byte[] pb = pos.GetBytes();
  590. Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
  591. byte[] rot = rotation.GetBytes();
  592. Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length);
  593. OutPacket(outPacket);
  594. }
  595. /// <summary>
  596. /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
  597. /// or big changes to a existing primitive.
  598. /// Uses default rotation
  599. /// </summary>
  600. /// <param name="primData"></param>
  601. /// <param name="pos"></param>
  602. public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID , uint flags)
  603. {
  604. ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
  605. outPacket.RegionData.RegionHandle = regionHandle;
  606. outPacket.RegionData.TimeDilation = timeDilation;
  607. outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  608. outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
  609. outPacket.ObjectData[0].ID = localID;
  610. outPacket.ObjectData[0].FullID = primData.FullID;
  611. byte[] pb = pos.GetBytes();
  612. Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
  613. OutPacket(outPacket);
  614. }
  615. public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID)
  616. {
  617. ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
  618. outPacket.RegionData.RegionHandle = regionHandle;
  619. outPacket.RegionData.TimeDilation = timeDilation;
  620. outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  621. outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, textureID, flags);
  622. outPacket.ObjectData[0].ID = localID;
  623. outPacket.ObjectData[0].FullID = objectID;
  624. outPacket.ObjectData[0].OwnerID = ownerID;
  625. outPacket.ObjectData[0].Text = enc.GetBytes(text);
  626. outPacket.ObjectData[0].ParentID = parentID;
  627. byte[] pb = pos.GetBytes();
  628. Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
  629. byte[] rot = rotation.GetBytes();
  630. Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length);
  631. OutPacket(outPacket);
  632. }
  633. public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLUUID textureID, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID)
  634. {
  635. ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
  636. outPacket.RegionData.RegionHandle = regionHandle;
  637. outPacket.RegionData.TimeDilation = timeDilation;
  638. outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
  639. outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, textureID, flags);
  640. outPacket.ObjectData[0].ID = localID;
  641. outPacket.ObjectData[0].FullID = objectID;
  642. outPacket.ObjectData[0].OwnerID = ownerID;
  643. outPacket.ObjectData[0].Text = enc.GetBytes(text);
  644. outPacket.ObjectData[0].ParentID = parentID;
  645. byte[] pb = pos.GetBytes();
  646. Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
  647. OutPacket(outPacket);
  648. }
  649. /// <summary>
  650. ///
  651. /// </summary>
  652. /// <param name="regionHandle"></param>
  653. /// <param name="timeDilation"></param>
  654. /// <param name="localID"></param>
  655. /// <param name="position"></param>
  656. /// <param name="rotation"></param>
  657. public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation)
  658. {
  659. ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
  660. terse.RegionData.RegionHandle = regionHandle;
  661. terse.RegionData.TimeDilation = timeDilation;
  662. terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
  663. terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation);
  664. this.OutPacket(terse);
  665. }
  666. #endregion
  667. #endregion
  668. #region Helper Methods
  669. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity)
  670. {
  671. byte[] bytes = new byte[60];
  672. int i = 0;
  673. ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
  674. dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
  675. uint ID = localID;
  676. bytes[i++] = (byte)(ID % 256);
  677. bytes[i++] = (byte)((ID >> 8) % 256);
  678. bytes[i++] = (byte)((ID >> 16) % 256);
  679. bytes[i++] = (byte)((ID >> 24) % 256);
  680. bytes[i++] = 0;
  681. bytes[i++] = 1;
  682. i += 14;
  683. bytes[i++] = 128;
  684. bytes[i++] = 63;
  685. byte[] pb = pos.GetBytes();
  686. Array.Copy(pb, 0, bytes, i, pb.Length);
  687. i += 12;
  688. ushort InternVelocityX;
  689. ushort InternVelocityY;
  690. ushort InternVelocityZ;
  691. Vector3 internDirec = new Vector3(0, 0, 0);
  692. internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z);
  693. internDirec = internDirec / 128.0f;
  694. internDirec.x += 1;
  695. internDirec.y += 1;
  696. internDirec.z += 1;
  697. InternVelocityX = (ushort)(32768 * internDirec.x);
  698. InternVelocityY = (ushort)(32768 * internDirec.y);
  699. InternVelocityZ = (ushort)(32768 * internDirec.z);
  700. ushort ac = 32767;
  701. bytes[i++] = (byte)(InternVelocityX % 256);
  702. bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
  703. bytes[i++] = (byte)(InternVelocityY % 256);
  704. bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
  705. bytes[i++] = (byte)(InternVelocityZ % 256);
  706. bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
  707. //accel
  708. bytes[i++] = (byte)(ac % 256);
  709. bytes[i++] = (byte)((ac >> 8) % 256);
  710. bytes[i++] = (byte)(ac % 256);
  711. bytes[i++] = (byte)((ac >> 8) % 256);
  712. bytes[i++] = (byte)(ac % 256);
  713. bytes[i++] = (byte)((ac >> 8) % 256);
  714. //rot
  715. bytes[i++] = (byte)(ac % 256);
  716. bytes[i++] = (byte)((ac >> 8) % 256);
  717. bytes[i++] = (byte)(ac % 256);
  718. bytes[i++] = (byte)((ac >> 8) % 256);
  719. bytes[i++] = (byte)(ac % 256);
  720. bytes[i++] = (byte)((ac >> 8) % 256);
  721. bytes[i++] = (byte)(ac % 256);
  722. bytes[i++] = (byte)((ac >> 8) % 256);
  723. //rotation vel
  724. bytes[i++] = (byte)(ac % 256);
  725. bytes[i++] = (byte)((ac >> 8) % 256);
  726. bytes[i++] = (byte)(ac % 256);
  727. bytes[i++] = (byte)((ac >> 8) % 256);
  728. bytes[i++] = (byte)(ac % 256);
  729. bytes[i++] = (byte)((ac >> 8) % 256);
  730. dat.Data = bytes;
  731. return (dat);
  732. }
  733. /// <summary>
  734. ///
  735. /// </summary>
  736. /// <param name="localID"></param>
  737. /// <param name="position"></param>
  738. /// <param name="rotation"></param>
  739. /// <returns></returns>
  740. protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation)
  741. {
  742. uint ID = localID;
  743. byte[] bytes = new byte[60];
  744. int i = 0;
  745. ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
  746. dat.TextureEntry = new byte[0];
  747. bytes[i++] = (byte)(ID % 256);
  748. bytes[i++] = (byte)((ID >> 8) % 256);
  749. bytes[i++] = (byte)((ID >> 16) % 256);
  750. bytes[i++] = (byte)((ID >> 24) % 256);
  751. bytes[i++] = 0;
  752. bytes[i++] = 0;
  753. byte[] pb = position.GetBytes();
  754. Array.Copy(pb, 0, bytes, i, pb.Length);
  755. i += 12;
  756. ushort ac = 32767;
  757. //vel
  758. bytes[i++] = (byte)(ac % 256);
  759. bytes[i++] = (byte)((ac >> 8) % 256);
  760. bytes[i++] = (byte)(ac % 256);
  761. bytes[i++] = (byte)((ac >> 8) % 256);
  762. bytes[i++] = (byte)(ac % 256);
  763. bytes[i++] = (byte)((ac >> 8) % 256);
  764. //accel
  765. bytes[i++] = (byte)(ac % 256);
  766. bytes[i++] = (byte)((ac >> 8) % 256);
  767. bytes[i++] = (byte)(ac % 256);
  768. bytes[i++] = (byte)((ac >> 8) % 256);
  769. bytes[i++] = (byte)(ac % 256);
  770. bytes[i++] = (byte)((ac >> 8) % 256);
  771. ushort rw, rx, ry, rz;
  772. rw = (ushort)(32768 * (rotation.W + 1));
  773. rx = (ushort)(32768 * (rotation.X + 1));
  774. ry = (ushort)(32768 * (rotation.Y + 1));
  775. rz = (ushort)(32768 * (rotation.Z + 1));
  776. //rot
  777. bytes[i++] = (byte)(rx % 256);
  778. bytes[i++] = (byte)((rx >> 8) % 256);
  779. bytes[i++] = (byte)(ry % 256);
  780. bytes[i++] = (byte)((ry >> 8) % 256);
  781. bytes[i++] = (byte)(rz % 256);
  782. bytes[i++] = (byte)((rz >> 8) % 256);
  783. bytes[i++] = (byte)(rw % 256);
  784. bytes[i++] = (byte)((rw >> 8) % 256);
  785. //rotation vel
  786. bytes[i++] = (byte)(ac % 256);
  787. bytes[i++] = (byte)((ac >> 8) % 256);
  788. bytes[i++] = (byte)(ac % 256);
  789. bytes[i++] = (byte)((ac >> 8) % 256);
  790. bytes[i++] = (byte)(ac % 256);
  791. bytes[i++] = (byte)((ac >> 8) % 256);
  792. dat.Data = bytes;
  793. return dat;
  794. }
  795. /// <summary>
  796. /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
  797. /// </summary>
  798. /// <param name="primData"></param>
  799. /// <returns></returns>
  800. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimData primData, LLUUID textureID, uint flags)
  801. {
  802. ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
  803. this.SetDefaultPrimPacketValues(objupdate);
  804. objupdate.UpdateFlags = flags;
  805. this.SetPrimPacketShapeData(objupdate, primData, textureID);
  806. return objupdate;
  807. }
  808. /// <summary>
  809. /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
  810. /// </summary>
  811. /// <param name="primData"></param>
  812. /// <returns></returns>
  813. protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, LLUUID textureID, uint flags)
  814. {
  815. ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
  816. this.SetDefaultPrimPacketValues(objupdate);
  817. objupdate.UpdateFlags = flags;
  818. this.SetPrimPacketShapeData(objupdate, primShape, textureID);
  819. return objupdate;
  820. }
  821. /// <summary>
  822. /// Copy the data from a PrimData object to a ObjectUpdatePacket
  823. /// </summary>
  824. /// <param name="objectData"></param>
  825. /// <param name="primData"></param>
  826. protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimData primData, LLUUID textureID)
  827. {
  828. LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID);
  829. objectData.TextureEntry = ntex.ToBytes();
  830. objectData.OwnerID = primData.OwnerID;
  831. objectData.ParentID = primData.ParentID;
  832. objectData.PCode = primData.PCode;
  833. objectData.PathBegin = primData.PathBegin;
  834. objectData.PathEnd = primData.PathEnd;
  835. objectData.PathScaleX = primData.PathScaleX;
  836. objectData.PathScaleY = primData.PathScaleY;
  837. objectData.PathShearX = primData.PathShearX;
  838. objectData.PathShearY = primData.PathShearY;
  839. objectData.PathSkew = primData.PathSkew;
  840. objectData.ProfileBegin = primData.ProfileBegin;
  841. objectData.ProfileEnd = primData.ProfileEnd;
  842. objectData.Scale = primData.Scale;
  843. objectData.PathCurve = primData.PathCurve;
  844. objectData.ProfileCurve = primData.ProfileCurve;
  845. objectData.ProfileHollow = primData.ProfileHollow;
  846. objectData.PathRadiusOffset = primData.PathRadiusOffset;
  847. objectData.PathRevolutions = primData.PathRevolutions;
  848. objectData.PathTaperX = primData.PathTaperX;
  849. objectData.PathTaperY = primData.PathTaperY;
  850. objectData.PathTwist = primData.PathTwist;
  851. objectData.PathTwistBegin = primData.PathTwistBegin;
  852. }
  853. protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData, LLUUID textureID)
  854. {
  855. LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID);
  856. objectData.TextureEntry = ntex.ToBytes();
  857. objectData.PCode = primData.PCode;
  858. objectData.PathBegin = primData.PathBegin;
  859. objectData.PathEnd = primData.PathEnd;
  860. objectData.PathScaleX = primData.PathScaleX;
  861. objectData.PathScaleY = primData.PathScaleY;
  862. objectData.PathShearX = primData.PathShearX;
  863. objectData.PathShearY = primData.PathShearY;
  864. objectData.PathSkew = primData.PathSkew;
  865. objectData.ProfileBegin = primData.ProfileBegin;
  866. objectData.ProfileEnd = primData.ProfileEnd;
  867. objectData.Scale = primData.Scale;
  868. objectData.PathCurve = primData.PathCurve;
  869. objectData.ProfileCurve = primData.ProfileCurve;
  870. objectData.ProfileHollow = primData.ProfileHollow;
  871. objectData.PathRadiusOffset = primData.PathRadiusOffset;
  872. objectData.PathRevolutions = primData.PathRevolutions;
  873. objectData.PathTaperX = primData.PathTaperX;
  874. objectData.PathTaperY = primData.PathTaperY;
  875. objectData.PathTwist = primData.PathTwist;
  876. objectData.PathTwistBegin = primData.PathTwistBegin;
  877. }
  878. /// <summary>
  879. /// Set some default values in a ObjectUpdatePacket
  880. /// </summary>
  881. /// <param name="objdata"></param>
  882. protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
  883. {
  884. objdata.PSBlock = new byte[0];
  885. objdata.ExtraParams = new byte[1];
  886. objdata.MediaURL = new byte[0];
  887. objdata.NameValue = new byte[0];
  888. objdata.Text = new byte[0];
  889. objdata.TextColor = new byte[4];
  890. objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
  891. objdata.JointPivot = new LLVector3(0, 0, 0);
  892. objdata.Material = 3;
  893. objdata.TextureAnim = new byte[0];
  894. objdata.Sound = LLUUID.Zero;
  895. objdata.State = 0;
  896. objdata.Data = new byte[0];
  897. objdata.ObjectData = new byte[60];
  898. objdata.ObjectData[46] = 128;
  899. objdata.ObjectData[47] = 63;
  900. }
  901. /// <summary>
  902. ///
  903. /// </summary>
  904. /// <returns></returns>
  905. protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
  906. {
  907. ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
  908. SetDefaultAvatarPacketValues(ref objdata);
  909. objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
  910. objdata.PathCurve = 16;
  911. objdata.ProfileCurve = 1;
  912. objdata.PathScaleX = 100;
  913. objdata.PathScaleY = 100;
  914. objdata.ParentID = 0;
  915. objdata.OwnerID = LLUUID.Zero;
  916. objdata.Scale = new LLVector3(1, 1, 1);
  917. objdata.PCode = 47;
  918. if (textureEntry != null)
  919. {
  920. objdata.TextureEntry = textureEntry;
  921. }
  922. Encoding enc = Encoding.ASCII;
  923. LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
  924. pos.X = 100f;
  925. objdata.ID = 8880000;
  926. objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
  927. LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
  928. //objdata.FullID=user.AgentID;
  929. byte[] pb = pos.GetBytes();
  930. Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
  931. return objdata;
  932. }
  933. /// <summary>
  934. ///
  935. /// </summary>
  936. /// <param name="objdata"></param>
  937. protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata)
  938. {
  939. objdata.PSBlock = new byte[0];
  940. objdata.ExtraParams = new byte[1];
  941. objdata.MediaURL = new byte[0];
  942. objdata.NameValue = new byte[0];
  943. objdata.Text = new byte[0];
  944. objdata.TextColor = new byte[4];
  945. objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
  946. objdata.JointPivot = new LLVector3(0, 0, 0);
  947. objdata.Material = 4;
  948. objdata.TextureAnim = new byte[0];
  949. objdata.Sound = LLUUID.Zero;
  950. LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
  951. objdata.TextureEntry = ntex.ToBytes();
  952. objdata.State = 0;
  953. objdata.Data = new byte[0];
  954. objdata.ObjectData = new byte[76];
  955. objdata.ObjectData[15] = 128;
  956. objdata.ObjectData[16] = 63;
  957. objdata.ObjectData[56] = 128;
  958. objdata.ObjectData[61] = 102;
  959. objdata.ObjectData[62] = 40;
  960. objdata.ObjectData[63] = 61;
  961. objdata.ObjectData[64] = 189;
  962. }
  963. /// <summary>
  964. ///
  965. /// </summary>
  966. /// <param name="addPacket"></param>
  967. /// <returns></returns>
  968. protected PrimData CreatePrimFromObjectAdd(ObjectAddPacket addPacket)
  969. {
  970. PrimData PData = new PrimData();
  971. PData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
  972. PData.PCode = addPacket.ObjectData.PCode;
  973. PData.PathBegin = addPacket.ObjectData.PathBegin;
  974. PData.PathEnd = addPacket.ObjectData.PathEnd;
  975. PData.PathScaleX = addPacket.ObjectData.PathScaleX;
  976. PData.PathScaleY = addPacket.ObjectData.PathScaleY;
  977. PData.PathShearX = addPacket.ObjectData.PathShearX;
  978. PData.PathShearY = addPacket.ObjectData.PathShearY;
  979. PData.PathSkew = addPacket.ObjectData.PathSkew;
  980. PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
  981. PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
  982. PData.Scale = addPacket.ObjectData.Scale;
  983. PData.PathCurve = addPacket.ObjectData.PathCurve;
  984. PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
  985. PData.ParentID = 0;
  986. PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
  987. PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
  988. PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
  989. PData.PathTaperX = addPacket.ObjectData.PathTaperX;
  990. PData.PathTaperY = addPacket.ObjectData.PathTaperY;
  991. PData.PathTwist = addPacket.ObjectData.PathTwist;
  992. PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
  993. return PData;
  994. }
  995. #endregion
  996. }
  997. }