aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs')
-rw-r--r--OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs299
1 files changed, 299 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs
new file mode 100644
index 0000000..5d3a406
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs
@@ -0,0 +1,299 @@
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 public event PrimCountTaintedDelegate OnPrimCountTainted;
22
23 /// <summary>
24 ///
25 /// </summary>
26 public int primCount
27 {
28 get
29 {
30 return 1;
31 }
32 }
33
34 /// <summary>
35 ///
36 /// </summary>
37 public LLVector3 GroupCentrePoint
38 {
39 get
40 {
41 return new LLVector3(0, 0, 0);
42 }
43 }
44
45 /// <summary>
46 ///
47 /// </summary>
48 public AllNewSceneObjectGroup2()
49 {
50
51 }
52
53 /// <summary>
54 ///
55 /// </summary>
56 public void FlagGroupForFullUpdate()
57 {
58
59 }
60
61 /// <summary>
62 ///
63 /// </summary>
64 public void FlagGroupForTerseUpdate()
65 {
66
67 }
68
69 /// <summary>
70 ///
71 /// </summary>
72 /// <param name="objectGroup"></param>
73 public void LinkToGroup(AllNewSceneObjectGroup2 objectGroup)
74 {
75
76 }
77
78 /// <summary>
79 ///
80 /// </summary>
81 /// <param name="primID"></param>
82 /// <returns></returns>
83 private AllNewSceneObjectPart2 GetChildPrim(LLUUID primID)
84 {
85 AllNewSceneObjectPart2 childPart = null;
86 if (this.m_parts.ContainsKey(primID))
87 {
88 childPart = this.m_parts[primID];
89 }
90 return childPart;
91 }
92
93 /// <summary>
94 ///
95 /// </summary>
96 /// <param name="localID"></param>
97 /// <returns></returns>
98 private AllNewSceneObjectPart2 GetChildPrim(uint localID)
99 {
100 foreach (AllNewSceneObjectPart2 part in this.m_parts.Values)
101 {
102 if (part.m_localID == localID)
103 {
104 return part;
105 }
106 }
107 return null;
108 }
109
110 public void TriggerTainted()
111 {
112 if (OnPrimCountTainted != null)
113 {
114 this.OnPrimCountTainted();
115 }
116 }
117
118 /// <summary>
119 ///
120 /// </summary>
121 /// <param name="offset"></param>
122 /// <param name="pos"></param>
123 /// <param name="remoteClient"></param>
124 public void GrapMovement(LLVector3 offset, LLVector3 pos, IClientAPI remoteClient)
125 {
126 this.Pos = pos;
127 }
128
129 /// <summary>
130 ///
131 /// </summary>
132 /// <param name="client"></param>
133 public void GetProperites(IClientAPI client)
134 {
135 ObjectPropertiesPacket proper = new ObjectPropertiesPacket();
136 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[1];
137 proper.ObjectData[0] = new ObjectPropertiesPacket.ObjectDataBlock();
138 proper.ObjectData[0].ItemID = LLUUID.Zero;
139 proper.ObjectData[0].CreationDate = (ulong)this.m_rootPart.CreationDate;
140 proper.ObjectData[0].CreatorID = this.m_rootPart.CreatorID;
141 proper.ObjectData[0].FolderID = LLUUID.Zero;
142 proper.ObjectData[0].FromTaskID = LLUUID.Zero;
143 proper.ObjectData[0].GroupID = LLUUID.Zero;
144 proper.ObjectData[0].InventorySerial = 0;
145 proper.ObjectData[0].LastOwnerID = this.m_rootPart.LastOwnerID;
146 proper.ObjectData[0].ObjectID = this.m_uuid;
147 proper.ObjectData[0].OwnerID = this.m_rootPart.OwnerID;
148 proper.ObjectData[0].TouchName = enc.GetBytes(this.m_rootPart.TouchName + "\0");
149 proper.ObjectData[0].TextureID = new byte[0];
150 proper.ObjectData[0].SitName = enc.GetBytes(this.m_rootPart.SitName + "\0");
151 proper.ObjectData[0].Name = enc.GetBytes(this.m_rootPart.Name + "\0");
152 proper.ObjectData[0].Description = enc.GetBytes(this.m_rootPart.Description + "\0");
153 proper.ObjectData[0].OwnerMask = this.m_rootPart.OwnerMask;
154 proper.ObjectData[0].NextOwnerMask = this.m_rootPart.NextOwnerMask;
155 proper.ObjectData[0].GroupMask = this.m_rootPart.GroupMask;
156 proper.ObjectData[0].EveryoneMask = this.m_rootPart.EveryoneMask;
157 proper.ObjectData[0].BaseMask = this.m_rootPart.BaseMask;
158
159 client.OutPacket(proper);
160 }
161
162 #region Shape
163 /// <summary>
164 ///
165 /// </summary>
166 /// <param name="shapeBlock"></param>
167 public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock, uint localID)
168 {
169 AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
170 if (part != null)
171 {
172 part.UpdateShape(shapeBlock);
173 }
174 }
175 #endregion
176
177 #region Position
178 public void UpdateGroupPosition(LLVector3 pos)
179 {
180 this.m_pos = pos;
181 }
182
183 public void UpdateSinglePosition(LLVector3 pos, uint localID)
184 {
185 AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
186 if (part != null)
187 {
188 if (part.uuid == this.m_rootPart.uuid)
189 {
190 this.UpdateRootPosition(pos);
191 }
192 else
193 {
194 part.UpdateOffSet(pos);
195 }
196 }
197 }
198
199 private void UpdateRootPosition(LLVector3 pos)
200 {
201 LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z);
202 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);
203 LLVector3 diff = oldPos - newPos;
204 Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
205 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);
206 axDiff = partRotation.Inverse() * axDiff;
207 diff.X = axDiff.x;
208 diff.Y = axDiff.y;
209 diff.Z = axDiff.z;
210
211 foreach (AllNewSceneObjectPart2 obPart in this.m_parts.Values)
212 {
213 if (obPart.uuid != this.m_rootPart.uuid)
214 {
215 obPart.OffsetPosition = obPart.OffsetPosition + diff;
216 }
217 }
218 this.Pos = newPos;
219 pos.X = newPos.X;
220 pos.Y = newPos.Y;
221 pos.Z = newPos.Z;
222 }
223 #endregion
224
225 #region Roation
226 public void UpdateGroupRotation(LLQuaternion rot)
227 {
228 this.m_rootPart.RotationOffset = new LLQuaternion(rot.X, rot.Y, rot.Z, rot.W);
229 }
230
231 /// <summary>
232 ///
233 /// </summary>
234 /// <param name="pos"></param>
235 /// <param name="rot"></param>
236 public void UpdateGroupMouseRotation(LLVector3 pos, LLQuaternion rot)
237 {
238 this.m_rootPart.RotationOffset = new LLQuaternion(rot.X, rot.Y, rot.Z, rot.W);
239 this.m_pos = pos;
240 }
241
242 public void UpdateSingleRotation(LLQuaternion rot, uint localID)
243 {
244 AllNewSceneObjectPart2 part = this.GetChildPrim(localID);
245 if (part != null)
246 {
247 if (part.uuid == this.m_rootPart.uuid)
248 {
249 this.UpdateRootRotation(rot);
250 }
251 else
252 {
253 part.UpdateRotation(rot);
254 }
255 }
256 }
257 private void UpdateRootRotation(LLQuaternion rot)
258 {
259 this.m_rootPart.UpdateRotation(rot);
260 Axiom.Math.Quaternion axRot = new Quaternion(rot.W, rot.X, rot.Y, rot.Z);
261 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);
262
263 foreach (AllNewSceneObjectPart2 prim in this.m_parts.Values)
264 {
265 if (prim.uuid != this.m_rootPart.uuid)
266 {
267 Vector3 axPos = new Vector3(prim.OffsetPosition.X, prim.OffsetPosition.Y, prim.OffsetPosition.Z);
268 axPos = oldParentRot * axPos;
269 axPos = axRot.Inverse() * axPos;
270 prim.OffsetPosition = new LLVector3(axPos.x, axPos.y, axPos.z);
271 Axiom.Math.Quaternion primsRot = new Quaternion(prim.RotationOffset.W, prim.RotationOffset.X, prim.RotationOffset.Y, prim.RotationOffset.Z);
272 Axiom.Math.Quaternion newRot = oldParentRot * primsRot;
273 newRot = axRot.Inverse() * newRot;
274 prim.RotationOffset = new LLQuaternion(newRot.w, newRot.x, newRot.y, newRot.z);
275 }
276 }
277 }
278 #endregion
279 /// <summary>
280 ///
281 /// </summary>
282 /// <param name="part"></param>
283 private void SetPartAsRoot(AllNewSceneObjectPart2 part)
284 {
285 this.m_rootPart = part;
286 this.m_uuid = part.uuid;
287 this.m_localId = part.m_localID;
288 }
289
290 /// <summary>
291 ///
292 /// </summary>
293 /// <param name="part"></param>
294 private void SetPartAsNonRoot(AllNewSceneObjectPart2 part)
295 {
296
297 }
298 }
299}