aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2009-03-05 00:16:06 +0000
committerAdam Frisby2009-03-05 00:16:06 +0000
commit0e7e2eba14cd9a5302f6f14e57b7247a5199a65e (patch)
treea0bc034d4481bf4dde52367a1acaff8ff91141b4 /OpenSim
parent* Fleshed out the MRM Module a little. (diff)
downloadopensim-SC_OLD-0e7e2eba14cd9a5302f6f14e57b7247a5199a65e.zip
opensim-SC_OLD-0e7e2eba14cd9a5302f6f14e57b7247a5199a65e.tar.gz
opensim-SC_OLD-0e7e2eba14cd9a5302f6f14e57b7247a5199a65e.tar.bz2
opensim-SC_OLD-0e7e2eba14cd9a5302f6f14e57b7247a5199a65e.tar.xz
* Implements a number of members on SOGObject for use with the MRM Script Engine API.
* It's lag-tacular! :D
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs18
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs163
2 files changed, 166 insertions, 15 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs
index 3456258..ef442d4 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IObject.cs
@@ -66,15 +66,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
66 66
67 public enum PrimType 67 public enum PrimType
68 { 68 {
69 NotPrimitive, 69 NotPrimitive = 255,
70 Box, 70 Box = 0,
71 Cylinder, 71 Cylinder = 1,
72 Prism, 72 Prism = 2,
73 Sphere, 73 Sphere = 3,
74 Torus, 74 Torus = 4,
75 Tube, 75 Tube = 5,
76 Ring, 76 Ring = 6,
77 Sculpt 77 Sculpt = 7
78 } 78 }
79 79
80 public enum TextureMapping 80 public enum TextureMapping
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index 55b9767..cf59cba 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -1,7 +1,6 @@
1using System; 1using System.Collections.Generic;
2using System.Collections.Generic;
3using System.Text;
4using OpenMetaverse; 2using OpenMetaverse;
3using OpenSim.Framework;
5using OpenSim.Region.Framework.Scenes; 4using OpenSim.Region.Framework.Scenes;
6 5
7namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 6namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
@@ -17,6 +16,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
17 m_localID = localID; 16 m_localID = localID;
18 } 17 }
19 18
19 /// <summary>
20 /// This needs to run very, very quickly.
21 /// It is utilized in nearly every property and method.
22 /// </summary>
23 /// <returns></returns>
20 private SceneObjectPart GetSOP() 24 private SceneObjectPart GetSOP()
21 { 25 {
22 if (m_rootScene.Entities.ContainsKey(m_localID)) 26 if (m_rootScene.Entities.ContainsKey(m_localID))
@@ -42,7 +46,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
42 46
43 public IObject[] Children 47 public IObject[] Children
44 { 48 {
45 get { throw new System.NotImplementedException(); } 49 get
50 {
51 SceneObjectPart my = GetSOP();
52 int total = my.ParentGroup.Children.Count;
53
54 IObject[] rets = new IObject[total];
55
56 int i = 0;
57 foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children)
58 {
59 rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId);
60 }
61
62 return rets;
63 }
46 } 64 }
47 65
48 public IObject Root 66 public IObject Root
@@ -52,7 +70,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
52 70
53 public IObjectFace[] Faces 71 public IObjectFace[] Faces
54 { 72 {
55 get { throw new System.NotImplementedException(); } 73 get
74 {
75 SceneObjectPart sop = GetSOP();
76 IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)];
77
78 for (int i = 0; i < rets.Length;i++ )
79 {
80 //rets[i] = new ObjectFace
81 }
82
83 return rets;
84 }
56 } 85 }
57 86
58 public Vector3 Scale 87 public Vector3 Scale
@@ -153,7 +182,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
153 182
154 public PrimType PrimShape 183 public PrimType PrimShape
155 { 184 {
156 get { throw new System.NotImplementedException(); } 185 get { return (PrimType) getScriptPrimType(GetSOP().Shape); }
157 set { throw new System.NotImplementedException(); } 186 set { throw new System.NotImplementedException(); }
158 } 187 }
159 188
@@ -162,5 +191,127 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
162 get { throw new System.NotImplementedException(); } 191 get { throw new System.NotImplementedException(); }
163 set { throw new System.NotImplementedException(); } 192 set { throw new System.NotImplementedException(); }
164 } 193 }
194
195
196 #region Supporting Functions
197
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,
200 out bool hasDimple, out bool hasProfileCut)
201 {
202 if (primType == (int)PrimType.Box
203 ||
204 primType == (int)PrimType.Cylinder
205 ||
206 primType == (int)PrimType.Prism)
207
208 hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
209 else
210 hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);
211
212 hasHollow = shape.ProfileHollow > 0;
213 hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
214 hasProfileCut = hasDimple; // is it the same thing?
215
216 }
217
218 private static int getScriptPrimType(PrimitiveBaseShape primShape)
219 {
220 if (primShape.SculptEntry)
221 return (int) PrimType.Sculpt;
222 if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square)
223 {
224 if (primShape.PathCurve == (byte) Extrusion.Straight)
225 return (int) PrimType.Box;
226 if (primShape.PathCurve == (byte) Extrusion.Curve1)
227 return (int) PrimType.Tube;
228 }
229 else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle)
230 {
231 if (primShape.PathCurve == (byte) Extrusion.Straight)
232 return (int) PrimType.Cylinder;
233 if (primShape.PathCurve == (byte) Extrusion.Curve1)
234 return (int) PrimType.Torus;
235 }
236 else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle)
237 {
238 if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2)
239 return (int) PrimType.Sphere;
240 }
241 else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle)
242 {
243 if (primShape.PathCurve == (byte) Extrusion.Straight)
244 return (int) PrimType.Prism;
245 if (primShape.PathCurve == (byte) Extrusion.Curve1)
246 return (int) PrimType.Ring;
247 }
248 return (int) PrimType.NotPrimitive;
249 }
250
251 private static int getNumberOfSides(SceneObjectPart part)
252 {
253 int ret;
254 bool hasCut;
255 bool hasHollow;
256 bool hasDimple;
257 bool hasProfileCut;
258
259 int primType = getScriptPrimType(part.Shape);
260 hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
261
262 switch (primType)
263 {
264 default:
265 case (int) PrimType.Box:
266 ret = 6;
267 if (hasCut) ret += 2;
268 if (hasHollow) ret += 1;
269 break;
270 case (int) PrimType.Cylinder:
271 ret = 3;
272 if (hasCut) ret += 2;
273 if (hasHollow) ret += 1;
274 break;
275 case (int) PrimType.Prism:
276 ret = 5;
277 if (hasCut) ret += 2;
278 if (hasHollow) ret += 1;
279 break;
280 case (int) PrimType.Sphere:
281 ret = 1;
282 if (hasCut) ret += 2;
283 if (hasDimple) ret += 2;
284 if (hasHollow)
285 ret += 1; // GOTCHA: LSL shows 2 additional sides here.
286 // This has been fixed, but may cause porting issues.
287 break;
288 case (int) PrimType.Torus:
289 ret = 1;
290 if (hasCut) ret += 2;
291 if (hasProfileCut) ret += 2;
292 if (hasHollow) ret += 1;
293 break;
294 case (int) PrimType.Tube:
295 ret = 4;
296 if (hasCut) ret += 2;
297 if (hasProfileCut) ret += 2;
298 if (hasHollow) ret += 1;
299 break;
300 case (int) PrimType.Ring:
301 ret = 3;
302 if (hasCut) ret += 2;
303 if (hasProfileCut) ret += 2;
304 if (hasHollow) ret += 1;
305 break;
306 case (int) PrimType.Sculpt:
307 ret = 1;
308 break;
309 }
310 return ret;
311 }
312
313
314 #endregion
315
165 } 316 }
166} 317}