aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/Primitive.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Primitive.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/Primitive.cs1296
1 files changed, 648 insertions, 648 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs
index 0e5b083..b413758 100644
--- a/OpenSim/Region/Environment/Scenes/Primitive.cs
+++ b/OpenSim/Region/Environment/Scenes/Primitive.cs
@@ -1,648 +1,648 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using Axiom.Math; 3using Axiom.Math;
4using libsecondlife; 4using libsecondlife;
5using libsecondlife.Packets; 5using libsecondlife.Packets;
6using OpenSim.Framework.Interfaces; 6using OpenSim.Framework.Interfaces;
7using OpenSim.Framework.Inventory; 7using OpenSim.Framework.Inventory;
8using OpenSim.Framework.Types; 8using OpenSim.Framework.Types;
9 9
10namespace OpenSim.Region.Environment.Scenes 10namespace OpenSim.Region.Environment.Scenes
11{ 11{
12 public delegate void PrimCountTaintedDelegate(); 12 public delegate void PrimCountTaintedDelegate();
13 13
14 public class Primitive : EntityBase 14 public class Primitive : EntityBase
15 { 15 {
16 private const uint FULL_MASK_PERMISSIONS = 2147483647; 16 private const uint FULL_MASK_PERMISSIONS = 2147483647;
17 17
18 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); 18 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
19 private ulong m_regionHandle; 19 private ulong m_regionHandle;
20 private byte updateFlag = 0; 20 private byte updateFlag = 0;
21 private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; 21 private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128;
22 22
23 private Dictionary<LLUUID, InventoryItem> inventoryItems; 23 private Dictionary<LLUUID, InventoryItem> inventoryItems;
24 24
25 private string m_description = ""; 25 private string m_description = "";
26 26
27 public string SitName = ""; 27 public string SitName = "";
28 public string TouchName = ""; 28 public string TouchName = "";
29 public string Text = ""; 29 public string Text = "";
30 30
31 public LLUUID CreatorID; 31 public LLUUID CreatorID;
32 public LLUUID OwnerID; 32 public LLUUID OwnerID;
33 public LLUUID LastOwnerID; 33 public LLUUID LastOwnerID;
34 public Int32 CreationDate; 34 public Int32 CreationDate;
35 35
36 public uint ParentID = 0; 36 public uint ParentID = 0;
37 37
38 public uint OwnerMask = FULL_MASK_PERMISSIONS; 38 public uint OwnerMask = FULL_MASK_PERMISSIONS;
39 public uint NextOwnerMask = FULL_MASK_PERMISSIONS; 39 public uint NextOwnerMask = FULL_MASK_PERMISSIONS;
40 public uint GroupMask = FULL_MASK_PERMISSIONS; 40 public uint GroupMask = FULL_MASK_PERMISSIONS;
41 public uint EveryoneMask = FULL_MASK_PERMISSIONS; 41 public uint EveryoneMask = FULL_MASK_PERMISSIONS;
42 public uint BaseMask = FULL_MASK_PERMISSIONS; 42 public uint BaseMask = FULL_MASK_PERMISSIONS;
43 43
44 private PrimitiveBaseShape m_Shape; 44 private PrimitiveBaseShape m_Shape;
45 45
46 public SceneObject m_RootParent; 46 public SceneObject m_RootParent;
47 public bool m_isRootPrim; 47 public bool m_isRootPrim;
48 public EntityBase m_Parent; 48 public EntityBase m_Parent;
49 49
50 private EventManager m_eventManager; 50 private EventManager m_eventManager;
51 51
52 public event PrimCountTaintedDelegate OnPrimCountTainted; 52 public event PrimCountTaintedDelegate OnPrimCountTainted;
53 53
54 #region Properties 54 #region Properties
55 /// <summary> 55 /// <summary>
56 /// If rootprim, will return world position 56 /// If rootprim, will return world position
57 /// otherwise will return local offset from rootprim 57 /// otherwise will return local offset from rootprim
58 /// </summary> 58 /// </summary>
59 public override LLVector3 Pos 59 public override LLVector3 Pos
60 { 60 {
61 get 61 get
62 { 62 {
63 if (m_isRootPrim) 63 if (m_isRootPrim)
64 { 64 {
65 //if we are rootprim then our offset should be zero 65 //if we are rootprim then our offset should be zero
66 return this.m_pos + m_Parent.Pos; 66 return this.m_pos + m_Parent.Pos;
67 } 67 }
68 else 68 else
69 { 69 {
70 return this.m_pos; 70 return this.m_pos;
71 } 71 }
72 } 72 }
73 set 73 set
74 { 74 {
75 if (m_isRootPrim) 75 if (m_isRootPrim)
76 { 76 {
77 m_Parent.Pos = value; 77 m_Parent.Pos = value;
78 } 78 }
79 this.m_pos = value - m_Parent.Pos; 79 this.m_pos = value - m_Parent.Pos;
80 } 80 }
81 81
82 } 82 }
83 83
84 public PrimitiveBaseShape Shape 84 public PrimitiveBaseShape Shape
85 { 85 {
86 get 86 get
87 { 87 {
88 return this.m_Shape; 88 return this.m_Shape;
89 } 89 }
90 } 90 }
91 91
92 public LLVector3 WorldPos 92 public LLVector3 WorldPos
93 { 93 {
94 get 94 get
95 { 95 {
96 if (!this.m_isRootPrim) 96 if (!this.m_isRootPrim)
97 { 97 {
98 Primitive parentPrim = (Primitive)this.m_Parent; 98 Primitive parentPrim = (Primitive)this.m_Parent;
99 Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); 99 Axiom.Math.Vector3 offsetPos = new Vector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z);
100 offsetPos = parentPrim.Rotation * offsetPos; 100 offsetPos = parentPrim.Rotation * offsetPos;
101 return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z); 101 return parentPrim.WorldPos + new LLVector3(offsetPos.x, offsetPos.y, offsetPos.z);
102 } 102 }
103 else 103 else
104 { 104 {
105 return this.Pos; 105 return this.Pos;
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 public string Description 110 public string Description
111 { 111 {
112 get 112 get
113 { 113 {
114 return this.m_description; 114 return this.m_description;
115 } 115 }
116 set 116 set
117 { 117 {
118 this.m_description = value; 118 this.m_description = value;
119 } 119 }
120 } 120 }
121 121
122 public LLVector3 Scale 122 public LLVector3 Scale
123 { 123 {
124 set 124 set
125 { 125 {
126 this.m_Shape.Scale = value; 126 this.m_Shape.Scale = value;
127 } 127 }
128 get 128 get
129 { 129 {
130 return this.m_Shape.Scale; 130 return this.m_Shape.Scale;
131 } 131 }
132 } 132 }
133 #endregion 133 #endregion
134 134
135 #region Constructors 135 #region Constructors
136 /// <summary> 136 /// <summary>
137 /// 137 ///
138 /// </summary> 138 /// </summary>
139 /// <param name="regionHandle"></param> 139 /// <param name="regionHandle"></param>
140 /// <param name="world"></param> 140 /// <param name="world"></param>
141 /// <param name="addPacket"></param> 141 /// <param name="addPacket"></param>
142 /// <param name="ownerID"></param> 142 /// <param name="ownerID"></param>
143 /// <param name="localID"></param> 143 /// <param name="localID"></param>
144 /// <param name="isRoot"></param> 144 /// <param name="isRoot"></param>
145 /// <param name="parent"></param> 145 /// <param name="parent"></param>
146 /// <param name="rootObject"></param> 146 /// <param name="rootObject"></param>
147 public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos) 147 public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos)
148 { 148 {
149 149
150 m_regionHandle = regionHandle; 150 m_regionHandle = regionHandle;
151 m_world = world; 151 m_world = world;
152 inventoryItems = new Dictionary<LLUUID, InventoryItem>(); 152 inventoryItems = new Dictionary<LLUUID, InventoryItem>();
153 this.m_Parent = parent; 153 this.m_Parent = parent;
154 this.m_isRootPrim = isRoot; 154 this.m_isRootPrim = isRoot;
155 this.m_RootParent = rootObject; 155 this.m_RootParent = rootObject;
156 this.CreateFromShape(ownerID, localID, pos, shape); 156 this.CreateFromShape(ownerID, localID, pos, shape);
157 this.Rotation = Axiom.Math.Quaternion.Identity; 157 this.Rotation = Axiom.Math.Quaternion.Identity;
158 158
159 m_world.AcknowledgeNewPrim(this); 159 m_world.AcknowledgeNewPrim(this);
160 160
161 this.OnPrimCountTainted(); 161 this.OnPrimCountTainted();
162 } 162 }
163 163
164 /// <summary> 164 /// <summary>
165 /// 165 ///
166 /// </summary> 166 /// </summary>
167 /// <remarks>Empty constructor for duplication</remarks> 167 /// <remarks>Empty constructor for duplication</remarks>
168 public Primitive() 168 public Primitive()
169 { 169 {
170 170
171 } 171 }
172 172
173 #endregion 173 #endregion
174 174
175 #region Destructors 175 #region Destructors
176 176
177 ~Primitive() 177 ~Primitive()
178 { 178 {
179 this.OnPrimCountTainted(); 179 this.OnPrimCountTainted();
180 } 180 }
181 #endregion 181 #endregion
182 182
183 #region Duplication 183 #region Duplication
184 184
185 public Primitive Copy(EntityBase parent, SceneObject rootParent) 185 public Primitive Copy(EntityBase parent, SceneObject rootParent)
186 { 186 {
187 Primitive dupe = (Primitive)this.MemberwiseClone(); 187 Primitive dupe = (Primitive)this.MemberwiseClone();
188 188
189 dupe.m_Parent = parent; 189 dupe.m_Parent = parent;
190 dupe.m_RootParent = rootParent; 190 dupe.m_RootParent = rootParent;
191 191
192 // TODO: Copy this properly. 192 // TODO: Copy this properly.
193 dupe.inventoryItems = this.inventoryItems; 193 dupe.inventoryItems = this.inventoryItems;
194 dupe.children = new List<EntityBase>(); 194 dupe.children = new List<EntityBase>();
195 dupe.m_Shape = this.m_Shape.Copy(); 195 dupe.m_Shape = this.m_Shape.Copy();
196 dupe.m_regionHandle = this.m_regionHandle; 196 dupe.m_regionHandle = this.m_regionHandle;
197 dupe.m_world = this.m_world; 197 dupe.m_world = this.m_world;
198 198
199 uint newLocalID = this.m_world.PrimIDAllocate(); 199 uint newLocalID = this.m_world.PrimIDAllocate();
200 dupe.uuid = LLUUID.Random(); 200 dupe.uuid = LLUUID.Random();
201 dupe.LocalId = newLocalID; 201 dupe.LocalId = newLocalID;
202 202
203 if (parent is SceneObject) 203 if (parent is SceneObject)
204 { 204 {
205 dupe.m_isRootPrim = true; 205 dupe.m_isRootPrim = true;
206 dupe.ParentID = 0; 206 dupe.ParentID = 0;
207 } 207 }
208 else 208 else
209 { 209 {
210 dupe.m_isRootPrim = false; 210 dupe.m_isRootPrim = false;
211 dupe.ParentID = ((Primitive)parent).LocalId; 211 dupe.ParentID = ((Primitive)parent).LocalId;
212 } 212 }
213 213
214 dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z); 214 dupe.Scale = new LLVector3(this.Scale.X, this.Scale.Y, this.Scale.Z);
215 dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); 215 dupe.Rotation = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
216 dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z); 216 dupe.m_pos = new LLVector3(this.m_pos.X, this.m_pos.Y, this.m_pos.Z);
217 217
218 rootParent.AddChildToList(dupe); 218 rootParent.AddChildToList(dupe);
219 this.m_world.AcknowledgeNewPrim(dupe); 219 this.m_world.AcknowledgeNewPrim(dupe);
220 dupe.TriggerOnPrimCountTainted(); 220 dupe.TriggerOnPrimCountTainted();
221 221
222 foreach (Primitive prim in this.children) 222 foreach (Primitive prim in this.children)
223 { 223 {
224 Primitive primClone = prim.Copy(dupe, rootParent); 224 Primitive primClone = prim.Copy(dupe, rootParent);
225 dupe.children.Add(primClone); 225 dupe.children.Add(primClone);
226 } 226 }
227 227
228 return dupe; 228 return dupe;
229 } 229 }
230 230
231 #endregion 231 #endregion
232 232
233 #region Override from EntityBase 233 #region Override from EntityBase
234 /// <summary> 234 /// <summary>
235 /// 235 ///
236 /// </summary> 236 /// </summary>
237 public override void update() 237 public override void update()
238 { 238 {
239 if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes 239 if (this.updateFlag == 1) // is a new prim just been created/reloaded or has major changes
240 { 240 {
241 this.SendFullUpdateToAllClients(); 241 this.SendFullUpdateToAllClients();
242 this.updateFlag = 0; 242 this.updateFlag = 0;
243 } 243 }
244 if (this.updateFlag == 2) //some change has been made so update the clients 244 if (this.updateFlag == 2) //some change has been made so update the clients
245 { 245 {
246 this.SendTerseUpdateToALLClients(); 246 this.SendTerseUpdateToALLClients();
247 this.updateFlag = 0; 247 this.updateFlag = 0;
248 } 248 }
249 249
250 foreach (EntityBase child in children) 250 foreach (EntityBase child in children)
251 { 251 {
252 child.update(); 252 child.update();
253 } 253 }
254 } 254 }
255 #endregion 255 #endregion
256 256
257 #region Setup 257 #region Setup
258 /// <summary> 258 /// <summary>
259 /// 259 ///
260 /// </summary> 260 /// </summary>
261 /// <param name="addPacket"></param> 261 /// <param name="addPacket"></param>
262 /// <param name="ownerID"></param> 262 /// <param name="ownerID"></param>
263 /// <param name="localID"></param> 263 /// <param name="localID"></param>
264 public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) 264 public void CreateFromShape(LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape)
265 { 265 {
266 this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 266 this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
267 this.OwnerID = ownerID; 267 this.OwnerID = ownerID;
268 this.CreatorID = this.OwnerID; 268 this.CreatorID = this.OwnerID;
269 this.LastOwnerID = LLUUID.Zero; 269 this.LastOwnerID = LLUUID.Zero;
270 this.Pos = pos; 270 this.Pos = pos;
271 this.uuid = LLUUID.Random(); 271 this.uuid = LLUUID.Random();
272 this.m_localId = (uint)(localID); 272 this.m_localId = (uint)(localID);
273 273
274 this.m_Shape = shape; 274 this.m_Shape = shape;
275 this.updateFlag = 1; 275 this.updateFlag = 1;
276 } 276 }
277 277
278 #endregion 278 #endregion
279 279
280 #region Linking / unlinking 280 #region Linking / unlinking
281 /// <summary> 281 /// <summary>
282 /// 282 ///
283 /// </summary> 283 /// </summary>
284 /// <param name="linkObject"></param> 284 /// <param name="linkObject"></param>
285 public void AddNewChildren(SceneObject linkObject) 285 public void AddNewChildren(SceneObject linkObject)
286 { 286 {
287 // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")"); 287 // Console.WriteLine("linking new prims " + linkObject.rootLocalID + " to me (" + this.LocalId + ")");
288 //TODO check permissions 288 //TODO check permissions
289 this.children.Add(linkObject.rootPrimitive); 289 this.children.Add(linkObject.rootPrimitive);
290 linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent); 290 linkObject.rootPrimitive.SetNewParent(this, this.m_RootParent);
291 291
292 this.m_world.DeleteEntity(linkObject.rootUUID); 292 this.m_world.DeleteEntity(linkObject.rootUUID);
293 linkObject.DeleteAllChildren(); 293 linkObject.DeleteAllChildren();
294 294
295 this.OnPrimCountTainted(); 295 this.OnPrimCountTainted();
296 } 296 }
297 297
298 /// <summary> 298 /// <summary>
299 /// 299 ///
300 /// </summary> 300 /// </summary>
301 /// <param name="newParent"></param> 301 /// <param name="newParent"></param>
302 /// <param name="rootParent"></param> 302 /// <param name="rootParent"></param>
303 public void SetNewParent(Primitive newParent, SceneObject rootParent) 303 public void SetNewParent(Primitive newParent, SceneObject rootParent)
304 { 304 {
305 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); 305 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
306 this.m_isRootPrim = false; 306 this.m_isRootPrim = false;
307 this.m_Parent = newParent; 307 this.m_Parent = newParent;
308 this.ParentID = newParent.LocalId; 308 this.ParentID = newParent.LocalId;
309 this.m_RootParent = rootParent; 309 this.m_RootParent = rootParent;
310 this.m_RootParent.AddChildToList(this); 310 this.m_RootParent.AddChildToList(this);
311 this.Pos = oldPos; 311 this.Pos = oldPos;
312 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); 312 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
313 axPos = this.m_Parent.Rotation.Inverse() * axPos; 313 axPos = this.m_Parent.Rotation.Inverse() * axPos;
314 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 314 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
315 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); 315 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
316 this.Rotation = this.m_Parent.Rotation.Inverse() * this.Rotation; 316 this.Rotation = this.m_Parent.Rotation.Inverse() * this.Rotation;
317 this.updateFlag = 1; 317 this.updateFlag = 1;
318 318
319 foreach (Primitive child in children) 319 foreach (Primitive child in children)
320 { 320 {
321 child.SetRootParent(rootParent, newParent, oldPos, oldRot); 321 child.SetRootParent(rootParent, newParent, oldPos, oldRot);
322 } 322 }
323 children.Clear(); 323 children.Clear();
324 324
325 325
326 } 326 }
327 327
328 /// <summary> 328 /// <summary>
329 /// 329 ///
330 /// </summary> 330 /// </summary>
331 /// <param name="newRoot"></param> 331 /// <param name="newRoot"></param>
332 public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation) 332 public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition, Axiom.Math.Quaternion oldParentRotation)
333 { 333 {
334 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); 334 LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z);
335 Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z); 335 Axiom.Math.Vector3 axOldPos = new Vector3(oldPos.X, oldPos.Y, oldPos.Z);
336 axOldPos = oldParentRotation * axOldPos; 336 axOldPos = oldParentRotation * axOldPos;
337 oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z); 337 oldPos = new LLVector3(axOldPos.x, axOldPos.y, axOldPos.z);
338 oldPos += oldParentPosition; 338 oldPos += oldParentPosition;
339 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); 339 Axiom.Math.Quaternion oldRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
340 this.m_isRootPrim = false; 340 this.m_isRootPrim = false;
341 this.m_Parent = newParent; 341 this.m_Parent = newParent;
342 this.ParentID = newParent.LocalId; 342 this.ParentID = newParent.LocalId;
343 newParent.AddToChildrenList(this); 343 newParent.AddToChildrenList(this);
344 this.m_RootParent = newRoot; 344 this.m_RootParent = newRoot;
345 this.m_RootParent.AddChildToList(this); 345 this.m_RootParent.AddChildToList(this);
346 this.Pos = oldPos; 346 this.Pos = oldPos;
347 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); 347 Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z);
348 axPos = this.m_Parent.Rotation.Inverse() * axPos; 348 axPos = this.m_Parent.Rotation.Inverse() * axPos;
349 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 349 this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
350 this.Rotation = oldParentRotation * this.Rotation; 350 this.Rotation = oldParentRotation * this.Rotation;
351 this.Rotation = this.m_Parent.Rotation.Inverse()* this.Rotation ; 351 this.Rotation = this.m_Parent.Rotation.Inverse()* this.Rotation ;
352 this.updateFlag = 1; 352 this.updateFlag = 1;
353 foreach (Primitive child in children) 353 foreach (Primitive child in children)
354 { 354 {
355 child.SetRootParent(newRoot, newParent, oldPos, oldRot); 355 child.SetRootParent(newRoot, newParent, oldPos, oldRot);
356 } 356 }
357 children.Clear(); 357 children.Clear();
358 } 358 }
359 359
360 /// <summary> 360 /// <summary>
361 /// 361 ///
362 /// </summary> 362 /// </summary>
363 /// <param name="offset"></param> 363 /// <param name="offset"></param>
364 public void AddOffsetToChildren(LLVector3 offset) 364 public void AddOffsetToChildren(LLVector3 offset)
365 { 365 {
366 foreach (Primitive prim in this.children) 366 foreach (Primitive prim in this.children)
367 { 367 {
368 prim.m_pos += offset; 368 prim.m_pos += offset;
369 prim.updateFlag = 2; 369 prim.updateFlag = 2;
370 } 370 }
371 this.OnPrimCountTainted(); 371 this.OnPrimCountTainted();
372 } 372 }
373 373
374 /// <summary> 374 /// <summary>
375 /// 375 ///
376 /// </summary> 376 /// </summary>
377 /// <param name="prim"></param> 377 /// <param name="prim"></param>
378 public void AddToChildrenList(Primitive prim) 378 public void AddToChildrenList(Primitive prim)
379 { 379 {
380 this.children.Add(prim); 380 this.children.Add(prim);
381 } 381 }
382 #endregion 382 #endregion
383 383
384 #region Resizing/Scale 384 #region Resizing/Scale
385 /// <summary> 385 /// <summary>
386 /// 386 ///
387 /// </summary> 387 /// </summary>
388 /// <param name="scale"></param> 388 /// <param name="scale"></param>
389 public void ResizeGoup(LLVector3 scale) 389 public void ResizeGoup(LLVector3 scale)
390 { 390 {
391 LLVector3 offset = (scale - this.m_Shape.Scale); 391 LLVector3 offset = (scale - this.m_Shape.Scale);
392 offset.X /= 2; 392 offset.X /= 2;
393 offset.Y /= 2; 393 offset.Y /= 2;
394 offset.Z /= 2; 394 offset.Z /= 2;
395 if (this.m_isRootPrim) 395 if (this.m_isRootPrim)
396 { 396 {
397 this.m_Parent.Pos += offset; 397 this.m_Parent.Pos += offset;
398 } 398 }
399 else 399 else
400 { 400 {
401 this.m_pos += offset; 401 this.m_pos += offset;
402 } 402 }
403 403
404 this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z)); 404 this.AddOffsetToChildren(new LLVector3(-offset.X, -offset.Y, -offset.Z));
405 this.m_Shape.Scale = scale; 405 this.m_Shape.Scale = scale;
406 406
407 this.updateFlag = 1; 407 this.updateFlag = 1;
408 } 408 }
409 #endregion 409 #endregion
410 410
411 #region Position 411 #region Position
412 /// <summary> 412 /// <summary>
413 /// 413 ///
414 /// </summary> 414 /// </summary>
415 /// <param name="pos"></param> 415 /// <param name="pos"></param>
416 public void UpdateGroupPosition(LLVector3 pos) 416 public void UpdateGroupPosition(LLVector3 pos)
417 { 417 {
418 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); 418 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
419 419
420 this.Pos = newPos; 420 this.Pos = newPos;
421 this.updateFlag = 2; 421 this.updateFlag = 2;
422 422
423 this.OnPrimCountTainted(); 423 this.OnPrimCountTainted();
424 } 424 }
425 425
426 /// <summary> 426 /// <summary>
427 /// 427 ///
428 /// </summary> 428 /// </summary>
429 /// <param name="pos"></param> 429 /// <param name="pos"></param>
430 public void UpdateSinglePosition(LLVector3 pos) 430 public void UpdateSinglePosition(LLVector3 pos)
431 { 431 {
432 // Console.WriteLine("updating single prim position"); 432 // Console.WriteLine("updating single prim position");
433 if (this.m_isRootPrim) 433 if (this.m_isRootPrim)
434 { 434 {
435 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); 435 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
436 LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); 436 LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z);
437 LLVector3 diff = oldPos - newPos; 437 LLVector3 diff = oldPos - newPos;
438 Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); 438 Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
439 axDiff = this.Rotation.Inverse() * axDiff; 439 axDiff = this.Rotation.Inverse() * axDiff;
440 diff.X = axDiff.x; 440 diff.X = axDiff.x;
441 diff.Y = axDiff.y; 441 diff.Y = axDiff.y;
442 diff.Z = axDiff.z; 442 diff.Z = axDiff.z;
443 this.Pos = newPos; 443 this.Pos = newPos;
444 444
445 foreach (Primitive prim in this.children) 445 foreach (Primitive prim in this.children)
446 { 446 {
447 prim.m_pos += diff; 447 prim.m_pos += diff;
448 prim.updateFlag = 2; 448 prim.updateFlag = 2;
449 } 449 }
450 this.updateFlag = 2; 450 this.updateFlag = 2;
451 } 451 }
452 else 452 else
453 { 453 {
454 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); 454 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
455 this.m_pos = newPos; 455 this.m_pos = newPos;
456 this.updateFlag = 2; 456 this.updateFlag = 2;
457 } 457 }
458 458
459 459
460 } 460 }
461 461
462 #endregion 462 #endregion
463 463
464 #region Rotation 464 #region Rotation
465 /// <summary> 465 /// <summary>
466 /// 466 ///
467 /// </summary> 467 /// </summary>
468 /// <param name="rot"></param> 468 /// <param name="rot"></param>
469 public void UpdateGroupRotation(LLQuaternion rot) 469 public void UpdateGroupRotation(LLQuaternion rot)
470 { 470 {
471 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); 471 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
472 this.updateFlag = 2; 472 this.updateFlag = 2;
473 473
474 } 474 }
475 475
476 /// <summary> 476 /// <summary>
477 /// 477 ///
478 /// </summary> 478 /// </summary>
479 /// <param name="pos"></param> 479 /// <param name="pos"></param>
480 /// <param name="rot"></param> 480 /// <param name="rot"></param>
481 public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) 481 public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot)
482 { 482 {
483 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); 483 this.Rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
484 this.Pos = pos; 484 this.Pos = pos;
485 this.updateFlag = 2; 485 this.updateFlag = 2;
486 } 486 }
487 487
488 /// <summary> 488 /// <summary>
489 /// 489 ///
490 /// </summary> 490 /// </summary>
491 /// <param name="rot"></param> 491 /// <param name="rot"></param>
492 public void UpdateSingleRotation(LLQuaternion rot) 492 public void UpdateSingleRotation(LLQuaternion rot)
493 { 493 {
494 //Console.WriteLine("updating single prim rotation"); 494 //Console.WriteLine("updating single prim rotation");
495 Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); 495 Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z);
496 Axiom.Math.Quaternion oldParentRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z); 496 Axiom.Math.Quaternion oldParentRot = new Quaternion(this.Rotation.w, this.Rotation.x, this.Rotation.y, this.Rotation.z);
497 this.Rotation = axRot; 497 this.Rotation = axRot;
498 foreach (Primitive prim in this.children) 498 foreach (Primitive prim in this.children)
499 { 499 {
500 Axiom.Math.Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z); 500 Axiom.Math.Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z);
501 axPos = oldParentRot * axPos; 501 axPos = oldParentRot * axPos;
502 axPos = axRot.Inverse() * axPos; 502 axPos = axRot.Inverse() * axPos;
503 prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); 503 prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z);
504 prim.Rotation = oldParentRot * prim.Rotation ; 504 prim.Rotation = oldParentRot * prim.Rotation ;
505 prim.Rotation = axRot.Inverse()* prim.Rotation; 505 prim.Rotation = axRot.Inverse()* prim.Rotation;
506 prim.updateFlag = 2; 506 prim.updateFlag = 2;
507 } 507 }
508 this.updateFlag = 2; 508 this.updateFlag = 2;
509 } 509 }
510 #endregion 510 #endregion
511 511
512 #region Shape 512 #region Shape
513 /// <summary> 513 /// <summary>
514 /// 514 ///
515 /// </summary> 515 /// </summary>
516 /// <param name="shapeBlock"></param> 516 /// <param name="shapeBlock"></param>
517 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) 517 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock)
518 { 518 {
519 this.m_Shape.PathBegin = shapeBlock.PathBegin; 519 this.m_Shape.PathBegin = shapeBlock.PathBegin;
520 this.m_Shape.PathEnd = shapeBlock.PathEnd; 520 this.m_Shape.PathEnd = shapeBlock.PathEnd;
521 this.m_Shape.PathScaleX = shapeBlock.PathScaleX; 521 this.m_Shape.PathScaleX = shapeBlock.PathScaleX;
522 this.m_Shape.PathScaleY = shapeBlock.PathScaleY; 522 this.m_Shape.PathScaleY = shapeBlock.PathScaleY;
523 this.m_Shape.PathShearX = shapeBlock.PathShearX; 523 this.m_Shape.PathShearX = shapeBlock.PathShearX;
524 this.m_Shape.PathShearY = shapeBlock.PathShearY; 524 this.m_Shape.PathShearY = shapeBlock.PathShearY;
525 this.m_Shape.PathSkew = shapeBlock.PathSkew; 525 this.m_Shape.PathSkew = shapeBlock.PathSkew;
526 this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin; 526 this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin;
527 this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd; 527 this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd;
528 this.m_Shape.PathCurve = shapeBlock.PathCurve; 528 this.m_Shape.PathCurve = shapeBlock.PathCurve;
529 this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve; 529 this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve;
530 this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow; 530 this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow;
531 this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; 531 this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset;
532 this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions; 532 this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions;
533 this.m_Shape.PathTaperX = shapeBlock.PathTaperX; 533 this.m_Shape.PathTaperX = shapeBlock.PathTaperX;
534 this.m_Shape.PathTaperY = shapeBlock.PathTaperY; 534 this.m_Shape.PathTaperY = shapeBlock.PathTaperY;
535 this.m_Shape.PathTwist = shapeBlock.PathTwist; 535 this.m_Shape.PathTwist = shapeBlock.PathTwist;
536 this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; 536 this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin;
537 this.updateFlag = 1; 537 this.updateFlag = 1;
538 } 538 }
539 #endregion 539 #endregion
540 540
541 #region Texture 541 #region Texture
542 /// <summary> 542 /// <summary>
543 /// 543 ///
544 /// </summary> 544 /// </summary>
545 /// <param name="textureEntry"></param> 545 /// <param name="textureEntry"></param>
546 public void UpdateTextureEntry(byte[] textureEntry) 546 public void UpdateTextureEntry(byte[] textureEntry)
547 { 547 {
548 this.m_Shape.TextureEntry = textureEntry; 548 this.m_Shape.TextureEntry = textureEntry;
549 this.updateFlag = 1; 549 this.updateFlag = 1;
550 } 550 }
551 #endregion 551 #endregion
552 552
553 #region Client Update Methods 553 #region Client Update Methods
554 554
555 /// <summary> 555 /// <summary>
556 /// 556 ///
557 /// </summary> 557 /// </summary>
558 /// <param name="remoteClient"></param> 558 /// <param name="remoteClient"></param>
559 public void SendFullUpdateForAllChildren(IClientAPI remoteClient) 559 public void SendFullUpdateForAllChildren(IClientAPI remoteClient)
560 { 560 {
561 this.SendFullUpdateToClient(remoteClient); 561 this.SendFullUpdateToClient(remoteClient);
562 for (int i = 0; i < this.children.Count; i++) 562 for (int i = 0; i < this.children.Count; i++)
563 { 563 {
564 if (this.children[i] is Primitive) 564 if (this.children[i] is Primitive)
565 { 565 {
566 ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient); 566 ((Primitive)this.children[i]).SendFullUpdateForAllChildren(remoteClient);
567 } 567 }
568 } 568 }
569 } 569 }
570 570
571 /// <summary> 571 /// <summary>
572 /// 572 ///
573 /// </summary> 573 /// </summary>
574 /// <param name="remoteClient"></param> 574 /// <param name="remoteClient"></param>
575 public void SendFullUpdateToClient(IClientAPI remoteClient) 575 public void SendFullUpdateToClient(IClientAPI remoteClient)
576 { 576 {
577 LLVector3 lPos; 577 LLVector3 lPos;
578 lPos = this.Pos; 578 lPos = this.Pos;
579 LLQuaternion lRot; 579 LLQuaternion lRot;
580 lRot = new LLQuaternion(this.Rotation.x, this.Rotation.y, this.Rotation.z, this.Rotation.w); 580 lRot = new LLQuaternion(this.Rotation.x, this.Rotation.y, this.Rotation.z, this.Rotation.w);
581 581
582 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, this.m_flags, this.uuid, this.OwnerID, this.Text, this.ParentID); 582 remoteClient.SendPrimitiveToClient(this.m_regionHandle, 64096, this.LocalId, this.m_Shape, lPos, lRot, this.m_flags, this.uuid, this.OwnerID, this.Text, this.ParentID);
583 } 583 }
584 584
585 /// <summary> 585 /// <summary>
586 /// 586 ///
587 /// </summary> 587 /// </summary>
588 public void SendFullUpdateToAllClients() 588 public void SendFullUpdateToAllClients()
589 { 589 {
590 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 590 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
591 for (int i = 0; i < avatars.Count; i++) 591 for (int i = 0; i < avatars.Count; i++)
592 { 592 {
593 this.SendFullUpdateToClient(avatars[i].ControllingClient); 593 this.SendFullUpdateToClient(avatars[i].ControllingClient);
594 } 594 }
595 } 595 }
596 596
597 /// <summary> 597 /// <summary>
598 /// 598 ///
599 /// </summary> 599 /// </summary>
600 /// <param name="remoteClient"></param> 600 /// <param name="remoteClient"></param>
601 public void SendTerseUpdateForAllChildren(IClientAPI remoteClient) 601 public void SendTerseUpdateForAllChildren(IClientAPI remoteClient)
602 { 602 {
603 this.SendTerseUpdateToClient(remoteClient); 603 this.SendTerseUpdateToClient(remoteClient);
604 for (int i = 0; i < this.children.Count; i++) 604 for (int i = 0; i < this.children.Count; i++)
605 { 605 {
606 if (this.children[i] is Primitive) 606 if (this.children[i] is Primitive)
607 { 607 {
608 ((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient); 608 ((Primitive)this.children[i]).SendTerseUpdateForAllChildren(remoteClient);
609 } 609 }
610 } 610 }
611 } 611 }
612 612
613 /// <summary> 613 /// <summary>
614 /// 614 ///
615 /// </summary> 615 /// </summary>
616 /// <param name="RemoteClient"></param> 616 /// <param name="RemoteClient"></param>
617 public void SendTerseUpdateToClient(IClientAPI RemoteClient) 617 public void SendTerseUpdateToClient(IClientAPI RemoteClient)
618 { 618 {
619 LLVector3 lPos; 619 LLVector3 lPos;
620 Quaternion lRot; 620 Quaternion lRot;
621 621
622 lPos = this.Pos; 622 lPos = this.Pos;
623 lRot = this.Rotation; 623 lRot = this.Rotation;
624 624
625 LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w); 625 LLQuaternion mRot = new LLQuaternion(lRot.x, lRot.y, lRot.z, lRot.w);
626 RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot); 626 RemoteClient.SendPrimTerseUpdate(this.m_regionHandle, 64096, this.LocalId, lPos, mRot);
627 } 627 }
628 628
629 /// <summary> 629 /// <summary>
630 /// 630 ///
631 /// </summary> 631 /// </summary>
632 public void SendTerseUpdateToALLClients() 632 public void SendTerseUpdateToALLClients()
633 { 633 {
634 List<ScenePresence> avatars = this.m_world.RequestAvatarList(); 634 List<ScenePresence> avatars = this.m_world.RequestAvatarList();
635 for (int i = 0; i < avatars.Count; i++) 635 for (int i = 0; i < avatars.Count; i++)
636 { 636 {
637 this.SendTerseUpdateToClient(avatars[i].ControllingClient); 637 this.SendTerseUpdateToClient(avatars[i].ControllingClient);
638 } 638 }
639 } 639 }
640 640
641 #endregion 641 #endregion
642 642
643 public void TriggerOnPrimCountTainted() 643 public void TriggerOnPrimCountTainted()
644 { 644 {
645 this.OnPrimCountTainted(); 645 this.OnPrimCountTainted();
646 } 646 }
647 } 647 }
648} 648}