diff options
author | MW | 2007-07-18 13:40:07 +0000 |
---|---|---|
committer | MW | 2007-07-18 13:40:07 +0000 |
commit | 04ece84d6b3aa442ed7413f23b0daa30ff6d3ee8 (patch) | |
tree | e457adc88cfa763d6e3fb3734b253f94b2aa775b /OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup.cs | |
parent | * Added a FileSystemObject to SimpleApp (diff) | |
download | opensim-SC-04ece84d6b3aa442ed7413f23b0daa30ff6d3ee8.zip opensim-SC-04ece84d6b3aa442ed7413f23b0daa30ff6d3ee8.tar.gz opensim-SC-04ece84d6b3aa442ed7413f23b0daa30ff6d3ee8.tar.bz2 opensim-SC-04ece84d6b3aa442ed7413f23b0daa30ff6d3ee8.tar.xz |
few small changes
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup.cs | 244 |
1 files changed, 244 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup.cs new file mode 100644 index 0000000..b04340a --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup.cs | |||
@@ -0,0 +1,244 @@ | |||
1 | using System.Collections.Generic; | ||
2 | using System.Text; | ||
3 | using Axiom.Math; | ||
4 | using libsecondlife; | ||
5 | using libsecondlife.Packets; | ||
6 | using OpenSim.Framework.Interfaces; | ||
7 | using OpenSim.Framework.Types; | ||
8 | using OpenSim.Physics.Manager; | ||
9 | |||
10 | namespace OpenSim.Region.Environment.Scenes | ||
11 | { | ||
12 | public delegate void PrimCountTaintedDelegate(); | ||
13 | |||
14 | public class AllNewSceneObjectGroup : EntityBase | ||
15 | { | ||
16 | private Encoding enc = Encoding.ASCII; | ||
17 | |||
18 | protected AllNewSceneObjectPart m_rootPart; | ||
19 | protected Dictionary<LLUUID, AllNewSceneObjectPart> m_parts = new Dictionary<LLUUID, AllNewSceneObjectPart>(); | ||
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 AllNewSceneObjectGroup() | ||
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(AllNewSceneObjectGroup objectGroup) | ||
74 | { | ||
75 | |||
76 | } | ||
77 | |||
78 | /// <summary> | ||
79 | /// | ||
80 | /// </summary> | ||
81 | /// <param name="primID"></param> | ||
82 | /// <returns></returns> | ||
83 | public AllNewSceneObjectPart HasChildPrim(LLUUID primID) | ||
84 | { | ||
85 | AllNewSceneObjectPart 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 | public AllNewSceneObjectPart HasChildPrim(uint localID) | ||
99 | { | ||
100 | foreach (AllNewSceneObjectPart 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 | /// <summary> | ||
163 | /// | ||
164 | /// </summary> | ||
165 | /// <param name="part"></param> | ||
166 | private void SetPartAsRoot(AllNewSceneObjectPart part) | ||
167 | { | ||
168 | this.m_rootPart = part; | ||
169 | this.m_uuid = part.uuid; | ||
170 | this.m_localId = part.m_localID; | ||
171 | part.ParentID = 0; | ||
172 | part.UpdateHandler = delegate(ref LLVector3 pos, UpdateType direction, AllNewSceneObjectPart objectPart) | ||
173 | { | ||
174 | switch (direction) | ||
175 | { | ||
176 | case UpdateType.InComingNewPosition: | ||
177 | this.m_pos = new LLVector3(pos.X, pos.Y, pos.Z); | ||
178 | pos.X = 0; | ||
179 | pos.Y = 0; | ||
180 | pos.Z = 0; | ||
181 | break; | ||
182 | |||
183 | case UpdateType.SinglePositionEdit: | ||
184 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); | ||
185 | LLVector3 oldPos = new LLVector3(this.Pos.X + objectPart.OffsetPosition.X, this.Pos.Y + objectPart.OffsetPosition.Y, this.Pos.Z + objectPart.OffsetPosition.Z); | ||
186 | LLVector3 diff = oldPos - newPos; | ||
187 | Axiom.Math.Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z); | ||
188 | Axiom.Math.Quaternion partRotation = new Quaternion(objectPart.RotationOffset.W, objectPart.RotationOffset.X, objectPart.RotationOffset.Y, objectPart.RotationOffset.Z); | ||
189 | axDiff = partRotation.Inverse() * axDiff; | ||
190 | diff.X = axDiff.x; | ||
191 | diff.Y = axDiff.y; | ||
192 | diff.Z = axDiff.z; | ||
193 | |||
194 | foreach (AllNewSceneObjectPart obPart in this.m_parts.Values) | ||
195 | { | ||
196 | if (obPart.uuid == objectPart.uuid) | ||
197 | { | ||
198 | obPart.OffsetPosition = obPart.OffsetPosition + diff; | ||
199 | } | ||
200 | } | ||
201 | this.Pos = newPos; | ||
202 | pos.X = newPos.X; | ||
203 | pos.Y = newPos.Y; | ||
204 | pos.Z = newPos.Z; | ||
205 | break; | ||
206 | |||
207 | case UpdateType.ResizeOffset: | ||
208 | this.Pos += pos; | ||
209 | LLVector3 offset = new LLVector3(-pos.X, -pos.Y, -pos.Z); | ||
210 | foreach (AllNewSceneObjectPart obPart2 in this.m_parts.Values) | ||
211 | { | ||
212 | if (obPart2.uuid == objectPart.uuid) | ||
213 | { | ||
214 | obPart2.OffsetPosition = obPart2.OffsetPosition + offset; | ||
215 | } | ||
216 | } | ||
217 | pos.X = 0; | ||
218 | pos.Y = 0; | ||
219 | pos.Z = 0; | ||
220 | break; | ||
221 | |||
222 | case UpdateType.SingleRotationEdit: | ||
223 | break; | ||
224 | } | ||
225 | |||
226 | |||
227 | return pos; | ||
228 | }; | ||
229 | } | ||
230 | |||
231 | /// <summary> | ||
232 | /// | ||
233 | /// </summary> | ||
234 | /// <param name="part"></param> | ||
235 | private void SetPartAsNonRoot(AllNewSceneObjectPart part) | ||
236 | { | ||
237 | part.ParentID = this.m_rootPart.m_localID; | ||
238 | part.UpdateHandler = delegate(ref LLVector3 pos, UpdateType direction, AllNewSceneObjectPart objectPart) | ||
239 | { | ||
240 | return pos; | ||
241 | }; | ||
242 | } | ||
243 | } | ||
244 | } | ||