aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs
diff options
context:
space:
mode:
authorMW2007-06-15 10:34:13 +0000
committerMW2007-06-15 10:34:13 +0000
commit2bcd37aa94bca4446baf46bd7dbbf9f0482cd01d (patch)
tree2f480f443ab4f96990ed522d86ded301b827f248 /OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs
parentsome more rearranging (diff)
downloadopensim-SC_OLD-2bcd37aa94bca4446baf46bd7dbbf9f0482cd01d.zip
opensim-SC_OLD-2bcd37aa94bca4446baf46bd7dbbf9f0482cd01d.tar.gz
opensim-SC_OLD-2bcd37aa94bca4446baf46bd7dbbf9f0482cd01d.tar.bz2
opensim-SC_OLD-2bcd37aa94bca4446baf46bd7dbbf9f0482cd01d.tar.xz
and some more
Diffstat (limited to 'OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs')
-rw-r--r--OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs541
1 files changed, 0 insertions, 541 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs b/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs
deleted file mode 100644
index 9bccfd3..0000000
--- a/OpenSim/OpenSim.Region/Scenes/Entities/Primitive.cs
+++ /dev/null
@@ -1,541 +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 libsecondlife;
33using libsecondlife.Packets;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Physics.Manager;
36using OpenSim.Framework.Types;
37using OpenSim.Framework.Inventory;
38
39namespace OpenSim.Region.Scenes
40{
41 public class Primitive : Entity
42 {
43 internal PrimData primData;
44 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
45 // private Dictionary<uint, IClientAPI> m_clientThreads;
46 private ulong m_regionHandle;
47 private const uint FULL_MASK_PERMISSIONS = 2147483647;
48 private bool physicsEnabled = false;
49 private byte updateFlag = 0;
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
76 public override LLVector3 Pos
77 {
78 get
79 {
80 return base.Pos;
81 }
82 set
83 {
84 base.Pos = value;
85 }
86 }
87 #endregion
88
89 /// <summary>
90 ///
91 /// </summary>
92 /// <param name="clientThreads"></param>
93 /// <param name="regionHandle"></param>
94 /// <param name="world"></param>
95 public Primitive( ulong regionHandle, Scene world)
96 {
97 // m_clientThreads = clientThreads;
98 m_regionHandle = regionHandle;
99 m_world = world;
100 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
101 }
102
103 /// <summary>
104 ///
105 /// </summary>
106 /// <param name="regionHandle"></param>
107 /// <param name="world"></param>
108 /// <param name="addPacket"></param>
109 /// <param name="ownerID"></param>
110 /// <param name="localID"></param>
111 public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
112 {
113 // m_clientThreads = clientThreads;
114 m_regionHandle = regionHandle;
115 m_world = world;
116 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
117 this.CreateFromPacket(addPacket, ownerID, localID);
118 }
119
120 /// <summary>
121 ///
122 /// </summary>
123 /// <param name="clientThreads"></param>
124 /// <param name="regionHandle"></param>
125 /// <param name="world"></param>
126 /// <param name="owner"></param>
127 /// <param name="fullID"></param>
128 /// <param name="localID"></param>
129 public Primitive( ulong regionHandle, Scene world, LLUUID owner, LLUUID fullID, uint localID)
130 {
131 // m_clientThreads = clientThreads;
132 m_regionHandle = regionHandle;
133 m_world = world;
134 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
135 this.primData = new PrimData();
136 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
137 this.primData.OwnerID = owner;
138 this.primData.FullID = this.uuid = fullID;
139 this.primData.LocalID = this.localid = localID;
140 }
141
142 /// <summary>
143 /// Constructor to create a default cube
144 /// </summary>
145 /// <param name="clientThreads"></param>
146 /// <param name="regionHandle"></param>
147 /// <param name="world"></param>
148 /// <param name="owner"></param>
149 /// <param name="localID"></param>
150 /// <param name="position"></param>
151 public Primitive( ulong regionHandle, Scene world, LLUUID owner, uint localID, LLVector3 position)
152 {
153 //m_clientThreads = clientThreads;
154 m_regionHandle = regionHandle;
155 m_world = world;
156 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
157 this.primData = PrimData.DefaultCube();
158 this.primData.OwnerID = owner;
159 this.primData.LocalID = this.localid = localID;
160 this.Pos = this.primData.Position = position;
161
162 this.updateFlag = 1;
163 }
164
165 /// <summary>
166 ///
167 /// </summary>
168 /// <returns></returns>
169 public byte[] GetByteArray()
170 {
171 byte[] result = null;
172 List<byte[]> dataArrays = new List<byte[]>();
173 dataArrays.Add(primData.ToBytes());
174 foreach (Entity child in children)
175 {
176 if (child is OpenSim.Region.Scenes.Primitive)
177 {
178 dataArrays.Add(((OpenSim.Region.Scenes.Primitive)child).GetByteArray());
179 }
180 }
181 byte[] primstart = Helpers.StringToField("<Prim>");
182 byte[] primend = Helpers.StringToField("</Prim>");
183 int totalLength = primstart.Length + primend.Length;
184 for (int i = 0; i < dataArrays.Count; i++)
185 {
186 totalLength += dataArrays[i].Length;
187 }
188
189 result = new byte[totalLength];
190 int arraypos = 0;
191 Array.Copy(primstart, 0, result, 0, primstart.Length);
192 arraypos += primstart.Length;
193 for (int i = 0; i < dataArrays.Count; i++)
194 {
195 Array.Copy(dataArrays[i], 0, result, arraypos, dataArrays[i].Length);
196 arraypos += dataArrays[i].Length;
197 }
198 Array.Copy(primend, 0, result, arraypos, primend.Length);
199
200 return result;
201 }
202
203 #region Overridden Methods
204
205 /// <summary>
206 ///
207 /// </summary>
208 public override void update()
209 {
210 if (this.updateFlag == 1) // is a new prim just been created/reloaded
211 {
212 this.SendFullUpdateToAllClients();
213 this.updateFlag = 0;
214 }
215 if (this.updateFlag == 2) //some change has been made so update the clients
216 {
217 this.SendTerseUpdateToALLClients();
218 this.updateFlag = 0;
219 }
220 }
221
222 /// <summary>
223 ///
224 /// </summary>
225 public override void BackUp()
226 {
227
228 }
229
230 #endregion
231
232 #region Packet handlers
233
234 /// <summary>
235 ///
236 /// </summary>
237 /// <param name="pos"></param>
238 public void UpdatePosition(LLVector3 pos)
239 {
240 this.Pos = new LLVector3(pos.X, pos.Y, pos.Z);
241 this.updateFlag = 2;
242 }
243
244 /// <summary>
245 ///
246 /// </summary>
247 /// <param name="addPacket"></param>
248 public void UpdateShape(ObjectShapePacket.ObjectDataBlock updatePacket)
249 {
250 this.primData.PathBegin = updatePacket.PathBegin;
251 this.primData.PathEnd = updatePacket.PathEnd;
252 this.primData.PathScaleX = updatePacket.PathScaleX;
253 this.primData.PathScaleY = updatePacket.PathScaleY;
254 this.primData.PathShearX = updatePacket.PathShearX;
255 this.primData.PathShearY = updatePacket.PathShearY;
256 this.primData.PathSkew = updatePacket.PathSkew;
257 this.primData.ProfileBegin = updatePacket.ProfileBegin;
258 this.primData.ProfileEnd = updatePacket.ProfileEnd;
259 this.primData.PathCurve = updatePacket.PathCurve;
260 this.primData.ProfileCurve = updatePacket.ProfileCurve;
261 this.primData.ProfileHollow = updatePacket.ProfileHollow;
262 this.primData.PathRadiusOffset = updatePacket.PathRadiusOffset;
263 this.primData.PathRevolutions = updatePacket.PathRevolutions;
264 this.primData.PathTaperX = updatePacket.PathTaperX;
265 this.primData.PathTaperY = updatePacket.PathTaperY;
266 this.primData.PathTwist = updatePacket.PathTwist;
267 this.primData.PathTwistBegin = updatePacket.PathTwistBegin;
268 }
269
270 /// <summary>
271 ///
272 /// </summary>
273 /// <param name="tex"></param>
274 public void UpdateTexture(byte[] tex)
275 {
276 this.primData.Texture = tex;
277 }
278
279 /// <summary>
280 ///
281 /// </summary>
282 /// <param name="pack"></param>
283 public void UpdateObjectFlags(ObjectFlagUpdatePacket pack)
284 {
285
286 }
287
288 /// <summary>
289 ///
290 /// </summary>
291 /// <param name="prim"></param>
292 public void AssignToParent(Primitive prim)
293 {
294
295 }
296
297 #endregion
298
299 # region Inventory Methods
300 /// <summary>
301 ///
302 /// </summary>
303 /// <param name="item"></param>
304 /// <returns></returns>
305 public bool AddToInventory(InventoryItem item)
306 {
307 return false;
308 }
309
310 /// <summary>
311 ///
312 /// </summary>
313 /// <param name="itemID"></param>
314 /// <returns></returns>
315 public InventoryItem RemoveFromInventory(LLUUID itemID)
316 {
317 return null;
318 }
319
320 /// <summary>
321 ///
322 /// </summary>
323 /// <param name="simClient"></param>
324 /// <param name="packet"></param>
325 public void RequestInventoryInfo(IClientAPI simClient, RequestTaskInventoryPacket packet)
326 {
327
328 }
329
330 /// <summary>
331 ///
332 /// </summary>
333 /// <param name="simClient"></param>
334 /// <param name="xferID"></param>
335 public void RequestXferInventory(IClientAPI simClient, ulong xferID)
336 {
337 //will only currently work if the total size of the inventory data array is under about 1000 bytes
338 SendXferPacketPacket send = new SendXferPacketPacket();
339
340 send.XferID.ID = xferID;
341 send.XferID.Packet = 1 + 2147483648;
342 send.DataPacket.Data = this.ConvertInventoryToBytes();
343
344 simClient.OutPacket(send);
345 }
346
347 /// <summary>
348 ///
349 /// </summary>
350 /// <returns></returns>
351 public byte[] ConvertInventoryToBytes()
352 {
353 System.Text.Encoding enc = System.Text.Encoding.ASCII;
354 byte[] result = new byte[0];
355 List<byte[]> inventoryData = new List<byte[]>();
356 int totallength = 0;
357 foreach (InventoryItem invItem in inventoryItems.Values)
358 {
359 byte[] data = enc.GetBytes(invItem.ExportString());
360 inventoryData.Add(data);
361 totallength += data.Length;
362 }
363 //TODO: copy arrays into the single result array
364
365 return result;
366 }
367
368 /// <summary>
369 ///
370 /// </summary>
371 /// <param name="data"></param>
372 public void CreateInventoryFromBytes(byte[] data)
373 {
374
375 }
376
377 #endregion
378
379 #region Update viewers Methods
380
381 /// <summary>
382 ///
383 /// </summary>
384 /// <param name="remoteClient"></param>
385 public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
386 {
387 this.SendFullUpdateToClient(remoteClient);
388 for (int i = 0; i < this.children.Count; i++)
389 {
390 if (this.children[i] is Primitive)
391 {
392 ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
393 }
394 }
395 }
396
397 /// <summary>
398 ///
399 /// </summary>
400 /// <param name="remoteClient"></param>
401 public void SendFullUpdateToClient(IClientAPI remoteClient)
402 {
403 LLVector3 lPos;
404 if (this._physActor != null && this.physicsEnabled)
405 {
406 PhysicsVector pPos = this._physActor.Position;
407 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
408 }
409 else
410 {
411 lPos = this.Pos;
412 }
413
414 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.localid, this.primData, lPos, new LLUUID("00000000-0000-0000-5005-000000000005"));
415 }
416
417 /// <summary>
418 ///
419 /// </summary>
420 public void SendFullUpdateToAllClients()
421 {
422 List<Avatar> avatars = this.m_world.RequestAvatarList();
423 for (int i = 0; i < avatars.Count; i++)
424 {
425 this.SendFullUpdateToClient(avatars[i].ControllingClient);
426 }
427 }
428
429 /// <summary>
430 ///
431 /// </summary>
432 /// <param name="RemoteClient"></param>
433 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
434 {
435 LLVector3 lPos;
436 Axiom.MathLib.Quaternion lRot;
437 if (this._physActor != null && this.physicsEnabled)
438 {
439 PhysicsVector pPos = this._physActor.Position;
440 lPos = new LLVector3(pPos.X, pPos.Y, pPos.Z);
441 lRot = this._physActor.Orientation;
442 }
443 else
444 {
445 lPos = this.Pos;
446 lRot = this.rotation;
447 }
448 }
449
450 /// <summary>
451 ///
452 /// </summary>
453 public void SendTerseUpdateToALLClients()
454 {
455 List<Avatar> avatars = this.m_world.RequestAvatarList();
456 for (int i = 0; i < avatars.Count; i++)
457 {
458 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
459 }
460 }
461
462 #endregion
463
464 #region Create Methods
465
466 /// <summary>
467 ///
468 /// </summary>
469 /// <param name="addPacket"></param>
470 /// <param name="ownerID"></param>
471 /// <param name="localID"></param>
472 public void CreateFromPacket(ObjectAddPacket addPacket, LLUUID ownerID, uint localID)
473 {
474 PrimData PData = new PrimData();
475 this.primData = PData;
476 this.primData.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
477
478 PData.OwnerID = ownerID;
479 PData.PCode = addPacket.ObjectData.PCode;
480 PData.PathBegin = addPacket.ObjectData.PathBegin;
481 PData.PathEnd = addPacket.ObjectData.PathEnd;
482 PData.PathScaleX = addPacket.ObjectData.PathScaleX;
483 PData.PathScaleY = addPacket.ObjectData.PathScaleY;
484 PData.PathShearX = addPacket.ObjectData.PathShearX;
485 PData.PathShearY = addPacket.ObjectData.PathShearY;
486 PData.PathSkew = addPacket.ObjectData.PathSkew;
487 PData.ProfileBegin = addPacket.ObjectData.ProfileBegin;
488 PData.ProfileEnd = addPacket.ObjectData.ProfileEnd;
489 PData.Scale = addPacket.ObjectData.Scale;
490 PData.PathCurve = addPacket.ObjectData.PathCurve;
491 PData.ProfileCurve = addPacket.ObjectData.ProfileCurve;
492 PData.ParentID = 0;
493 PData.ProfileHollow = addPacket.ObjectData.ProfileHollow;
494 PData.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
495 PData.PathRevolutions = addPacket.ObjectData.PathRevolutions;
496 PData.PathTaperX = addPacket.ObjectData.PathTaperX;
497 PData.PathTaperY = addPacket.ObjectData.PathTaperY;
498 PData.PathTwist = addPacket.ObjectData.PathTwist;
499 PData.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
500 LLVector3 pos1 = addPacket.ObjectData.RayEnd;
501 this.primData.FullID = this.uuid = LLUUID.Random();
502 this.primData.LocalID = this.localid = (uint)(localID);
503 this.primData.Position = this.Pos = pos1;
504
505 this.updateFlag = 1;
506 }
507
508 /// <summary>
509 ///
510 /// </summary>
511 /// <param name="data"></param>
512 public void CreateFromBytes(byte[] data)
513 {
514
515 }
516
517 /// <summary>
518 ///
519 /// </summary>
520 /// <param name="primData"></param>
521 public void CreateFromPrimData(PrimData primData)
522 {
523 this.CreateFromPrimData(primData, primData.Position, primData.LocalID, false);
524 }
525
526 /// <summary>
527 ///
528 /// </summary>
529 /// <param name="primData"></param>
530 /// <param name="posi"></param>
531 /// <param name="localID"></param>
532 /// <param name="newprim"></param>
533 public void CreateFromPrimData(PrimData primData, LLVector3 posi, uint localID, bool newprim)
534 {
535
536 }
537
538 #endregion
539
540 }
541}