diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | 634 |
1 files changed, 317 insertions, 317 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index d939e85..e154b79 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | |||
@@ -1,317 +1,317 @@ | |||
1 | using System.Collections.Generic; | 1 | using System.Collections.Generic; |
2 | using OpenMetaverse; | 2 | using OpenMetaverse; |
3 | using OpenSim.Framework; | 3 | using OpenSim.Framework; |
4 | using OpenSim.Region.Framework.Scenes; | 4 | using OpenSim.Region.Framework.Scenes; |
5 | 5 | ||
6 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 6 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
7 | { | 7 | { |
8 | class SOPObject : IObject | 8 | class SOPObject : IObject |
9 | { | 9 | { |
10 | private readonly Scene m_rootScene; | 10 | private readonly Scene m_rootScene; |
11 | private readonly uint m_localID; | 11 | private readonly uint m_localID; |
12 | 12 | ||
13 | public SOPObject(Scene rootScene, uint localID) | 13 | public SOPObject(Scene rootScene, uint localID) |
14 | { | 14 | { |
15 | m_rootScene = rootScene; | 15 | m_rootScene = rootScene; |
16 | m_localID = localID; | 16 | m_localID = localID; |
17 | } | 17 | } |
18 | 18 | ||
19 | /// <summary> | 19 | /// <summary> |
20 | /// This needs to run very, very quickly. | 20 | /// This needs to run very, very quickly. |
21 | /// It is utilized in nearly every property and method. | 21 | /// It is utilized in nearly every property and method. |
22 | /// </summary> | 22 | /// </summary> |
23 | /// <returns></returns> | 23 | /// <returns></returns> |
24 | private SceneObjectPart GetSOP() | 24 | private SceneObjectPart GetSOP() |
25 | { | 25 | { |
26 | if (m_rootScene.Entities.ContainsKey(m_localID)) | 26 | if (m_rootScene.Entities.ContainsKey(m_localID)) |
27 | return ((SceneObjectGroup) m_rootScene.Entities[m_localID]).RootPart; | 27 | return ((SceneObjectGroup) m_rootScene.Entities[m_localID]).RootPart; |
28 | 28 | ||
29 | return null; | 29 | return null; |
30 | } | 30 | } |
31 | 31 | ||
32 | public bool Exists | 32 | public bool Exists |
33 | { | 33 | { |
34 | get { return GetSOP() != null; } | 34 | get { return GetSOP() != null; } |
35 | } | 35 | } |
36 | 36 | ||
37 | public uint LocalID | 37 | public uint LocalID |
38 | { | 38 | { |
39 | get { return m_localID; } | 39 | get { return m_localID; } |
40 | } | 40 | } |
41 | 41 | ||
42 | public UUID GlobalID | 42 | public UUID GlobalID |
43 | { | 43 | { |
44 | get { return GetSOP().UUID; } | 44 | get { return GetSOP().UUID; } |
45 | } | 45 | } |
46 | 46 | ||
47 | public IObject[] Children | 47 | public IObject[] Children |
48 | { | 48 | { |
49 | get | 49 | get |
50 | { | 50 | { |
51 | SceneObjectPart my = GetSOP(); | 51 | SceneObjectPart my = GetSOP(); |
52 | int total = my.ParentGroup.Children.Count; | 52 | int total = my.ParentGroup.Children.Count; |
53 | 53 | ||
54 | IObject[] rets = new IObject[total]; | 54 | IObject[] rets = new IObject[total]; |
55 | 55 | ||
56 | int i = 0; | 56 | int i = 0; |
57 | foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children) | 57 | foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children) |
58 | { | 58 | { |
59 | rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); | 59 | rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId); |
60 | } | 60 | } |
61 | 61 | ||
62 | return rets; | 62 | return rets; |
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | public IObject Root | 66 | public IObject Root |
67 | { | 67 | { |
68 | get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } | 68 | get { return new SOPObject(m_rootScene, GetSOP().ParentGroup.RootPart.LocalId); } |
69 | } | 69 | } |
70 | 70 | ||
71 | public IObjectFace[] Faces | 71 | public IObjectFace[] Faces |
72 | { | 72 | { |
73 | get | 73 | get |
74 | { | 74 | { |
75 | SceneObjectPart sop = GetSOP(); | 75 | SceneObjectPart sop = GetSOP(); |
76 | IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)]; | 76 | IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)]; |
77 | 77 | ||
78 | for (int i = 0; i < rets.Length;i++ ) | 78 | for (int i = 0; i < rets.Length;i++ ) |
79 | { | 79 | { |
80 | //rets[i] = new ObjectFace | 80 | //rets[i] = new ObjectFace |
81 | } | 81 | } |
82 | 82 | ||
83 | return rets; | 83 | return rets; |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | public Vector3 Scale | 87 | public Vector3 Scale |
88 | { | 88 | { |
89 | get { return GetSOP().Scale; } | 89 | get { return GetSOP().Scale; } |
90 | set { GetSOP().Scale = value; } | 90 | set { GetSOP().Scale = value; } |
91 | } | 91 | } |
92 | 92 | ||
93 | public Quaternion Rotation | 93 | public Quaternion Rotation |
94 | { | 94 | { |
95 | get { throw new System.NotImplementedException(); } | 95 | get { throw new System.NotImplementedException(); } |
96 | set { throw new System.NotImplementedException(); } | 96 | set { throw new System.NotImplementedException(); } |
97 | } | 97 | } |
98 | 98 | ||
99 | public Vector3 SitTarget | 99 | public Vector3 SitTarget |
100 | { | 100 | { |
101 | get { throw new System.NotImplementedException(); } | 101 | get { throw new System.NotImplementedException(); } |
102 | set { throw new System.NotImplementedException(); } | 102 | set { throw new System.NotImplementedException(); } |
103 | } | 103 | } |
104 | 104 | ||
105 | public string SitTargetText | 105 | public string SitTargetText |
106 | { | 106 | { |
107 | get { throw new System.NotImplementedException(); } | 107 | get { throw new System.NotImplementedException(); } |
108 | set { throw new System.NotImplementedException(); } | 108 | set { throw new System.NotImplementedException(); } |
109 | } | 109 | } |
110 | 110 | ||
111 | public string TouchText | 111 | public string TouchText |
112 | { | 112 | { |
113 | get { throw new System.NotImplementedException(); } | 113 | get { throw new System.NotImplementedException(); } |
114 | set { throw new System.NotImplementedException(); } | 114 | set { throw new System.NotImplementedException(); } |
115 | } | 115 | } |
116 | 116 | ||
117 | public string Text | 117 | public string Text |
118 | { | 118 | { |
119 | get { throw new System.NotImplementedException(); } | 119 | get { throw new System.NotImplementedException(); } |
120 | set { throw new System.NotImplementedException(); } | 120 | set { throw new System.NotImplementedException(); } |
121 | } | 121 | } |
122 | 122 | ||
123 | public bool IsPhysical | 123 | public bool IsPhysical |
124 | { | 124 | { |
125 | get { throw new System.NotImplementedException(); } | 125 | get { throw new System.NotImplementedException(); } |
126 | set { throw new System.NotImplementedException(); } | 126 | set { throw new System.NotImplementedException(); } |
127 | } | 127 | } |
128 | 128 | ||
129 | public bool IsPhantom | 129 | public bool IsPhantom |
130 | { | 130 | { |
131 | get { throw new System.NotImplementedException(); } | 131 | get { throw new System.NotImplementedException(); } |
132 | set { throw new System.NotImplementedException(); } | 132 | set { throw new System.NotImplementedException(); } |
133 | } | 133 | } |
134 | 134 | ||
135 | public bool IsRotationLockedX | 135 | public bool IsRotationLockedX |
136 | { | 136 | { |
137 | get { throw new System.NotImplementedException(); } | 137 | get { throw new System.NotImplementedException(); } |
138 | set { throw new System.NotImplementedException(); } | 138 | set { throw new System.NotImplementedException(); } |
139 | } | 139 | } |
140 | 140 | ||
141 | public bool IsRotationLockedY | 141 | public bool IsRotationLockedY |
142 | { | 142 | { |
143 | get { throw new System.NotImplementedException(); } | 143 | get { throw new System.NotImplementedException(); } |
144 | set { throw new System.NotImplementedException(); } | 144 | set { throw new System.NotImplementedException(); } |
145 | } | 145 | } |
146 | 146 | ||
147 | public bool IsRotationLockedZ | 147 | public bool IsRotationLockedZ |
148 | { | 148 | { |
149 | get { throw new System.NotImplementedException(); } | 149 | get { throw new System.NotImplementedException(); } |
150 | set { throw new System.NotImplementedException(); } | 150 | set { throw new System.NotImplementedException(); } |
151 | } | 151 | } |
152 | 152 | ||
153 | public bool IsSandboxed | 153 | public bool IsSandboxed |
154 | { | 154 | { |
155 | get { throw new System.NotImplementedException(); } | 155 | get { throw new System.NotImplementedException(); } |
156 | set { throw new System.NotImplementedException(); } | 156 | set { throw new System.NotImplementedException(); } |
157 | } | 157 | } |
158 | 158 | ||
159 | public bool IsImmotile | 159 | public bool IsImmotile |
160 | { | 160 | { |
161 | get { throw new System.NotImplementedException(); } | 161 | get { throw new System.NotImplementedException(); } |
162 | set { throw new System.NotImplementedException(); } | 162 | set { throw new System.NotImplementedException(); } |
163 | } | 163 | } |
164 | 164 | ||
165 | public bool IsAlwaysReturned | 165 | public bool IsAlwaysReturned |
166 | { | 166 | { |
167 | get { throw new System.NotImplementedException(); } | 167 | get { throw new System.NotImplementedException(); } |
168 | set { throw new System.NotImplementedException(); } | 168 | set { throw new System.NotImplementedException(); } |
169 | } | 169 | } |
170 | 170 | ||
171 | public bool IsTemporary | 171 | public bool IsTemporary |
172 | { | 172 | { |
173 | get { throw new System.NotImplementedException(); } | 173 | get { throw new System.NotImplementedException(); } |
174 | set { throw new System.NotImplementedException(); } | 174 | set { throw new System.NotImplementedException(); } |
175 | } | 175 | } |
176 | 176 | ||
177 | public bool IsFlexible | 177 | public bool IsFlexible |
178 | { | 178 | { |
179 | get { throw new System.NotImplementedException(); } | 179 | get { throw new System.NotImplementedException(); } |
180 | set { throw new System.NotImplementedException(); } | 180 | set { throw new System.NotImplementedException(); } |
181 | } | 181 | } |
182 | 182 | ||
183 | public PrimType PrimShape | 183 | public PrimType PrimShape |
184 | { | 184 | { |
185 | get { return (PrimType) getScriptPrimType(GetSOP().Shape); } | 185 | get { return (PrimType) getScriptPrimType(GetSOP().Shape); } |
186 | set { throw new System.NotImplementedException(); } | 186 | set { throw new System.NotImplementedException(); } |
187 | } | 187 | } |
188 | 188 | ||
189 | public Material Material | 189 | public Material Material |
190 | { | 190 | { |
191 | get { throw new System.NotImplementedException(); } | 191 | get { throw new System.NotImplementedException(); } |
192 | set { throw new System.NotImplementedException(); } | 192 | set { throw new System.NotImplementedException(); } |
193 | } | 193 | } |
194 | 194 | ||
195 | 195 | ||
196 | #region Supporting Functions | 196 | #region Supporting Functions |
197 | 197 | ||
198 | // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces | 198 | // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces |
199 | private static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, | 199 | private static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, |
200 | out bool hasDimple, out bool hasProfileCut) | 200 | out bool hasDimple, out bool hasProfileCut) |
201 | { | 201 | { |
202 | if (primType == (int)PrimType.Box | 202 | if (primType == (int)PrimType.Box |
203 | || | 203 | || |
204 | primType == (int)PrimType.Cylinder | 204 | primType == (int)PrimType.Cylinder |
205 | || | 205 | || |
206 | primType == (int)PrimType.Prism) | 206 | primType == (int)PrimType.Prism) |
207 | 207 | ||
208 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); | 208 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); |
209 | else | 209 | else |
210 | hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); | 210 | hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); |
211 | 211 | ||
212 | hasHollow = shape.ProfileHollow > 0; | 212 | hasHollow = shape.ProfileHollow > 0; |
213 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms | 213 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms |
214 | hasProfileCut = hasDimple; // is it the same thing? | 214 | hasProfileCut = hasDimple; // is it the same thing? |
215 | 215 | ||
216 | } | 216 | } |
217 | 217 | ||
218 | private static int getScriptPrimType(PrimitiveBaseShape primShape) | 218 | private static int getScriptPrimType(PrimitiveBaseShape primShape) |
219 | { | 219 | { |
220 | if (primShape.SculptEntry) | 220 | if (primShape.SculptEntry) |
221 | return (int) PrimType.Sculpt; | 221 | return (int) PrimType.Sculpt; |
222 | if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square) | 222 | if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square) |
223 | { | 223 | { |
224 | if (primShape.PathCurve == (byte) Extrusion.Straight) | 224 | if (primShape.PathCurve == (byte) Extrusion.Straight) |
225 | return (int) PrimType.Box; | 225 | return (int) PrimType.Box; |
226 | if (primShape.PathCurve == (byte) Extrusion.Curve1) | 226 | if (primShape.PathCurve == (byte) Extrusion.Curve1) |
227 | return (int) PrimType.Tube; | 227 | return (int) PrimType.Tube; |
228 | } | 228 | } |
229 | else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle) | 229 | else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle) |
230 | { | 230 | { |
231 | if (primShape.PathCurve == (byte) Extrusion.Straight) | 231 | if (primShape.PathCurve == (byte) Extrusion.Straight) |
232 | return (int) PrimType.Cylinder; | 232 | return (int) PrimType.Cylinder; |
233 | if (primShape.PathCurve == (byte) Extrusion.Curve1) | 233 | if (primShape.PathCurve == (byte) Extrusion.Curve1) |
234 | return (int) PrimType.Torus; | 234 | return (int) PrimType.Torus; |
235 | } | 235 | } |
236 | else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle) | 236 | else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle) |
237 | { | 237 | { |
238 | if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2) | 238 | if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2) |
239 | return (int) PrimType.Sphere; | 239 | return (int) PrimType.Sphere; |
240 | } | 240 | } |
241 | else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle) | 241 | else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle) |
242 | { | 242 | { |
243 | if (primShape.PathCurve == (byte) Extrusion.Straight) | 243 | if (primShape.PathCurve == (byte) Extrusion.Straight) |
244 | return (int) PrimType.Prism; | 244 | return (int) PrimType.Prism; |
245 | if (primShape.PathCurve == (byte) Extrusion.Curve1) | 245 | if (primShape.PathCurve == (byte) Extrusion.Curve1) |
246 | return (int) PrimType.Ring; | 246 | return (int) PrimType.Ring; |
247 | } | 247 | } |
248 | return (int) PrimType.NotPrimitive; | 248 | return (int) PrimType.NotPrimitive; |
249 | } | 249 | } |
250 | 250 | ||
251 | private static int getNumberOfSides(SceneObjectPart part) | 251 | private static int getNumberOfSides(SceneObjectPart part) |
252 | { | 252 | { |
253 | int ret; | 253 | int ret; |
254 | bool hasCut; | 254 | bool hasCut; |
255 | bool hasHollow; | 255 | bool hasHollow; |
256 | bool hasDimple; | 256 | bool hasDimple; |
257 | bool hasProfileCut; | 257 | bool hasProfileCut; |
258 | 258 | ||
259 | int primType = getScriptPrimType(part.Shape); | 259 | int primType = getScriptPrimType(part.Shape); |
260 | hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | 260 | hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); |
261 | 261 | ||
262 | switch (primType) | 262 | switch (primType) |
263 | { | 263 | { |
264 | default: | 264 | default: |
265 | case (int) PrimType.Box: | 265 | case (int) PrimType.Box: |
266 | ret = 6; | 266 | ret = 6; |
267 | if (hasCut) ret += 2; | 267 | if (hasCut) ret += 2; |
268 | if (hasHollow) ret += 1; | 268 | if (hasHollow) ret += 1; |
269 | break; | 269 | break; |
270 | case (int) PrimType.Cylinder: | 270 | case (int) PrimType.Cylinder: |
271 | ret = 3; | 271 | ret = 3; |
272 | if (hasCut) ret += 2; | 272 | if (hasCut) ret += 2; |
273 | if (hasHollow) ret += 1; | 273 | if (hasHollow) ret += 1; |
274 | break; | 274 | break; |
275 | case (int) PrimType.Prism: | 275 | case (int) PrimType.Prism: |
276 | ret = 5; | 276 | ret = 5; |
277 | if (hasCut) ret += 2; | 277 | if (hasCut) ret += 2; |
278 | if (hasHollow) ret += 1; | 278 | if (hasHollow) ret += 1; |
279 | break; | 279 | break; |
280 | case (int) PrimType.Sphere: | 280 | case (int) PrimType.Sphere: |
281 | ret = 1; | 281 | ret = 1; |
282 | if (hasCut) ret += 2; | 282 | if (hasCut) ret += 2; |
283 | if (hasDimple) ret += 2; | 283 | if (hasDimple) ret += 2; |
284 | if (hasHollow) | 284 | if (hasHollow) |
285 | ret += 1; // GOTCHA: LSL shows 2 additional sides here. | 285 | ret += 1; // GOTCHA: LSL shows 2 additional sides here. |
286 | // This has been fixed, but may cause porting issues. | 286 | // This has been fixed, but may cause porting issues. |
287 | break; | 287 | break; |
288 | case (int) PrimType.Torus: | 288 | case (int) PrimType.Torus: |
289 | ret = 1; | 289 | ret = 1; |
290 | if (hasCut) ret += 2; | 290 | if (hasCut) ret += 2; |
291 | if (hasProfileCut) ret += 2; | 291 | if (hasProfileCut) ret += 2; |
292 | if (hasHollow) ret += 1; | 292 | if (hasHollow) ret += 1; |
293 | break; | 293 | break; |
294 | case (int) PrimType.Tube: | 294 | case (int) PrimType.Tube: |
295 | ret = 4; | 295 | ret = 4; |
296 | if (hasCut) ret += 2; | 296 | if (hasCut) ret += 2; |
297 | if (hasProfileCut) ret += 2; | 297 | if (hasProfileCut) ret += 2; |
298 | if (hasHollow) ret += 1; | 298 | if (hasHollow) ret += 1; |
299 | break; | 299 | break; |
300 | case (int) PrimType.Ring: | 300 | case (int) PrimType.Ring: |
301 | ret = 3; | 301 | ret = 3; |
302 | if (hasCut) ret += 2; | 302 | if (hasCut) ret += 2; |
303 | if (hasProfileCut) ret += 2; | 303 | if (hasProfileCut) ret += 2; |
304 | if (hasHollow) ret += 1; | 304 | if (hasHollow) ret += 1; |
305 | break; | 305 | break; |
306 | case (int) PrimType.Sculpt: | 306 | case (int) PrimType.Sculpt: |
307 | ret = 1; | 307 | ret = 1; |
308 | break; | 308 | break; |
309 | } | 309 | } |
310 | return ret; | 310 | return ret; |
311 | } | 311 | } |
312 | 312 | ||
313 | 313 | ||
314 | #endregion | 314 | #endregion |
315 | 315 | ||
316 | } | 316 | } |
317 | } | 317 | } |