* Implements a number of members on SOGObject for use with the MRM Script Engine API.

* It's lag-tacular! :D
0.6.4-rc1
Adam Frisby 2009-03-05 00:16:06 +00:00
parent f3aac0fa4a
commit 0e7e2eba14
2 changed files with 166 additions and 15 deletions

View File

@ -66,15 +66,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public enum PrimType public enum PrimType
{ {
NotPrimitive, NotPrimitive = 255,
Box, Box = 0,
Cylinder, Cylinder = 1,
Prism, Prism = 2,
Sphere, Sphere = 3,
Torus, Torus = 4,
Tube, Tube = 5,
Ring, Ring = 6,
Sculpt Sculpt = 7
} }
public enum TextureMapping public enum TextureMapping

View File

@ -1,7 +1,6 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
@ -17,6 +16,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
m_localID = localID; m_localID = localID;
} }
/// <summary>
/// This needs to run very, very quickly.
/// It is utilized in nearly every property and method.
/// </summary>
/// <returns></returns>
private SceneObjectPart GetSOP() private SceneObjectPart GetSOP()
{ {
if (m_rootScene.Entities.ContainsKey(m_localID)) if (m_rootScene.Entities.ContainsKey(m_localID))
@ -42,7 +46,21 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public IObject[] Children public IObject[] Children
{ {
get { throw new System.NotImplementedException(); } get
{
SceneObjectPart my = GetSOP();
int total = my.ParentGroup.Children.Count;
IObject[] rets = new IObject[total];
int i = 0;
foreach (KeyValuePair<UUID, SceneObjectPart> pair in my.ParentGroup.Children)
{
rets[i++] = new SOPObject(m_rootScene, pair.Value.LocalId);
}
return rets;
}
} }
public IObject Root public IObject Root
@ -52,7 +70,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public IObjectFace[] Faces public IObjectFace[] Faces
{ {
get { throw new System.NotImplementedException(); } get
{
SceneObjectPart sop = GetSOP();
IObjectFace[] rets = new IObjectFace[getNumberOfSides(sop)];
for (int i = 0; i < rets.Length;i++ )
{
//rets[i] = new ObjectFace
}
return rets;
}
} }
public Vector3 Scale public Vector3 Scale
@ -153,7 +182,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
public PrimType PrimShape public PrimType PrimShape
{ {
get { throw new System.NotImplementedException(); } get { return (PrimType) getScriptPrimType(GetSOP().Shape); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
@ -162,5 +191,127 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
get { throw new System.NotImplementedException(); } get { throw new System.NotImplementedException(); }
set { throw new System.NotImplementedException(); } set { throw new System.NotImplementedException(); }
} }
#region Supporting Functions
// Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces
private static void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
out bool hasDimple, out bool hasProfileCut)
{
if (primType == (int)PrimType.Box
||
primType == (int)PrimType.Cylinder
||
primType == (int)PrimType.Prism)
hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
else
hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);
hasHollow = shape.ProfileHollow > 0;
hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
hasProfileCut = hasDimple; // is it the same thing?
}
private static int getScriptPrimType(PrimitiveBaseShape primShape)
{
if (primShape.SculptEntry)
return (int) PrimType.Sculpt;
if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square)
{
if (primShape.PathCurve == (byte) Extrusion.Straight)
return (int) PrimType.Box;
if (primShape.PathCurve == (byte) Extrusion.Curve1)
return (int) PrimType.Tube;
}
else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Circle)
{
if (primShape.PathCurve == (byte) Extrusion.Straight)
return (int) PrimType.Cylinder;
if (primShape.PathCurve == (byte) Extrusion.Curve1)
return (int) PrimType.Torus;
}
else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.HalfCircle)
{
if (primShape.PathCurve == (byte) Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2)
return (int) PrimType.Sphere;
}
else if ((primShape.ProfileCurve & 0x07) == (byte) ProfileShape.EquilateralTriangle)
{
if (primShape.PathCurve == (byte) Extrusion.Straight)
return (int) PrimType.Prism;
if (primShape.PathCurve == (byte) Extrusion.Curve1)
return (int) PrimType.Ring;
}
return (int) PrimType.NotPrimitive;
}
private static int getNumberOfSides(SceneObjectPart part)
{
int ret;
bool hasCut;
bool hasHollow;
bool hasDimple;
bool hasProfileCut;
int primType = getScriptPrimType(part.Shape);
hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
switch (primType)
{
default:
case (int) PrimType.Box:
ret = 6;
if (hasCut) ret += 2;
if (hasHollow) ret += 1;
break;
case (int) PrimType.Cylinder:
ret = 3;
if (hasCut) ret += 2;
if (hasHollow) ret += 1;
break;
case (int) PrimType.Prism:
ret = 5;
if (hasCut) ret += 2;
if (hasHollow) ret += 1;
break;
case (int) PrimType.Sphere:
ret = 1;
if (hasCut) ret += 2;
if (hasDimple) ret += 2;
if (hasHollow)
ret += 1; // GOTCHA: LSL shows 2 additional sides here.
// This has been fixed, but may cause porting issues.
break;
case (int) PrimType.Torus:
ret = 1;
if (hasCut) ret += 2;
if (hasProfileCut) ret += 2;
if (hasHollow) ret += 1;
break;
case (int) PrimType.Tube:
ret = 4;
if (hasCut) ret += 2;
if (hasProfileCut) ret += 2;
if (hasHollow) ret += 1;
break;
case (int) PrimType.Ring:
ret = 3;
if (hasCut) ret += 2;
if (hasProfileCut) ret += 2;
if (hasHollow) ret += 1;
break;
case (int) PrimType.Sculpt:
ret = 1;
break;
}
return ret;
}
#endregion
} }
} }