aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs
diff options
context:
space:
mode:
authorMW2007-08-09 17:54:22 +0000
committerMW2007-08-09 17:54:22 +0000
commitd451dddcd0e061cd5aa326cb08d6e24e08817dcc (patch)
tree72284c21869a14db90f0fbaba25ba69b4abd0ab8 /OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs
parentNew linux libopenjpeg compiled for i386 instead of i686. Hopefully this one w... (diff)
downloadopensim-SC_OLD-d451dddcd0e061cd5aa326cb08d6e24e08817dcc.zip
opensim-SC_OLD-d451dddcd0e061cd5aa326cb08d6e24e08817dcc.tar.gz
opensim-SC_OLD-d451dddcd0e061cd5aa326cb08d6e24e08817dcc.tar.bz2
opensim-SC_OLD-d451dddcd0e061cd5aa326cb08d6e24e08817dcc.tar.xz
Start of replacing the old SceneObject/Primitive classes with the new versions.
PLEASE NOTE: that with this revision some prim related features may be broke for a while. (things like linking prims and the parcel prim count.) Also this revision may not work on mono, but that will be fixed soon.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs586
1 files changed, 0 insertions, 586 deletions
diff --git a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs
deleted file mode 100644
index 86610c0..0000000
--- a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs
+++ /dev/null
@@ -1,586 +0,0 @@
1using System.Collections.Generic;
2using System.Text;
3using Axiom.Math;
4using libsecondlife;
5using libsecondlife.Packets;
6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Types;
8using OpenSim.Physics.Manager;
9
10namespace OpenSim.Region.Environment.Scenes
11{
12 // public delegate void PrimCountTaintedDelegate();
13
14 public class AllNewSceneObjectGroup2 : EntityBase
15 {
16 private Encoding enc = Encoding.ASCII;
17
18 protected AllNewSceneObjectPart2 m_rootPart;
19 protected Dictionary<LLUUID, AllNewSceneObjectPart2> m_parts = new Dictionary<LLUUID, AllNewSceneObjectPart2>();
20
21 protected ulong m_regionHandle;
22
23 public event PrimCountTaintedDelegate OnPrimCountTainted;
24
25 /// <summary>
26 ///
27 /// </summary>
28 public int PrimCount
29 {
30 get { return 1; }
31 }
32
33 /// <summary>
34 ///
35 /// </summary>
36 public LLVector3 GroupCentrePoint
37 {
38 get { return new LLVector3(0, 0, 0); }
39 }
40
41 public override LLVector3 Pos
42 {
43 get { return m_rootPart.GroupPosition; }
44 set
45 {
46 lock (this.m_parts)
47 {
48 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
49 {
50 part.GroupPosition = value;
51 }
52 }
53 }
54 }
55
56 public override uint LocalId
57 {
58 get { return m_rootPart.LocalID; }
59 set { m_rootPart.LocalID = value; }
60 }
61
62 public override LLUUID UUID
63 {
64 get { return m_rootPart.UUID; }
65 set { m_rootPart.UUID = value; }
66 }
67
68 /// <summary>
69 ///
70 /// </summary>
71 public AllNewSceneObjectGroup2()
72 {
73
74 }
75
76 /// <summary>
77 ///
78 /// </summary>
79 public AllNewSceneObjectGroup2(byte[] data)
80 {
81
82 }
83
84 /// <summary>
85 ///
86 /// </summary>
87 public AllNewSceneObjectGroup2(Scene scene, ulong regionHandle, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
88 {
89 m_regionHandle = regionHandle;
90 m_scene = scene;
91
92 this.Pos = pos;
93 LLVector3 rootOffset = new LLVector3(0, 0, 0);
94 AllNewSceneObjectPart2 newPart = new AllNewSceneObjectPart2(m_regionHandle, this, ownerID, localID, shape, pos, rootOffset);
95 this.m_parts.Add(newPart.UUID, newPart);
96 this.SetPartAsRoot(newPart);
97 }
98
99
100 #region Copying
101 /// <summary>
102 ///
103 /// </summary>
104 /// <returns></returns>
105 public new AllNewSceneObjectGroup2 Copy()
106 {
107 AllNewSceneObjectGroup2 dupe = (AllNewSceneObjectGroup2)this.MemberwiseClone();
108 dupe.Pos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
109 dupe.m_scene = m_scene;
110 dupe.m_regionHandle = this.m_regionHandle;
111
112 dupe.CopyRootPart(this.m_rootPart);
113
114 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
115 {
116 if (part.UUID != this.m_rootPart.UUID)
117 {
118 dupe.CopyPart(part);
119 }
120 }
121 return dupe;
122 }
123
124 /// <summary>
125 ///
126 /// </summary>
127 /// <param name="part"></param>
128 public void CopyRootPart(AllNewSceneObjectPart2 part)
129 {
130 AllNewSceneObjectPart2 newPart = part.Copy(m_scene.PrimIDAllocate());
131 this.m_parts.Add(newPart.UUID, newPart);
132 this.SetPartAsRoot(newPart);
133 }
134
135 /// <summary>
136 ///
137 /// </summary>
138 /// <param name="part"></param>
139 public void CopyPart(AllNewSceneObjectPart2 part)
140 {
141 AllNewSceneObjectPart2 newPart = part.Copy(m_scene.PrimIDAllocate());
142 this.m_parts.Add(newPart.UUID, newPart);
143 this.SetPartAsNonRoot(newPart);
144 }
145 #endregion
146
147 /// <summary>
148 ///
149 /// </summary>
150 public override void Update()
151 {
152 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
153 {
154 part.SendScheduledUpdates();
155 }
156 }
157
158 /// <summary>
159 ///
160 /// </summary>
161 public void ScheduleGroupForFullUpdate()
162 {
163 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
164 {
165 part.ScheduleFullUpdate();
166 }
167 }
168
169 /// <summary>
170 ///
171 /// </summary>
172 public void ScheduleGroupForTerseUpdate()
173 {
174 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
175 {
176 part.ScheduleTerseUpdate();
177 }
178 }
179
180 /// <summary>
181 ///
182 /// </summary>
183 public void SendGroupFullUpdate()
184 {
185 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
186 {
187 part.SendFullUpdateToAllClients();
188 }
189 }
190
191 /// <summary>
192 ///
193 /// </summary>
194 public void SendGroupTerseUpdate()
195 {
196 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
197 {
198 part.SendTerseUpdateToAllClients();
199 }
200 }
201
202 /// <summary>
203 ///
204 /// </summary>
205 /// <param name="objectGroup"></param>
206 public void LinkToGroup(AllNewSceneObjectGroup2 objectGroup)
207 {
208
209 }
210
211 /// <summary>
212 ///
213 /// </summary>
214 /// <param name="primID"></param>
215 /// <returns></returns>
216 private AllNewSceneObjectPart2 GetChildPrim(LLUUID primID)
217 {
218 AllNewSceneObjectPart2 childPart = null;
219 if (this.m_parts.ContainsKey(primID))
220 {
221 childPart = this.m_parts[primID];
222 }
223 return childPart;
224 }
225
226 /// <summary>
227 ///
228 /// </summary>
229 /// <param name="localID"></param>
230 /// <returns></returns>
231 private AllNewSceneObjectPart2 GetChildPrim(uint localID)
232 {
233 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
234 {
235 if (part.LocalID == localID)
236 {
237 return part;
238 }
239 }
240 return null;
241 }
242
243 /// <summary>
244 /// Does this group contain the child prim
245 /// should be able to remove these methods once we have a entity index in scene
246 /// </summary>
247 /// <param name="primID"></param>
248 /// <returns></returns>
249 public bool HasChildPrim(LLUUID primID)
250 {
251 AllNewSceneObjectPart2 childPart = null;
252 if (this.m_parts.ContainsKey(primID))
253 {
254 childPart = this.m_parts[primID];
255 return true;
256 }
257 return false;
258 }
259
260 /// <summary>
261 /// Does this group contain the child prim
262 /// should be able to remove these methods once we have a entity index in scene
263 /// </summary>
264 /// <param name="localID"></param>
265 /// <returns></returns>
266 public bool HasChildPrim(uint localID)
267 {
268 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
269 {
270 if (part.LocalID == localID)
271 {
272 return true;
273 }
274 }
275 return false;
276 }
277
278 /// <summary>
279 ///
280 /// </summary>
281 public void TriggerTainted()
282 {
283 if (OnPrimCountTainted != null)
284 {
285 this.OnPrimCountTainted();
286 }
287 }
288
289 /// <summary>
290 ///
291 /// </summary>
292 /// <param name="offset"></param>
293 /// <param name="pos"></param>
294 /// <param name="remoteClient"></param>
295 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
296 {
297 this.Pos = pos;
298 this.m_rootPart.SendTerseUpdateToAllClients();
299 }
300
301 /// <summary>
302 ///
303 /// </summary>
304 /// <param name="client"></param>
305 public void GetProperites(IClientAPI client)
306 {
307 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
308 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
309 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
310 proper.ObjectData[0].ItemID = LLUUID.Zero;
311 proper.ObjectData[0].CreationDate = (ulong)this.m_rootPart.CreationDate;
312 proper.ObjectData[0].CreatorID = this.m_rootPart.CreatorID;
313 proper.ObjectData[0].FolderID = LLUUID.Zero;
314 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
315 proper.ObjectData[0].GroupID = LLUUID.Zero;
316 proper.ObjectData[0].InventorySerial = 0;
317 proper.ObjectData[0].LastOwnerID = this.m_rootPart.LastOwnerID;
318 proper.ObjectData[0].ObjectID = this.m_uuid;
319 proper.ObjectData[0].OwnerID = this.m_rootPart.OwnerID;
320 proper.ObjectData[0].TouchName = enc.GetBytes(this.m_rootPart.TouchName + "\0");
321 proper.ObjectData[0].TextureID = new byte[0];
322 proper.ObjectData[0].SitName = enc.GetBytes(this.m_rootPart.SitName + "\0");
323 proper.ObjectData[0].Name = enc.GetBytes(this.m_rootPart.PartName + "\0");
324 proper.ObjectData[0].Description = enc.GetBytes(this.m_rootPart.Description + "\0");
325 proper.ObjectData[0].OwnerMask = this.m_rootPart.OwnerMask;
326 proper.ObjectData[0].NextOwnerMask = this.m_rootPart.NextOwnerMask;
327 proper.ObjectData[0].GroupMask = this.m_rootPart.GroupMask;
328 proper.ObjectData[0].EveryoneMask = this.m_rootPart.EveryoneMask;
329 proper.ObjectData[0].BaseMask = this.m_rootPart.BaseMask;
330
331 client.OutPacket(proper);
332 }
333
334 /// <summary>
335 ///
336 /// </summary>
337 /// <param name="remoteClient"></param>
338 /// <param name="localID"></param>
339 public void GetInventory(IClientAPI remoteClient, uint localID)
340 {
341 AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
342 if (part != null)
343 {
344 part.GetInventory(remoteClient, localID);
345 }
346 }
347
348 /// <summary>
349 ///
350 /// </summary>
351 /// <param name="localID"></param>
352 /// <param name="type"></param>
353 /// <param name="inUse"></param>
354 /// <param name="data"></param>
355 public void UpdateExtraParam(uint localID, ushort type, bool inUse, byte[] data)
356 {
357 AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
358 if (part != null)
359 {
360 part.UpdateExtraParam(type, inUse, data);
361 }
362 }
363
364 /// <summary>
365 ///
366 /// </summary>
367 /// <param name="localID"></param>
368 /// <param name="textureEntry"></param>
369 public void UpdateTextureEntry(uint localID, byte[] textureEntry)
370 {
371 AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
372 if (part != null)
373 {
374 part.UpdateTextureEntry(textureEntry);
375 }
376 }
377
378 #region Shape
379 /// <summary>
380 ///
381 /// </summary>
382 /// <param name="shapeBlock"></param>
383 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock, uint localID)
384 {
385 AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
386 if (part != null)
387 {
388 part.UpdateShape(shapeBlock);
389 }
390 }
391 #endregion
392
393 #region Position
394 /// <summary>
395 ///
396 /// </summary>
397 /// <param name="pos"></param>
398 public void UpdateGroupPosition(LLVector3 pos)
399 {
400 this.Pos = pos;
401 }
402
403 /// <summary>
404 ///
405 /// </summary>
406 /// <param name="pos"></param>
407 /// <param name="localID"></param>
408 public void UpdateSinglePosition(LLVector3 pos, uint localID)
409 {
410 AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
411 if (part != null)
412 {
413 if (part.UUID == this.m_rootPart.UUID)
414 {
415 this.UpdateRootPosition(pos);
416 }
417 else
418 {
419 part.UpdateOffSet(pos);
420 }
421 }
422 }
423
424 /// <summary>
425 ///
426 /// </summary>
427 /// <param name="pos"></param>
428 private void UpdateRootPosition(LLVector3 pos)
429 {
430 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
431 LLVector3 oldPos = new LLVector3(this.Pos.X + this.m_rootPart.OffsetPosition.X, this.Pos.Y + this.m_rootPart.OffsetPosition.Y, this.Pos.Z + this.m_rootPart.OffsetPosition.Z);
432 LLVector3 diff = oldPos - newPos;
433 Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
434 Axiom.Math.Quaternion partRotation = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z);
435 axDiff = partRotation.Inverse() * axDiff;
436 diff.X = axDiff.x;
437 diff.Y = axDiff.y;
438 diff.Z = axDiff.z;
439
440 foreach (AllNewSceneObjectPart2 obPart in this.m_parts.Values)
441 {
442 if (obPart.UUID != this.m_rootPart.UUID)
443 {
444 obPart.OffsetPosition = obPart.OffsetPosition + diff;
445 }
446 }
447 this.Pos = newPos;
448 pos.X = newPos.X;
449 pos.Y = newPos.Y;
450 pos.Z = newPos.Z;
451 }
452 #endregion
453
454 #region Roation
455 /// <summary>
456 ///
457 /// </summary>
458 /// <param name="rot"></param>
459 public void UpdateGroupRotation(LLQuaternion rot)
460 {
461 this.m_rootPart.UpdateRotation(rot);
462 }
463
464 /// <summary>
465 ///
466 /// </summary>
467 /// <param name="pos"></param>
468 /// <param name="rot"></param>
469 public void UpdateGroupRotation(LLVector3 pos, LLQuaternion rot)
470 {
471 this.m_rootPart.UpdateRotation(rot);
472 this.Pos = pos;
473 }
474
475 /// <summary>
476 ///
477 /// </summary>
478 /// <param name="rot"></param>
479 /// <param name="localID"></param>
480 public void UpdateSingleRotation(LLQuaternion rot, uint localID)
481 {
482 AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
483 if (part != null)
484 {
485 if (part.UUID == this.m_rootPart.UUID)
486 {
487 this.UpdateRootRotation(rot);
488 }
489 else
490 {
491 part.UpdateRotation(rot);
492 }
493 }
494 }
495
496 /// <summary>
497 ///
498 /// </summary>
499 /// <param name="rot"></param>
500 private void UpdateRootRotation(LLQuaternion rot)
501 {
502 this.m_rootPart.UpdateRotation(rot);
503 Axiom.Math.Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
504 Axiom.Math.Quaternion oldParentRot = new Quaternion(this.m_rootPart.RotationOffset.W, this.m_rootPart.RotationOffset.X, this.m_rootPart.RotationOffset.Y, this.m_rootPart.RotationOffset.Z);
505
506 foreach (AllNewSceneObjectPart2 prim in this.m_parts.Values)
507 {
508 if (prim.UUID != this.m_rootPart.UUID)
509 {
510 Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z);
511 axPos = oldParentRot * axPos;
512 axPos = axRot.Inverse() * axPos;
513 prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
514 Axiom.Math.Quaternion primsRot = new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, prim.RotationOffset.Z);
515 Axiom.Math.Quaternion newRot = oldParentRot * primsRot;
516 newRot = axRot.Inverse() * newRot;
517 prim.RotationOffset = new LLQuaternion(newRot.w, newRot.x, newRot.y, newRot.z);
518 }
519 }
520 }
521
522 #endregion
523 /// <summary>
524 ///
525 /// </summary>
526 /// <param name="part"></param>
527 private void SetPartAsRoot(AllNewSceneObjectPart2 part)
528 {
529 this.m_rootPart = part;
530 //this.m_uuid= part.UUID;
531 // this.m_localId = part.LocalID;
532 }
533
534 /// <summary>
535 ///
536 /// </summary>
537 /// <param name="part"></param>
538 private void SetPartAsNonRoot(AllNewSceneObjectPart2 part)
539 {
540 part.ParentID = this.m_rootPart.LocalID;
541 }
542
543 /// <summary>
544 ///
545 /// </summary>
546 /// <returns></returns>
547 public List<ScenePresence> RequestSceneAvatars()
548 {
549 return m_scene.RequestAvatarList();
550 }
551
552 /// <summary>
553 ///
554 /// </summary>
555 /// <param name="remoteClient"></param>
556 /// <param name="part"></param>
557 internal void SendPartFullUpdate(IClientAPI remoteClient, AllNewSceneObjectPart2 part)
558 {
559 if( m_rootPart == part )
560 {
561 part.SendFullUpdateToClient( remoteClient, Pos );
562 }
563 else
564 {
565 part.SendFullUpdateToClient( remoteClient );
566 }
567 }
568
569 /// <summary>
570 ///
571 /// </summary>
572 /// <param name="remoteClient"></param>
573 /// <param name="part"></param>
574 internal void SendPartTerseUpdate(IClientAPI remoteClient, AllNewSceneObjectPart2 part)
575 {
576 if (m_rootPart == part)
577 {
578 part.SendTerseUpdateToClient(remoteClient, Pos);
579 }
580 else
581 {
582 part.SendTerseUpdateToClient(remoteClient);
583 }
584 }
585 }
586}