diff options
author | MW | 2007-07-18 18:12:16 +0000 |
---|---|---|
committer | MW | 2007-07-18 18:12:16 +0000 |
commit | 643a02ec60151e1a501d1b260592695b90be6233 (patch) | |
tree | 55ec1fe8a36c91e8a59a579f62050b6d7b960345 /OpenSim/Region/Environment | |
parent | Just trying things out, nothing to see here, please go back to sleep. (diff) | |
download | opensim-SC-643a02ec60151e1a501d1b260592695b90be6233.zip opensim-SC-643a02ec60151e1a501d1b260592695b90be6233.tar.gz opensim-SC-643a02ec60151e1a501d1b260592695b90be6233.tar.bz2 opensim-SC-643a02ec60151e1a501d1b260592695b90be6233.tar.xz |
More testing some ideas, to find best method for SceneObject Primitive classes.
Diffstat (limited to 'OpenSim/Region/Environment')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/AllNewSceneObjectGroup2.cs | 299 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs | 211 |
2 files changed, 510 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 @@ | |||
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 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 | } | ||
diff --git a/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs new file mode 100644 index 0000000..b0df4af --- /dev/null +++ b/OpenSim/Region/Environment/Scenes/AllNewSceneObjectPart2.cs | |||
@@ -0,0 +1,211 @@ | |||
1 | using System.Collections.Generic; | ||
2 | using System.Text; | ||
3 | using System; | ||
4 | using Axiom.Math; | ||
5 | using libsecondlife; | ||
6 | using libsecondlife.Packets; | ||
7 | using OpenSim.Framework.Interfaces; | ||
8 | using OpenSim.Framework.Types; | ||
9 | |||
10 | namespace OpenSim.Region.Environment.Scenes | ||
11 | { | ||
12 | |||
13 | public class AllNewSceneObjectPart2 | ||
14 | { | ||
15 | private const uint FULL_MASK_PERMISSIONS = 2147483647; | ||
16 | |||
17 | private ulong m_regionHandle; | ||
18 | private uint m_flags = 32 + 65536 + 131072 + 256 + 4 + 8 + 2048 + 524288 + 268435456 + 128; | ||
19 | //private Dictionary<LLUUID, InventoryItem> inventoryItems; | ||
20 | |||
21 | public string SitName = ""; | ||
22 | public string TouchName = ""; | ||
23 | public string Text = ""; | ||
24 | |||
25 | public LLUUID CreatorID; | ||
26 | public LLUUID OwnerID; | ||
27 | public LLUUID LastOwnerID; | ||
28 | public Int32 CreationDate; | ||
29 | |||
30 | public LLUUID uuid; | ||
31 | public uint m_localID; | ||
32 | |||
33 | public uint ParentID = 0; | ||
34 | |||
35 | public uint OwnerMask = FULL_MASK_PERMISSIONS; | ||
36 | public uint NextOwnerMask = FULL_MASK_PERMISSIONS; | ||
37 | public uint GroupMask = FULL_MASK_PERMISSIONS; | ||
38 | public uint EveryoneMask = FULL_MASK_PERMISSIONS; | ||
39 | public uint BaseMask = FULL_MASK_PERMISSIONS; | ||
40 | |||
41 | protected PrimitiveBaseShape m_Shape; | ||
42 | |||
43 | protected AllNewSceneObjectGroup2 m_parentGroup; | ||
44 | |||
45 | |||
46 | #region Properties | ||
47 | protected string m_name; | ||
48 | /// <summary> | ||
49 | /// | ||
50 | /// </summary> | ||
51 | public virtual string Name | ||
52 | { | ||
53 | get { return m_name; } | ||
54 | set { m_name = value; } | ||
55 | } | ||
56 | |||
57 | protected LLVector3 m_offset; | ||
58 | public LLVector3 OffsetPosition | ||
59 | { | ||
60 | get | ||
61 | { | ||
62 | return m_offset; | ||
63 | } | ||
64 | set | ||
65 | { | ||
66 | m_offset = value; | ||
67 | } | ||
68 | } | ||
69 | |||
70 | protected LLQuaternion m_rotationOffset; | ||
71 | public LLQuaternion RotationOffset | ||
72 | { | ||
73 | get | ||
74 | { | ||
75 | return m_rotationOffset; | ||
76 | } | ||
77 | set | ||
78 | { | ||
79 | m_rotationOffset = value; | ||
80 | } | ||
81 | } | ||
82 | |||
83 | private string m_description = ""; | ||
84 | public string Description | ||
85 | { | ||
86 | get | ||
87 | { | ||
88 | return this.m_description; | ||
89 | } | ||
90 | set | ||
91 | { | ||
92 | this.m_description = value; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public PrimitiveBaseShape Shape | ||
97 | { | ||
98 | get | ||
99 | { | ||
100 | return this.m_Shape; | ||
101 | } | ||
102 | } | ||
103 | |||
104 | public LLVector3 Scale | ||
105 | { | ||
106 | set | ||
107 | { | ||
108 | this.m_Shape.Scale = value; | ||
109 | } | ||
110 | get | ||
111 | { | ||
112 | return this.m_Shape.Scale; | ||
113 | } | ||
114 | } | ||
115 | #endregion | ||
116 | |||
117 | #region Constructors | ||
118 | public AllNewSceneObjectPart2(ulong regionHandle, AllNewSceneObjectGroup2 parent, LLUUID ownerID, uint localID, PrimitiveBaseShape shape, LLVector3 position) | ||
119 | { | ||
120 | this.m_regionHandle = regionHandle; | ||
121 | this.m_parentGroup = parent; | ||
122 | |||
123 | this.CreationDate = (Int32)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
124 | this.OwnerID = ownerID; | ||
125 | this.CreatorID = this.OwnerID; | ||
126 | this.LastOwnerID = LLUUID.Zero; | ||
127 | this.uuid = LLUUID.Random(); | ||
128 | this.m_localID = (uint)(localID); | ||
129 | this.m_Shape = shape; | ||
130 | |||
131 | this.OffsetPosition = position; | ||
132 | } | ||
133 | #endregion | ||
134 | |||
135 | #region Shape | ||
136 | /// <summary> | ||
137 | /// | ||
138 | /// </summary> | ||
139 | /// <param name="shapeBlock"></param> | ||
140 | public void UpdateShape(ObjectShapePacket.ObjectDataBlock shapeBlock) | ||
141 | { | ||
142 | this.m_Shape.PathBegin = shapeBlock.PathBegin; | ||
143 | this.m_Shape.PathEnd = shapeBlock.PathEnd; | ||
144 | this.m_Shape.PathScaleX = shapeBlock.PathScaleX; | ||
145 | this.m_Shape.PathScaleY = shapeBlock.PathScaleY; | ||
146 | this.m_Shape.PathShearX = shapeBlock.PathShearX; | ||
147 | this.m_Shape.PathShearY = shapeBlock.PathShearY; | ||
148 | this.m_Shape.PathSkew = shapeBlock.PathSkew; | ||
149 | this.m_Shape.ProfileBegin = shapeBlock.ProfileBegin; | ||
150 | this.m_Shape.ProfileEnd = shapeBlock.ProfileEnd; | ||
151 | this.m_Shape.PathCurve = shapeBlock.PathCurve; | ||
152 | this.m_Shape.ProfileCurve = shapeBlock.ProfileCurve; | ||
153 | this.m_Shape.ProfileHollow = shapeBlock.ProfileHollow; | ||
154 | this.m_Shape.PathRadiusOffset = shapeBlock.PathRadiusOffset; | ||
155 | this.m_Shape.PathRevolutions = shapeBlock.PathRevolutions; | ||
156 | this.m_Shape.PathTaperX = shapeBlock.PathTaperX; | ||
157 | this.m_Shape.PathTaperY = shapeBlock.PathTaperY; | ||
158 | this.m_Shape.PathTwist = shapeBlock.PathTwist; | ||
159 | this.m_Shape.PathTwistBegin = shapeBlock.PathTwistBegin; | ||
160 | } | ||
161 | #endregion | ||
162 | |||
163 | #region Texture | ||
164 | /// <summary> | ||
165 | /// | ||
166 | /// </summary> | ||
167 | /// <param name="textureEntry"></param> | ||
168 | public void UpdateTextureEntry(byte[] textureEntry) | ||
169 | { | ||
170 | this.m_Shape.TextureEntry = textureEntry; | ||
171 | } | ||
172 | #endregion | ||
173 | |||
174 | #region Position | ||
175 | /// <summary> | ||
176 | /// | ||
177 | /// </summary> | ||
178 | /// <param name="pos"></param> | ||
179 | public void UpdateOffSet(LLVector3 pos) | ||
180 | { | ||
181 | LLVector3 newPos = new LLVector3(pos.X, pos.Y, pos.Z); | ||
182 | this.OffsetPosition = newPos; | ||
183 | } | ||
184 | #endregion | ||
185 | |||
186 | #region rotation | ||
187 | public void UpdateRotation(LLQuaternion rot) | ||
188 | { | ||
189 | this.RotationOffset = new LLQuaternion(rot.X, rot.Y, rot.Z, rot.W); | ||
190 | } | ||
191 | #endregion | ||
192 | |||
193 | #region Resizing/Scale | ||
194 | /// <summary> | ||
195 | /// | ||
196 | /// </summary> | ||
197 | /// <param name="scale"></param> | ||
198 | public void Resize(LLVector3 scale) | ||
199 | { | ||
200 | LLVector3 offset = (scale - this.m_Shape.Scale); | ||
201 | offset.X /= 2; | ||
202 | offset.Y /= 2; | ||
203 | offset.Z /= 2; | ||
204 | |||
205 | this.OffsetPosition += offset; | ||
206 | this.m_Shape.Scale = scale; | ||
207 | } | ||
208 | #endregion | ||
209 | } | ||
210 | } | ||
211 | |||