aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes
diff options
context:
space:
mode:
authorlbsa712007-07-13 15:20:18 +0000
committerlbsa712007-07-13 15:20:18 +0000
commit878289ef88fca6134f589fbbdfa44f572b308a89 (patch)
tree866a1a245d3d306dfed8a514bd930c87b75511fd /OpenSim/Region/Environment/Scenes
parentOne of these days i WILL have my pulsating cube! (diff)
downloadopensim-SC-878289ef88fca6134f589fbbdfa44f572b308a89.zip
opensim-SC-878289ef88fca6134f589fbbdfa44f572b308a89.tar.gz
opensim-SC-878289ef88fca6134f589fbbdfa44f572b308a89.tar.bz2
opensim-SC-878289ef88fca6134f589fbbdfa44f572b308a89.tar.xz
* removed PrimitiveOld and CreatePrimFromObjectAdd
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r--OpenSim/Region/Environment/Scenes/PrimitiveOld.cs583
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs9
2 files changed, 0 insertions, 592 deletions
diff --git a/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs b/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs
deleted file mode 100644
index 91a4162..0000000
--- a/OpenSim/Region/Environment/Scenes/PrimitiveOld.cs
+++ /dev/null
@@ -1,583 +0,0 @@
1
2/*
3* Copyright (c) Contributors, http://www.openmetaverse.org/
4* See CONTRIBUTORS.TXT for a full list of copyright holders.
5*
6* Redistribution and use in source and binary forms, with or without
7* modification, are permitted provided that the following conditions are met:
8* * Redistributions of source code must retain the above copyright
9* notice, this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of the OpenSim Project nor the
14* names of its contributors may be used to endorse or promote products
15* derived from this software without specific prior written permission.
16*
17* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
18* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
21* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*
28*/
29using System;
30using System.Collections.Generic;
31using System.Text;
32using Axiom.Math;
33using libsecondlife;
34using libsecondlife.Packets;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Inventory;
37using OpenSim.Framework.Types;
38using OpenSim.Physics.Manager;
39
40namespace OpenSim.Region.Environment.Scenes
41{
42 public class PrimitiveOld : Entity
43 {
44 internal PrimData primData;
45 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
46 // private ClientManager m_clientThreads;
47 private ulong m_regionHandle;
48 private const uint FULL_MASK_PERMISSIONS = 2147483647;
49 private bool physicsEnabled = false;
50 private byte updateFlag = 0;
51 private uint flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
52
53 private Dictionary<LLUUID, InventoryItem> inventoryItems;
54
55 #region Properties
56
57 public LLVector3 Scale
58 {
59 set
60 {
61 this.primData.Scale = value;
62 //this.dirtyFlag = true;
63 }
64 get
65 {
66 return this.primData.Scale;
67 }
68 }
69
70 public PhysicsActor PhysActor
71 {
72 set
73 {
74 this._physActor = value;
75 }
76 }
77
78 public override LLVector3 Pos
79 {
80 get
81 {
82 return base.Pos;
83 }
84 set
85 {
86 base.Pos = value;
87 }
88 }
89 #endregion
90
91 /// <summary>
92 ///
93 /// </summary>
94 /// <param name="clientThreads"></param>
95 /// <param name="regionHandle"></param>
96 /// <param name="world"></param>
97 public PrimitiveOld( ulong regionHandle, Scene world)
98 {
99 // m_clientThreads = clientThreads;
100 m_regionHandle = regionHandle;
101 m_world = world;
102 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
103 }
104
105 /// <summary>
106 ///
107 /// </summary>
108 /// <param name="regionHandle"></param>
109 /// <param name="world"></param>
110 /// <param name="addPacket"></param>
111 /// <param name="ownerID"></param>
112 /// <param name="localID"></param>
113 public PrimitiveOld(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
114 {
115 // m_clientThreads = clientThreads;
116 m_regionHandle = regionHandle;
117 m_world = world;
118 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
119 this.CreateFromPacket(addPacket, ownerID, localID);
120 }
121
122 /// <summary>
123 ///
124 /// </summary>
125 /// <param name="clientThreads"></param>
126 /// <param name="regionHandle"></param>
127 /// <param name="world"></param>
128 /// <param name="owner"></param>
129 /// <param name="fullID"></param>
130 /// <param name="localID"></param>
131 public PrimitiveOld( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID)
132 {
133 // m_clientThreads = clientThreads;
134 m_regionHandle = regionHandle;
135 m_world = world;
136 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
137 this.primData = new PrimData();
138 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
139 this.primData.OwnerID = owner;
140 this.primData.FullID = this.uuid = fullID;
141 this.primData.LocalID = m_localId = localID;
142 }
143
144 /// <summary>
145 /// Constructor to create a default cube
146 /// </summary>
147 /// <param name="clientThreads"></param>
148 /// <param name="regionHandle"></param>
149 /// <param name="world"></param>
150 /// <param name="owner"></param>
151 /// <param name="localID"></param>
152 /// <param name="position"></param>
153 public PrimitiveOld( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position)
154 {
155 //m_clientThreads = clientThreads;
156 m_regionHandle = regionHandle;
157 m_world = world;
158 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
159 this.primData = PrimData.DefaultCube();
160 this.primData.OwnerID = owner;
161 this.primData.LocalID = m_localId = localID;
162 this.Pos = this.primData.Position = position;
163
164 this.updateFlag = 1;
165 }
166
167 /// <summary>
168 ///
169 /// </summary>
170 /// <returns></returns>
171 public byte[] GetByteArray()
172 {
173 byte[] result = null;
174 List<byte[]> dataArrays = new List<byte[]>();
175 dataArrays.Add(primData.ToBytes());
176 foreach (Entity child in children)
177 {
178 if (child is PrimitiveOld)
179 {
180 dataArrays.Add(((PrimitiveOld)child).GetByteArray());
181 }
182 }
183 byte[] primstart = Helpers.StringToField("<Prim>");
184 byte[] primend = Helpers.StringToField("</Prim>");
185 int totalLength = primstart.Length + primend.Length;
186 for (int i = 0; i < dataArrays.Count; i++)
187 {
188 totalLength += dataArrays[i].Length;
189 }
190
191 result = new byte[totalLength];
192 int arraypos = 0;
193 Array.Copy(primstart, 0, result, 0, primstart.Length);
194 arraypos += primstart.Length;
195 for (int i = 0; i < dataArrays.Count; i++)
196 {
197 Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
198 arraypos += dataArrays[i].Length;
199 }
200 Array.Copy(primend, 0, result, arraypos, primend.Length);
201
202 return result;
203 }
204
205 #region Overridden Methods
206
207 /// <summary>
208 ///
209 /// </summary>
210 public override void update()
211 {
212 if (this.updateFlag == 1) // is a new prim just been created/reloaded
213 {
214 this.SendFullUpdateToAllClients();
215 this.updateFlag = 0;
216 }
217 if (this.updateFlag == 2) //some change has been made so update the clients
218 {
219 this.SendTerseUpdateToALLClients();
220 this.updateFlag = 0;
221 }
222 }
223
224 /// <summary>
225 ///
226 /// </summary>
227 public override void BackUp()
228 {
229
230 }
231
232 #endregion
233
234 #region Packet handlers
235
236 /// <summary>
237 ///
238 /// </summary>
239 /// <param name="pos"></param>
240 public void UpdatePosition(LLVector3 pos)
241 {
242 this.Pos = new LLVector3(pos.X, pos.Y, pos.Z);
243 this.updateFlag = 2;
244 }
245
246 /// <summary>
247 ///
248 /// </summary>
249 /// <param name="addPacket"></param>
250 public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket)
251 {
252 this.primData.PathBegin = updatePacket.PathBegin;
253 this.primData.PathEnd = updatePacket.PathEnd;
254 this.primData.PathScaleX = updatePacket.PathScaleX;
255 this.primData.PathScaleY = updatePacket.PathScaleY;
256 this.primData.PathShearX = updatePacket.PathShearX;
257 this.primData.PathShearY = updatePacket.PathShearY;
258 this.primData.PathSkew = updatePacket.PathSkew;
259 this.primData.ProfileBegin = updatePacket.ProfileBegin;
260 this.primData.ProfileEnd = updatePacket.ProfileEnd;
261 this.primData.PathCurve = updatePacket.PathCurve;
262 this.primData.ProfileCurve = updatePacket.ProfileCurve;
263 this.primData.ProfileHollow = updatePacket.ProfileHollow;
264 this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset;
265 this.primData.PathRevolutions = updatePacket.PathRevolutions;
266 this.primData.PathTaperX = updatePacket.PathTaperX;
267 this.primData.PathTaperY = updatePacket.PathTaperY;
268 this.primData.PathTwist = updatePacket.PathTwist;
269 this.primData.PathTwistBegin = updatePacket.PathTwistBegin;
270 }
271
272 /// <summary>
273 ///
274 /// </summary>
275 /// <param name="tex"></param>
276 public void UpdateTexture(byte[] tex)
277 {
278 this.primData.TextureEntry = tex;
279 }
280
281 /// <summary>
282 ///
283 /// </summary>
284 /// <param name="pack"></param>
285 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
286 {
287
288 }
289
290 /// <summary>
291 ///
292 /// </summary>
293 /// <param name="prim"></param>
294 public void AssignToParent(PrimitiveOld prim)
295 {
296
297 }
298
299 #endregion
300
301 # region Inventory Methods
302 /// <summary>
303 ///
304 /// </summary>
305 /// <param name="item"></param>
306 /// <returns></returns>
307 public bool AddToInventory(InventoryItem item)
308 {
309 return false;
310 }
311
312 /// <summary>
313 ///
314 /// </summary>
315 /// <param name="itemID"></param>
316 /// <returns></returns>
317 public InventoryItem RemoveFromInventory(LLUUID itemID)
318 {
319 return null;
320 }
321
322 /// <summary>
323 ///
324 /// </summary>
325 /// <param name="simClient"></param>
326 /// <param name="packet"></param>
327 public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
328 {
329
330 }
331
332 /// <summary>
333 ///
334 /// </summary>
335 /// <param name="simClient"></param>
336 /// <param name="xferID"></param>
337 public void RequestXferInventory(IClientAPI simClient, ulong xferID)
338 {
339 //will only currently work if the total size of the inventory data array is under about 1000 bytes
340 SendXferPacketPacket send = new SendXferPacketPacket();
341
342 send.XferID.ID = xferID;
343 send.XferID.Packet = 1 + 2147483648;
344 send.DataPacket.Data = this.ConvertInventoryToBytes();
345
346 simClient.OutPacket(send);
347 }
348
349 /// <summary>
350 ///
351 /// </summary>
352 /// <returns></returns>
353 public byte[] ConvertInventoryToBytes()
354 {
355 Encoding enc = Encoding.ASCII;
356 byte[] result = new byte[0];
357 List<byte[]> inventoryData = new List<byte[]>();
358 int totallength = 0;
359 foreach (InventoryItem invItem in inventoryItems.Values)
360 {
361 byte[] data = enc.GetBytes(invItem.ExportString());
362 inventoryData.Add(data);
363 totallength += data.Length;
364 }
365 //TODO: copy arrays into the single result array
366
367 return result;
368 }
369
370 /// <summary>
371 ///
372 /// </summary>
373 /// <param name="data"></param>
374 public void CreateInventoryFromBytes(byte[] data)
375 {
376
377 }
378
379 #endregion
380
381 #region Update viewers Methods
382
383 /// <summary>
384 ///
385 /// </summary>
386 /// <param name="remoteClient"></param>
387 public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
388 {
389 this.SendFullUpdateToClient(remoteClient);
390 for (int i = 0; i < this.children.Count; i++)
391 {
392 if (this.children[i] is PrimitiveOld)
393 {
394 ((PrimitiveOld)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
395 }
396 }
397 }
398
399 /// <summary>
400 ///
401 /// </summary>
402 /// <param name="remoteClient"></param>
403 public void SendFullUpdateToClient(IClientAPI remoteClient)
404 {
405 LLVector3 lPos;
406 if (this._physActor != null && this.physicsEnabled)
407 {
408 PhysicsVector pPos = this._physActor.Position;
409 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
410 }
411 else
412 {
413 lPos = this.Pos;
414 }
415
416 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.primData, lPos, new LLUUID("00000000-0000-0000-9999-000000000005"), this.flags);
417 }
418
419 /// <summary>
420 ///
421 /// </summary>
422 public void SendFullUpdateToAllClients()
423 {
424 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
425 for (int i = 0; i < avatars.Count; i++)
426 {
427 this.SendFullUpdateToClient(avatars[i].ControllingClient);
428 }
429 }
430
431 /// <summary>
432 ///
433 /// </summary>
434 /// <param name="RemoteClient"></param>
435 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
436 {
437 LLVector3 lPos;
438 Quaternion lRot;
439 if (this._physActor != null && this.physicsEnabled) //is this needed ? doesn't the property fields do this for us?
440 {
441 PhysicsVector pPos = this._physActor.Position;
442 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
443 lRot = this._physActor.Orientation;
444 }
445 else
446 {
447 lPos = this.Pos;
448 lRot = this.Rotation;
449 }
450 LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w);
451 RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot);
452 }
453
454 /// <summary>
455 ///
456 /// </summary>
457 public void SendTerseUpdateToALLClients()
458 {
459 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
460 for (int i = 0; i < avatars.Count; i++)
461 {
462 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
463 }
464 }
465
466 #endregion
467
468 #region Create Methods
469
470 /// <summary>
471 ///
472 /// </summary>
473 /// <param name="addPacket"></param>
474 /// <param name="ownerID"></param>
475 /// <param name="localID"></param>
476 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
477 {
478 PrimData PData = new PrimData();
479 this.primData = PData;
480 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
481
482 PData.OwnerID = ownerID;
483 PData.PCode = addPacket.ObjectData.PCode;
484 PData.PathBegin = addPacket.ObjectData.PathBegin;
485 PData.PathEnd = addPacket.ObjectData.PathEnd;
486 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
487 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
488 PData.PathShearX = addPacket.ObjectData.PathShearX;
489 PData.PathShearY = addPacket.ObjectData.PathShearY;
490 PData.PathSkew = addPacket.ObjectData.PathSkew;
491 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
492 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
493 PData.Scale = addPacket.ObjectData.Scale;
494 PData.PathCurve = addPacket.ObjectData.PathCurve;
495 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
496 PData.ParentID = 0;
497 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
498 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
499 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
500 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
501 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
502 PData.PathTwist = addPacket.ObjectData.PathTwist;
503 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
504 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
505 this.primData.FullID = this.uuid = LLUUID.Random();
506 this.primData.LocalID = m_localId = (uint)(localID);
507 this.primData.Position = this.Pos = pos1;
508
509 this.updateFlag = 1;
510 }
511
512 /// <summary>
513 ///
514 /// </summary>
515 /// <param name="data"></param>
516 public void CreateFromBytes(byte[] data)
517 {
518
519 }
520
521 /// <summary>
522 ///
523 /// </summary>
524 /// <param name="primData"></param>
525 public void CreateFromPrimData(PrimData primData)
526 {
527 this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
528 }
529
530 /// <summary>
531 ///
532 /// </summary>
533 /// <param name="primData"></param>
534 /// <param name="posi"></param>
535 /// <param name="localID"></param>
536 /// <param name="newprim"></param>
537 public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
538 {
539
540 }
541
542 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
543 {
544 // Console.WriteLine("moving prim to new location " + pos.X + " , " + pos.Y + " , " + pos.Z);
545 this.Pos = pos;
546 this.SendTerseUpdateToALLClients();
547 }
548
549 public void GetProperites(IClientAPI client)
550 {
551 //needs changing
552 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
553 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
554 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
555 proper.ObjectData[0].ItemID = LLUUID.Zero;
556 proper.ObjectData[0].CreationDate = (ulong)primData.CreationDate;
557 proper.ObjectData[0].CreatorID = primData.OwnerID;
558 proper.ObjectData[0].FolderID = LLUUID.Zero;
559 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
560 proper.ObjectData[0].GroupID = LLUUID.Zero;
561 proper.ObjectData[0].InventorySerial = 0;
562 proper.ObjectData[0].LastOwnerID = LLUUID.Zero;
563 proper.ObjectData[0].ObjectID = this.uuid;
564 proper.ObjectData[0].OwnerID = primData.OwnerID;
565 proper.ObjectData[0].TouchName = new byte[0];
566 proper.ObjectData[0].TextureID = new byte[0];
567 proper.ObjectData[0].SitName = new byte[0];
568 proper.ObjectData[0].Name = new byte[0];
569 proper.ObjectData[0].Description = new byte[0];
570 proper.ObjectData[0].OwnerMask = primData.OwnerMask;
571 proper.ObjectData[0].NextOwnerMask = primData.NextOwnerMask;
572 proper.ObjectData[0].GroupMask = primData.GroupMask;
573 proper.ObjectData[0].EveryoneMask = primData.EveryoneMask;
574 proper.ObjectData[0].BaseMask = primData.BaseMask;
575
576 client.OutPacket(proper);
577
578 }
579
580 #endregion
581
582 }
583}
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index 9e383c6..cfe3e01 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -13,9 +13,6 @@ namespace OpenSim.Region.Environment.Scenes
13 public delegate void OnNewPresenceDelegate(ScenePresence presence); 13 public delegate void OnNewPresenceDelegate(ScenePresence presence);
14 public event OnNewPresenceDelegate OnNewPresence; 14 public event OnNewPresenceDelegate OnNewPresence;
15 15
16 public delegate void OnNewPrimitiveDelegate(PrimitiveOld prim);
17 public event OnNewPrimitiveDelegate OnNewPrimitive;
18
19 public delegate void OnRemovePresenceDelegate(LLUUID uuid); 16 public delegate void OnRemovePresenceDelegate(LLUUID uuid);
20 public event OnRemovePresenceDelegate OnRemovePresence; 17 public event OnRemovePresenceDelegate OnRemovePresence;
21 18
@@ -27,12 +24,6 @@ namespace OpenSim.Region.Environment.Scenes
27 } 24 }
28 } 25 }
29 26
30 public void TriggerOnNewPrimitive(PrimitiveOld prim)
31 {
32 if (OnNewPrimitive != null)
33 OnNewPrimitive(prim);
34 }
35
36 public void TriggerOnNewPresence(ScenePresence presence) 27 public void TriggerOnNewPresence(ScenePresence presence)
37 { 28 {
38 if (OnNewPresence != null) 29 if (OnNewPresence != null)