aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/world/Primitive2.cs
diff options
context:
space:
mode:
authormingchen2007-06-07 14:23:19 +0000
committermingchen2007-06-07 14:23:19 +0000
commitf88a4777f9e9b23795aed5a7f364a93a73e9ed15 (patch)
tree7acf567aed35932ae0bcc5410698379bbb6087c0 /OpenSim/OpenSim.RegionServer/world/Primitive2.cs
parent*When avatar crosses parcel, it updates successfully in the viewer (diff)
downloadopensim-SC-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.zip
opensim-SC-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.tar.gz
opensim-SC-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.tar.bz2
opensim-SC-f88a4777f9e9b23795aed5a7f364a93a73e9ed15.tar.xz
*Cleaned up namespaces, filenames, etc in OpenSim.RegionServer
NOTES: *ClientView is now in the namespace OpenSim.RegionServer.Client *Scripting is now in the namespace OpenSim.RegionServer.scripting *Other various cleaning
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/world/Primitive2.cs')
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Primitive2.cs518
1 files changed, 0 insertions, 518 deletions
diff --git a/OpenSim/OpenSim.RegionServer/world/Primitive2.cs b/OpenSim/OpenSim.RegionServer/world/Primitive2.cs
deleted file mode 100644
index 083d4b8..0000000
--- a/OpenSim/OpenSim.RegionServer/world/Primitive2.cs
+++ /dev/null
@@ -1,518 +0,0 @@
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*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.types;
32using libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Physics.Manager;
36using OpenSim.Framework.Types;
37using OpenSim.Framework.Inventory;
38
39namespace OpenSim.world
40{
41 public class Primitive2 : Entity
42 {
43 protected PrimData primData;
44 //private ObjectUpdatePacket OurPacket;
45 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
46 private Dictionary<uint, ClientView> m_clientThreads;
47 private ulong m_regionHandle;
48 private const uint FULL_MASK_PERMISSIONS = 2147483647;
49 private bool physicsEnabled = false;
50
51 private Dictionary<LLUUID, InventoryItem> inventoryItems;
52
53 #region Properties
54
55 public LLVector3 Scale
56 {
57 set
58 {
59 this.primData.Scale = value;
60 //this.dirtyFlag = true;
61 }
62 get
63 {
64 return this.primData.Scale;
65 }
66 }
67
68 public PhysicsActor PhysActor
69 {
70 set
71 {
72 this._physActor = value;
73 }
74 }
75 public override LLVector3 Pos
76 {
77 get
78 {
79 return base.Pos;
80 }
81 set
82 {
83 base.Pos = value;
84 }
85 }
86 #endregion
87
88 public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world)
89 {
90 m_clientThreads = clientThreads;
91 m_regionHandle = regionHandle;
92 m_world = world;
93 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
94 }
95
96 public Primitive2(Dictionary<uint, ClientView> clientThreads, ulong regionHandle, World world, LLUUID owner)
97 {
98 m_clientThreads = clientThreads;
99 m_regionHandle = regionHandle;
100 m_world = world;
101 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
102 this.primData = new PrimData();
103 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
104 this.primData.OwnerID = owner;
105 }
106
107 public byte[] GetByteArray()
108 {
109 byte[] result = null;
110 List<byte[]> dataArrays = new List<byte[]>();
111 dataArrays.Add(primData.ToBytes());
112 foreach (Entity child in children)
113 {
114 if (child is OpenSim.world.Primitive2)
115 {
116 dataArrays.Add(((OpenSim.world.Primitive2)child).GetByteArray());
117 }
118 }
119 byte[] primstart = Helpers.StringToField("<Prim>");
120 byte[] primend = Helpers.StringToField("</Prim>");
121 int totalLength = primstart.Length + primend.Length;
122 for (int i = 0; i < dataArrays.Count; i++)
123 {
124 totalLength += dataArrays[i].Length;
125 }
126
127 result = new byte[totalLength];
128 int arraypos = 0;
129 Array.Copy(primstart, 0, result, 0, primstart.Length);
130 arraypos += primstart.Length;
131 for (int i = 0; i < dataArrays.Count; i++)
132 {
133 Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
134 arraypos += dataArrays[i].Length;
135 }
136 Array.Copy(primend, 0, result, arraypos, primend.Length);
137
138 return result;
139 }
140
141 #region Overridden Methods
142
143 public override void update()
144 {
145 LLVector3 pos2 = new LLVector3(0, 0, 0);
146 }
147
148 public override void BackUp()
149 {
150
151 }
152
153 #endregion
154
155 #region Packet handlers
156
157 public void UpdatePosition(LLVector3 pos)
158 {
159
160 }
161
162 public void UpdateShape(ObjectShapePacket.ObjectDataBlock addPacket)
163 {
164 this.primData.PathBegin = addPacket.PathBegin;
165 this.primData.PathEnd = addPacket.PathEnd;
166 this.primData.PathScaleX = addPacket.PathScaleX;
167 this.primData.PathScaleY = addPacket.PathScaleY;
168 this.primData.PathShearX = addPacket.PathShearX;
169 this.primData.PathShearY = addPacket.PathShearY;
170 this.primData.PathSkew = addPacket.PathSkew;
171 this.primData.ProfileBegin = addPacket.ProfileBegin;
172 this.primData.ProfileEnd = addPacket.ProfileEnd;
173 this.primData.PathCurve = addPacket.PathCurve;
174 this.primData.ProfileCurve = addPacket.ProfileCurve;
175 this.primData.ProfileHollow = addPacket.ProfileHollow;
176 this.primData.PathRadiusOffset = addPacket.PathRadiusOffset;
177 this.primData.PathRevolutions = addPacket.PathRevolutions;
178 this.primData.PathTaperX = addPacket.PathTaperX;
179 this.primData.PathTaperY = addPacket.PathTaperY;
180 this.primData.PathTwist = addPacket.PathTwist;
181 this.primData.PathTwistBegin = addPacket.PathTwistBegin;
182 }
183
184 public void UpdateTexture(byte[] tex)
185 {
186 this.primData.Texture = tex;
187 //this.dirtyFlag = true;
188 }
189
190 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
191 {
192
193 }
194
195 public void AssignToParent(Primitive prim)
196 {
197
198 }
199
200 public void GetProperites(ClientView client)
201 {
202 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
203 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
204 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
205 proper.ObjectData[0].ItemID = LLUUID.Zero;
206 proper.ObjectData[0].CreationDate = (ulong)this.primData.CreationDate;
207 proper.ObjectData[0].CreatorID = this.primData.OwnerID;
208 proper.ObjectData[0].FolderID = LLUUID.Zero;
209 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
210 proper.ObjectData[0].GroupID = LLUUID.Zero;
211 proper.ObjectData[0].InventorySerial = 0;
212 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
213 proper.ObjectData[0].ObjectID = this.uuid;
214 proper.ObjectData[0].OwnerID = primData.OwnerID;
215 proper.ObjectData[0].TouchName = new byte[0];
216 proper.ObjectData[0].TextureID = new byte[0];
217 proper.ObjectData[0].SitName = new byte[0];
218 proper.ObjectData[0].Name = new byte[0];
219 proper.ObjectData[0].Description = new byte[0];
220 proper.ObjectData[0].OwnerMask = this.primData.OwnerMask;
221 proper.ObjectData[0].NextOwnerMask = this.primData.NextOwnerMask;
222 proper.ObjectData[0].GroupMask = this.primData.GroupMask;
223 proper.ObjectData[0].EveryoneMask = this.primData.EveryoneMask;
224 proper.ObjectData[0].BaseMask = this.primData.BaseMask;
225
226 client.OutPacket(proper);
227 }
228
229 #endregion
230
231 # region Inventory Methods
232
233 public bool AddToInventory(InventoryItem item)
234 {
235 return false;
236 }
237
238 public InventoryItem RemoveFromInventory(LLUUID itemID)
239 {
240 return null;
241 }
242
243 public void RequestInventoryInfo(ClientView simClient, RequestTaskInventoryPacket packet)
244 {
245
246 }
247
248 public void RequestXferInventory(ClientView simClient, ulong xferID)
249 {
250 //will only currently work if the total size of the inventory data array is under about 1000 bytes
251 SendXferPacketPacket send = new SendXferPacketPacket();
252
253 send.XferID.ID = xferID;
254 send.XferID.Packet = 1 + 2147483648;
255 send.DataPacket.Data = this.ConvertInventoryToBytes();
256
257 simClient.OutPacket(send);
258 }
259
260 public byte[] ConvertInventoryToBytes()
261 {
262 System.Text.Encoding enc = System.Text.Encoding.ASCII;
263 byte[] result = new byte[0];
264 List<byte[]> inventoryData = new List<byte[]>();
265 int totallength = 0;
266 foreach (InventoryItem invItem in inventoryItems.Values)
267 {
268 byte[] data = enc.GetBytes(invItem.ExportString());
269 inventoryData.Add(data);
270 totallength += data.Length;
271 }
272 //TODO: copy arrays into the single result array
273
274 return result;
275 }
276
277 public void CreateInventoryFromBytes(byte[] data)
278 {
279
280 }
281
282 #endregion
283
284 #region Update viewers Methods
285
286 //should change these mehtods, so that outgoing packets are sent through the avatar class
287 public void SendFullUpdateToClient(ClientView remoteClient)
288 {
289 LLVector3 lPos;
290 if (this._physActor != null && this.physicsEnabled)
291 {
292 PhysicsVector pPos = this._physActor.Position;
293 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
294 }
295 else
296 {
297 lPos = this.Pos;
298 }
299
300 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
301 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
302 outPacket.ObjectData[0] = this.CreateUpdateBlock();
303 byte[] pb = lPos.GetBytes();
304 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
305
306 remoteClient.OutPacket(outPacket);
307 }
308
309 public void SendFullUpdateToAllClients()
310 {
311
312 }
313
314 public void SendTerseUpdateToClient(ClientView RemoteClient)
315 {
316
317 }
318
319 public void SendTerseUpdateToALLClients()
320 {
321
322 }
323
324 #endregion
325
326 #region Create Methods
327
328 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
329 {
330 PrimData PData = new PrimData();
331 this.primData = PData;
332 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
333
334 PData.OwnerID = ownerID;
335 PData.PCode = addPacket.ObjectData.PCode;
336 PData.PathBegin = addPacket.ObjectData.PathBegin;
337 PData.PathEnd = addPacket.ObjectData.PathEnd;
338 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
339 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
340 PData.PathShearX = addPacket.ObjectData.PathShearX;
341 PData.PathShearY = addPacket.ObjectData.PathShearY;
342 PData.PathSkew = addPacket.ObjectData.PathSkew;
343 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
344 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
345 PData.Scale = addPacket.ObjectData.Scale;
346 PData.PathCurve = addPacket.ObjectData.PathCurve;
347 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
348 PData.ParentID = 0;
349 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
350 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
351 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
352 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
353 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
354 PData.PathTwist = addPacket.ObjectData.PathTwist;
355 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
356 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
357 this.primData.FullID = this.uuid = LLUUID.Random();
358 this.localid = (uint)(localID);
359 this.primData.Position = this.Pos = pos1;
360 }
361
362 public void CreateFromBytes(byte[] data)
363 {
364
365 }
366
367 public void CreateFromPrimData(PrimData primData)
368 {
369 this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
370 }
371
372 public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
373 {
374
375 }
376
377 #endregion
378
379 #region Packet Update Methods
380 protected void SetDefaultPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
381 {
382 objdata.PSBlock = new byte[0];
383 objdata.ExtraParams = new byte[1];
384 objdata.MediaURL = new byte[0];
385 objdata.NameValue = new byte[0];
386 objdata.Text = new byte[0];
387 objdata.TextColor = new byte[4];
388 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
389 objdata.JointPivot = new LLVector3(0, 0, 0);
390 objdata.Material = 3;
391 objdata.TextureAnim = new byte[0];
392 objdata.Sound = LLUUID.Zero;
393 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
394 this.primData.Texture = objdata.TextureEntry = ntex.ToBytes();
395 objdata.State = 0;
396 objdata.Data = new byte[0];
397
398 objdata.ObjectData = new byte[60];
399 objdata.ObjectData[46] = 128;
400 objdata.ObjectData[47] = 63;
401 }
402
403 protected void SetPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData)
404 {
405 objectData.OwnerID = this.primData.OwnerID;
406 objectData.PCode = this.primData.PCode;
407 objectData.PathBegin = this.primData.PathBegin;
408 objectData.PathEnd = this.primData.PathEnd;
409 objectData.PathScaleX = this.primData.PathScaleX;
410 objectData.PathScaleY = this.primData.PathScaleY;
411 objectData.PathShearX = this.primData.PathShearX;
412 objectData.PathShearY = this.primData.PathShearY;
413 objectData.PathSkew = this.primData.PathSkew;
414 objectData.ProfileBegin = this.primData.ProfileBegin;
415 objectData.ProfileEnd = this.primData.ProfileEnd;
416 objectData.Scale = this.primData.Scale;
417 objectData.PathCurve = this.primData.PathCurve;
418 objectData.ProfileCurve = this.primData.ProfileCurve;
419 objectData.ParentID = this.primData.ParentID;
420 objectData.ProfileHollow = this.primData.ProfileHollow;
421 objectData.PathRadiusOffset = this.primData.PathRadiusOffset;
422 objectData.PathRevolutions = this.primData.PathRevolutions;
423 objectData.PathTaperX = this.primData.PathTaperX;
424 objectData.PathTaperY = this.primData.PathTaperY;
425 objectData.PathTwist = this.primData.PathTwist;
426 objectData.PathTwistBegin = this.primData.PathTwistBegin;
427 }
428
429 #endregion
430 protected ObjectUpdatePacket.ObjectDataBlock CreateUpdateBlock()
431 {
432 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
433 this.SetDefaultPacketValues(objupdate);
434 objupdate.UpdateFlags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456;
435 this.SetPacketShapeData(objupdate);
436 byte[] pb = this.Pos.GetBytes();
437 Array.Copy(pb, 0, objupdate.ObjectData, 0, pb.Length);
438 return objupdate;
439 }
440
441 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedBlock()
442 {
443 uint ID = this.localid;
444 byte[] bytes = new byte[60];
445
446 int i = 0;
447 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
448 dat.TextureEntry = new byte[0];
449 bytes[i++] = (byte)(ID % 256);
450 bytes[i++] = (byte)((ID >> 8) % 256);
451 bytes[i++] = (byte)((ID >> 16) % 256);
452 bytes[i++] = (byte)((ID >> 24) % 256);
453 bytes[i++] = 0;
454 bytes[i++] = 0;
455
456 LLVector3 lPos;
457 Axiom.MathLib.Quaternion lRot;
458 if (this._physActor != null && this.physicsEnabled)
459 {
460 PhysicsVector pPos = this._physActor.Position;
461 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
462 lRot = this._physActor.Orientation;
463 }
464 else
465 {
466 lPos = this.Pos;
467 lRot = this.rotation;
468 }
469 byte[] pb = lPos.GetBytes();
470 Array.Copy(pb, 0, bytes, i, pb.Length);
471 i += 12;
472 ushort ac = 32767;
473
474 //vel
475 bytes[i++] = (byte)(ac % 256);
476 bytes[i++] = (byte)((ac >> 8) % 256);
477 bytes[i++] = (byte)(ac % 256);
478 bytes[i++] = (byte)((ac >> 8) % 256);
479 bytes[i++] = (byte)(ac % 256);
480 bytes[i++] = (byte)((ac >> 8) % 256);
481
482 //accel
483 bytes[i++] = (byte)(ac % 256);
484 bytes[i++] = (byte)((ac >> 8) % 256);
485 bytes[i++] = (byte)(ac % 256);
486 bytes[i++] = (byte)((ac >> 8) % 256);
487 bytes[i++] = (byte)(ac % 256);
488 bytes[i++] = (byte)((ac >> 8) % 256);
489
490 ushort rw, rx, ry, rz;
491 rw = (ushort)(32768 * (lRot.w + 1));
492 rx = (ushort)(32768 * (lRot.x + 1));
493 ry = (ushort)(32768 * (lRot.y + 1));
494 rz = (ushort)(32768 * (lRot.z + 1));
495
496 //rot
497 bytes[i++] = (byte)(rx % 256);
498 bytes[i++] = (byte)((rx >> 8) % 256);
499 bytes[i++] = (byte)(ry % 256);
500 bytes[i++] = (byte)((ry >> 8) % 256);
501 bytes[i++] = (byte)(rz % 256);
502 bytes[i++] = (byte)((rz >> 8) % 256);
503 bytes[i++] = (byte)(rw % 256);
504 bytes[i++] = (byte)((rw >> 8) % 256);
505
506 //rotation vel
507 bytes[i++] = (byte)(ac % 256);
508 bytes[i++] = (byte)((ac >> 8) % 256);
509 bytes[i++] = (byte)(ac % 256);
510 bytes[i++] = (byte)((ac >> 8) % 256);
511 bytes[i++] = (byte)(ac % 256);
512 bytes[i++] = (byte)((ac >> 8) % 256);
513
514 dat.Data = bytes;
515 return dat;
516 }
517 }
518}