diff options
A bit more work on Building tools/support.
updated Axiom.MathLib.dll.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Primitive.cs | 124 |
1 files changed, 116 insertions, 8 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index 803bd28..24dc115 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs | |||
@@ -1,6 +1,6 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using Axiom.MathLib; | 3 | using Axiom.Math; |
4 | using libsecondlife; | 4 | using libsecondlife; |
5 | using libsecondlife.Packets; | 5 | using libsecondlife.Packets; |
6 | using OpenSim.Framework.Interfaces; | 6 | using OpenSim.Framework.Interfaces; |
@@ -45,6 +45,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
45 | public bool isRootPrim; | 45 | public bool isRootPrim; |
46 | public EntityBase m_Parent; | 46 | public EntityBase m_Parent; |
47 | 47 | ||
48 | #region Properties | ||
48 | public override LLVector3 Pos | 49 | public override LLVector3 Pos |
49 | { | 50 | { |
50 | get | 51 | get |
@@ -69,6 +70,22 @@ namespace OpenSim.Region.Environment.Scenes | |||
69 | 70 | ||
70 | } | 71 | } |
71 | 72 | ||
73 | public LLVector3 WorldPos | ||
74 | { | ||
75 | get | ||
76 | { | ||
77 | if (!this.isRootPrim) | ||
78 | { | ||
79 | Primitive parentPrim = (Primitive)this.m_Parent; | ||
80 | return this.m_pos + parentPrim.WorldPos; | ||
81 | } | ||
82 | else | ||
83 | { | ||
84 | return this.Pos; | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
72 | public string Description | 89 | public string Description |
73 | { | 90 | { |
74 | get | 91 | get |
@@ -92,7 +109,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
92 | return this.m_Shape.Scale; | 109 | return this.m_Shape.Scale; |
93 | } | 110 | } |
94 | } | 111 | } |
112 | #endregion | ||
95 | 113 | ||
114 | #region Constructors | ||
96 | public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject) | 115 | public Primitive(ulong regionHandle, Scene world, ObjectAddPacket addPacket, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject) |
97 | { | 116 | { |
98 | m_regionHandle = regionHandle; | 117 | m_regionHandle = regionHandle; |
@@ -102,9 +121,11 @@ namespace OpenSim.Region.Environment.Scenes | |||
102 | this.isRootPrim = isRoot; | 121 | this.isRootPrim = isRoot; |
103 | this.m_RootParent = rootObject; | 122 | this.m_RootParent = rootObject; |
104 | this.CreateFromPacket(addPacket, ownerID, localID); | 123 | this.CreateFromPacket(addPacket, ownerID, localID); |
105 | this.rotation = Axiom.MathLib.Quaternion.Identity; | 124 | this.rotation = Axiom.Math.Quaternion.Identity; |
106 | } | 125 | } |
126 | #endregion | ||
107 | 127 | ||
128 | #region Override from EntityBase | ||
108 | /// <summary> | 129 | /// <summary> |
109 | /// | 130 | /// |
110 | /// </summary> | 131 | /// </summary> |
@@ -126,7 +147,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
126 | child.update(); | 147 | child.update(); |
127 | } | 148 | } |
128 | } | 149 | } |
150 | #endregion | ||
129 | 151 | ||
152 | #region Setup | ||
130 | /// <summary> | 153 | /// <summary> |
131 | /// | 154 | /// |
132 | /// </summary> | 155 | /// </summary> |
@@ -169,7 +192,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
169 | 192 | ||
170 | this.updateFlag = 1; | 193 | this.updateFlag = 1; |
171 | } | 194 | } |
195 | #endregion | ||
172 | 196 | ||
197 | #region Linking / unlinking | ||
173 | /// <summary> | 198 | /// <summary> |
174 | /// | 199 | /// |
175 | /// </summary> | 200 | /// </summary> |
@@ -196,28 +221,49 @@ namespace OpenSim.Region.Environment.Scenes | |||
196 | this.isRootPrim = false; | 221 | this.isRootPrim = false; |
197 | this.m_Parent = newParent; | 222 | this.m_Parent = newParent; |
198 | this.ParentID = newParent.LocalId; | 223 | this.ParentID = newParent.LocalId; |
199 | this.SetRootParent(rootParent); | 224 | this.m_RootParent = rootParent; |
225 | this.m_RootParent.AddChildToList(this); | ||
200 | this.Pos = oldPos; | 226 | this.Pos = oldPos; |
201 | Axiom.MathLib.Vector3 axPos = new Axiom.MathLib.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); | 227 | Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); |
202 | axPos = this.m_Parent.rotation.Inverse() * axPos; | 228 | axPos = this.m_Parent.rotation.Inverse() * axPos; |
203 | this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); | 229 | this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); |
204 | this.rotation = this.rotation * this.m_Parent.rotation.Inverse(); | 230 | this.rotation = this.rotation * this.m_Parent.rotation.Inverse(); |
205 | this.updateFlag = 1; | 231 | this.updateFlag = 1; |
206 | 232 | ||
233 | foreach (Primitive child in children) | ||
234 | { | ||
235 | child.SetRootParent(rootParent, newParent, oldPos); | ||
236 | } | ||
237 | children.Clear(); | ||
238 | |||
239 | |||
207 | } | 240 | } |
208 | 241 | ||
209 | /// <summary> | 242 | /// <summary> |
210 | /// | 243 | /// |
211 | /// </summary> | 244 | /// </summary> |
212 | /// <param name="newRoot"></param> | 245 | /// <param name="newRoot"></param> |
213 | public void SetRootParent(SceneObject newRoot) | 246 | public void SetRootParent(SceneObject newRoot , Primitive newParent, LLVector3 oldParentPosition) |
214 | { | 247 | { |
248 | LLVector3 oldPos = new LLVector3(this.Pos.X, this.Pos.Y, this.Pos.Z); | ||
249 | oldPos += oldParentPosition; | ||
250 | this.isRootPrim = false; | ||
251 | this.m_Parent = newParent; | ||
252 | this.ParentID = newParent.LocalId; | ||
253 | newParent.AddToChildrenList(this); | ||
215 | this.m_RootParent = newRoot; | 254 | this.m_RootParent = newRoot; |
216 | this.m_RootParent.AddChildToList(this); | 255 | this.m_RootParent.AddChildToList(this); |
256 | this.Pos = oldPos; | ||
257 | Axiom.Math.Vector3 axPos = new Axiom.Math.Vector3(this.m_pos.X, m_pos.Y, m_pos.Z); | ||
258 | axPos = this.m_Parent.rotation.Inverse() * axPos; | ||
259 | this.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); | ||
260 | this.rotation = this.rotation * this.m_Parent.rotation.Inverse(); | ||
261 | this.updateFlag = 1; | ||
217 | foreach (Primitive child in children) | 262 | foreach (Primitive child in children) |
218 | { | 263 | { |
219 | child.SetRootParent(newRoot); | 264 | child.SetRootParent(newRoot, newParent, oldPos); |
220 | } | 265 | } |
266 | children.Clear(); | ||
221 | } | 267 | } |
222 | 268 | ||
223 | public void AddOffsetToChildren(LLVector3 offset) | 269 | public void AddOffsetToChildren(LLVector3 offset) |
@@ -229,6 +275,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
229 | } | 275 | } |
230 | } | 276 | } |
231 | 277 | ||
278 | public void AddToChildrenList(Primitive prim) | ||
279 | { | ||
280 | this.children.Add(prim); | ||
281 | } | ||
282 | #endregion | ||
283 | |||
232 | #region Resizing/Scale | 284 | #region Resizing/Scale |
233 | public void ResizeGoup(LLVector3 scale) | 285 | public void ResizeGoup(LLVector3 scale) |
234 | { | 286 | { |
@@ -252,6 +304,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
252 | } | 304 | } |
253 | #endregion | 305 | #endregion |
254 | 306 | ||
307 | #region Position | ||
255 | /// <summary> | 308 | /// <summary> |
256 | /// | 309 | /// |
257 | /// </summary> | 310 | /// </summary> |
@@ -264,19 +317,73 @@ namespace OpenSim.Region.Environment.Scenes | |||
264 | this.updateFlag = 2; | 317 | this.updateFlag = 2; |
265 | } | 318 | } |
266 | 319 | ||
320 | public void UpdateSinglePosition(LLVector3 pos) | ||
321 | { | ||
322 | //Console.WriteLine("updating single prim position"); | ||
323 | if (this.isRootPrim) | ||
324 | { | ||
325 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); | ||
326 | LLVector3 oldPos = new LLVector3(Pos.X, Pos.Y, Pos.Z); | ||
327 | LLVector3 diff = oldPos - newPos; | ||
328 | Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); | ||
329 | axDiff = this.rotation.Inverse() * axDiff; | ||
330 | diff.X = axDiff.x; | ||
331 | diff.Y = axDiff.y; | ||
332 | diff.Z = axDiff.z; | ||
333 | this.Pos = newPos; | ||
334 | |||
335 | foreach (Primitive prim in this.children) | ||
336 | { | ||
337 | prim.m_pos += diff; | ||
338 | prim.updateFlag = 2; | ||
339 | } | ||
340 | this.updateFlag = 2; | ||
341 | } | ||
342 | else | ||
343 | { | ||
344 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); | ||
345 | this.m_pos = newPos; | ||
346 | this.updateFlag = 2; | ||
347 | } | ||
348 | } | ||
349 | |||
350 | #endregion | ||
351 | |||
352 | #region Rotation | ||
267 | public void UpdateRotation(LLQuaternion rot) | 353 | public void UpdateRotation(LLQuaternion rot) |
268 | { | 354 | { |
269 | this.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z); | 355 | this.rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); |
356 | this.updateFlag = 2; | ||
357 | } | ||
358 | |||
359 | public void UpdateSingleRotation(LLQuaternion rot) | ||
360 | { | ||
361 | Axiom.Math.Quaternion axRot = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); | ||
362 | Axiom.Math.Quaternion oldParentRot = new Quaternion(this.rotation.w, this.rotation.x, this.rotation.y, this.rotation.z); | ||
363 | this.rotation = axRot; | ||
364 | foreach (Primitive prim in this.children) | ||
365 | { | ||
366 | Axiom.Math.Vector3 axPos = new Vector3(prim.m_pos.X, prim.m_pos.Y, prim.m_pos.Z); | ||
367 | axPos = oldParentRot * axPos; | ||
368 | axPos = axRot.Inverse() * axPos; | ||
369 | prim.m_pos = new LLVector3(axPos.x, axPos.y, axPos.z); | ||
370 | prim.rotation = prim.rotation * oldParentRot; | ||
371 | prim.rotation = prim.rotation * axRot.Inverse(); | ||
372 | prim.updateFlag = 2; | ||
373 | } | ||
270 | this.updateFlag = 2; | 374 | this.updateFlag = 2; |
271 | } | 375 | } |
272 | 376 | ||
273 | public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) | 377 | public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot) |
274 | { | 378 | { |
275 | this.rotation = new Axiom.MathLib.Quaternion(rot.W, rot.X, rot.Y, rot.Z); | 379 | this.rotation = new Axiom.Math.Quaternion(rot.W, rot.X, rot.Y, rot.Z); |
276 | this.Pos = pos; | 380 | this.Pos = pos; |
277 | this.updateFlag = 2; | 381 | this.updateFlag = 2; |
278 | } | 382 | } |
279 | 383 | ||
384 | #endregion | ||
385 | |||
386 | #region Shape | ||
280 | public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) | 387 | public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) |
281 | { | 388 | { |
282 | this.m_Shape.PathBegin = shapeBlock.PathBegin; | 389 | this.m_Shape.PathBegin = shapeBlock.PathBegin; |
@@ -299,6 +406,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
299 | this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; | 406 | this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; |
300 | this.updateFlag = 1; | 407 | this.updateFlag = 1; |
301 | } | 408 | } |
409 | #endregion | ||
302 | 410 | ||
303 | #region Client Update Methods | 411 | #region Client Update Methods |
304 | 412 | ||