diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 150 |
1 files changed, 29 insertions, 121 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 33218aa..e4ccce8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -54,8 +54,8 @@ using OpenSim.Region.ScriptEngine.Interfaces; | |||
54 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; | 54 | using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces; |
55 | using OpenSim.Services.Interfaces; | 55 | using OpenSim.Services.Interfaces; |
56 | 56 | ||
57 | using PrimType = OpenSim.Region.Framework.Scenes.PrimType; | ||
57 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 58 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
58 | |||
59 | using AssetLandmark = OpenSim.Framework.AssetLandmark; | 59 | using AssetLandmark = OpenSim.Framework.AssetLandmark; |
60 | 60 | ||
61 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | 61 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; |
@@ -1442,6 +1442,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1442 | part.UpdateTexture(tex); | 1442 | part.UpdateTexture(tex); |
1443 | return; | 1443 | return; |
1444 | } | 1444 | } |
1445 | |||
1446 | if (face == ScriptBaseClass.ALL_SIDES) | ||
1447 | face = SceneObjectPart.ALL_SIDES; | ||
1448 | |||
1449 | m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | ||
1445 | } | 1450 | } |
1446 | 1451 | ||
1447 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1452 | public void SetTexGen(SceneObjectPart part, int face,int style) |
@@ -1599,7 +1604,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1599 | { | 1604 | { |
1600 | int i; | 1605 | int i; |
1601 | double sum = 0.0; | 1606 | double sum = 0.0; |
1602 | for (i = 0 ; i < GetNumberOfSides(part) ; i++) | 1607 | for (i = 0 ; i < GetNumberOfSides(part); i++) |
1603 | sum += (double)tex.GetFace((uint)i).RGBA.A; | 1608 | sum += (double)tex.GetFace((uint)i).RGBA.A; |
1604 | return sum; | 1609 | return sum; |
1605 | } | 1610 | } |
@@ -1749,7 +1754,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1749 | { | 1754 | { |
1750 | int i; | 1755 | int i; |
1751 | 1756 | ||
1752 | for (i = 0 ; i < GetNumberOfSides(part) ; i++) | 1757 | for (i = 0 ; i < GetNumberOfSides(part); i++) |
1753 | { | 1758 | { |
1754 | texcolor = tex.GetFace((uint)i).RGBA; | 1759 | texcolor = tex.GetFace((uint)i).RGBA; |
1755 | rgb.x += texcolor.R; | 1760 | rgb.x += texcolor.R; |
@@ -3568,7 +3573,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3568 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 3573 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
3569 | 3574 | ||
3570 | foreach (SceneObjectPart part in parts) | 3575 | foreach (SceneObjectPart part in parts) |
3571 | SetColor(part, color, face); | 3576 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); |
3572 | } | 3577 | } |
3573 | 3578 | ||
3574 | public void llCreateLink(string target, int parent) | 3579 | public void llCreateLink(string target, int parent) |
@@ -4423,63 +4428,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4423 | return result; | 4428 | return result; |
4424 | } | 4429 | } |
4425 | 4430 | ||
4426 | // this function to understand which shape it is (taken from meshmerizer) | ||
4427 | // quite useful can be used by meshmerizer to have a centralized point of understanding the shape | ||
4428 | // except that it refers to scripting constants | ||
4429 | public int getScriptPrimType(PrimitiveBaseShape primShape) | ||
4430 | { | ||
4431 | if (primShape.SculptEntry) | ||
4432 | return ScriptBaseClass.PRIM_TYPE_SCULPT; | ||
4433 | if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) | ||
4434 | { | ||
4435 | if (primShape.PathCurve == (byte)Extrusion.Straight) | ||
4436 | return ScriptBaseClass.PRIM_TYPE_BOX; | ||
4437 | else if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
4438 | return ScriptBaseClass.PRIM_TYPE_TUBE; | ||
4439 | } | ||
4440 | else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) | ||
4441 | { | ||
4442 | if (primShape.PathCurve == (byte)Extrusion.Straight) | ||
4443 | return ScriptBaseClass.PRIM_TYPE_CYLINDER; | ||
4444 | // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits | ||
4445 | else if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
4446 | return ScriptBaseClass.PRIM_TYPE_TORUS; | ||
4447 | } | ||
4448 | else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle) | ||
4449 | { | ||
4450 | if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte)Extrusion.Curve2) | ||
4451 | return ScriptBaseClass.PRIM_TYPE_SPHERE; | ||
4452 | } | ||
4453 | else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) | ||
4454 | { | ||
4455 | if (primShape.PathCurve == (byte)Extrusion.Straight) | ||
4456 | return ScriptBaseClass.PRIM_TYPE_PRISM; | ||
4457 | else if (primShape.PathCurve == (byte)Extrusion.Curve1) | ||
4458 | return ScriptBaseClass.PRIM_TYPE_RING; | ||
4459 | } | ||
4460 | return ScriptBaseClass.PRIM_TYPE_BOX; | ||
4461 | } | ||
4462 | |||
4463 | // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces | ||
4464 | protected void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, | ||
4465 | out bool hasDimple, out bool hasProfileCut) | ||
4466 | { | ||
4467 | if (primType == ScriptBaseClass.PRIM_TYPE_BOX | ||
4468 | || | ||
4469 | primType == ScriptBaseClass.PRIM_TYPE_CYLINDER | ||
4470 | || | ||
4471 | primType == ScriptBaseClass.PRIM_TYPE_PRISM) | ||
4472 | |||
4473 | hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); | ||
4474 | else | ||
4475 | hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0); | ||
4476 | |||
4477 | hasHollow = shape.ProfileHollow > 0; | ||
4478 | hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms | ||
4479 | hasProfileCut = hasDimple; // is it the same thing? | ||
4480 | |||
4481 | } | ||
4482 | |||
4483 | public LSL_Integer llGetNumberOfSides() | 4431 | public LSL_Integer llGetNumberOfSides() |
4484 | { | 4432 | { |
4485 | m_host.AddScriptLPS(1); | 4433 | m_host.AddScriptLPS(1); |
@@ -4489,63 +4437,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4489 | 4437 | ||
4490 | protected int GetNumberOfSides(SceneObjectPart part) | 4438 | protected int GetNumberOfSides(SceneObjectPart part) |
4491 | { | 4439 | { |
4492 | int ret = 0; | 4440 | int sides = part.GetNumberOfSides(); |
4493 | bool hasCut; | ||
4494 | bool hasHollow; | ||
4495 | bool hasDimple; | ||
4496 | bool hasProfileCut; | ||
4497 | |||
4498 | int primType = getScriptPrimType(part.Shape); | ||
4499 | hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); | ||
4500 | 4441 | ||
4501 | switch (primType) | 4442 | if (part.GetPrimType() == PrimType.SPHERE && part.Shape.ProfileHollow > 0) |
4502 | { | 4443 | { |
4503 | case ScriptBaseClass.PRIM_TYPE_BOX: | 4444 | // Make up for a bug where LSL shows 4 sides rather than 2 |
4504 | ret = 6; | 4445 | sides += 2; |
4505 | if (hasCut) ret += 2; | ||
4506 | if (hasHollow) ret += 1; | ||
4507 | break; | ||
4508 | case ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
4509 | ret = 3; | ||
4510 | if (hasCut) ret += 2; | ||
4511 | if (hasHollow) ret += 1; | ||
4512 | break; | ||
4513 | case ScriptBaseClass.PRIM_TYPE_PRISM: | ||
4514 | ret = 5; | ||
4515 | if (hasCut) ret += 2; | ||
4516 | if (hasHollow) ret += 1; | ||
4517 | break; | ||
4518 | case ScriptBaseClass.PRIM_TYPE_SPHERE: | ||
4519 | ret = 1; | ||
4520 | if (hasCut) ret += 2; | ||
4521 | if (hasDimple) ret += 2; | ||
4522 | if (hasHollow) ret += 3; // Emulate lsl on secondlife (according to documentation it should have added only +1) | ||
4523 | break; | ||
4524 | case ScriptBaseClass.PRIM_TYPE_TORUS: | ||
4525 | ret = 1; | ||
4526 | if (hasCut) ret += 2; | ||
4527 | if (hasProfileCut) ret += 2; | ||
4528 | if (hasHollow) ret += 1; | ||
4529 | break; | ||
4530 | case ScriptBaseClass.PRIM_TYPE_TUBE: | ||
4531 | ret = 4; | ||
4532 | if (hasCut) ret += 2; | ||
4533 | if (hasProfileCut) ret += 2; | ||
4534 | if (hasHollow) ret += 1; | ||
4535 | break; | ||
4536 | case ScriptBaseClass.PRIM_TYPE_RING: | ||
4537 | ret = 3; | ||
4538 | if (hasCut) ret += 2; | ||
4539 | if (hasProfileCut) ret += 2; | ||
4540 | if (hasHollow) ret += 1; | ||
4541 | break; | ||
4542 | case ScriptBaseClass.PRIM_TYPE_SCULPT: | ||
4543 | ret = 1; | ||
4544 | break; | ||
4545 | } | 4446 | } |
4546 | return ret; | ||
4547 | } | ||
4548 | 4447 | ||
4448 | return sides; | ||
4449 | } | ||
4450 | |||
4549 | 4451 | ||
4550 | /* The new / changed functions were tested with the following LSL script: | 4452 | /* The new / changed functions were tested with the following LSL script: |
4551 | 4453 | ||
@@ -4570,8 +4472,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4570 | } | 4472 | } |
4571 | */ | 4473 | */ |
4572 | 4474 | ||
4573 | |||
4574 | |||
4575 | // Xantor 29/apr/2008 | 4475 | // Xantor 29/apr/2008 |
4576 | // Returns rotation described by rotating angle radians about axis. | 4476 | // Returns rotation described by rotating angle radians about axis. |
4577 | // q = cos(a/2) + i (x * sin(a/2)) + j (y * sin(a/2)) + k (z * sin(a/2)) | 4477 | // q = cos(a/2) + i (x * sin(a/2)) + j (y * sin(a/2)) + k (z * sin(a/2)) |
@@ -7203,10 +7103,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7203 | LSL_Vector color=rules.GetVector3Item(idx++); | 7103 | LSL_Vector color=rules.GetVector3Item(idx++); |
7204 | double alpha=(double)rules.GetLSLFloatItem(idx++); | 7104 | double alpha=(double)rules.GetLSLFloatItem(idx++); |
7205 | 7105 | ||
7206 | SetColor(part, color, face); | 7106 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); |
7207 | SetAlpha(part, alpha, face); | 7107 | SetAlpha(part, alpha, face); |
7208 | 7108 | ||
7209 | break; | 7109 | break; |
7110 | |||
7210 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | 7111 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: |
7211 | if (remain < 7) | 7112 | if (remain < 7) |
7212 | return; | 7113 | return; |
@@ -7222,6 +7123,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7222 | SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); | 7123 | SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); |
7223 | 7124 | ||
7224 | break; | 7125 | break; |
7126 | |||
7225 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | 7127 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: |
7226 | if (remain < 5) | 7128 | if (remain < 5) |
7227 | return; | 7129 | return; |
@@ -7234,6 +7136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7234 | SetPointLight(part, light, lightcolor, intensity, radius, falloff); | 7136 | SetPointLight(part, light, lightcolor, intensity, radius, falloff); |
7235 | 7137 | ||
7236 | break; | 7138 | break; |
7139 | |||
7237 | case (int)ScriptBaseClass.PRIM_GLOW: | 7140 | case (int)ScriptBaseClass.PRIM_GLOW: |
7238 | if (remain < 2) | 7141 | if (remain < 2) |
7239 | return; | 7142 | return; |
@@ -7243,6 +7146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7243 | SetGlow(part, face, glow); | 7146 | SetGlow(part, face, glow); |
7244 | 7147 | ||
7245 | break; | 7148 | break; |
7149 | |||
7246 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 7150 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
7247 | if (remain < 3) | 7151 | if (remain < 3) |
7248 | return; | 7152 | return; |
@@ -7253,6 +7157,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7253 | SetShiny(part, face, shiny, bump); | 7157 | SetShiny(part, face, shiny, bump); |
7254 | 7158 | ||
7255 | break; | 7159 | break; |
7160 | |||
7256 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 7161 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
7257 | if (remain < 2) | 7162 | if (remain < 2) |
7258 | return; | 7163 | return; |
@@ -7260,6 +7165,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7260 | bool st = rules.GetLSLIntegerItem(idx++); | 7165 | bool st = rules.GetLSLIntegerItem(idx++); |
7261 | SetFullBright(part, face , st); | 7166 | SetFullBright(part, face , st); |
7262 | break; | 7167 | break; |
7168 | |||
7263 | case (int)ScriptBaseClass.PRIM_MATERIAL: | 7169 | case (int)ScriptBaseClass.PRIM_MATERIAL: |
7264 | if (remain < 1) | 7170 | if (remain < 1) |
7265 | return; | 7171 | return; |
@@ -7269,6 +7175,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7269 | 7175 | ||
7270 | part.Material = Convert.ToByte(mat); | 7176 | part.Material = Convert.ToByte(mat); |
7271 | break; | 7177 | break; |
7178 | |||
7272 | case (int)ScriptBaseClass.PRIM_PHANTOM: | 7179 | case (int)ScriptBaseClass.PRIM_PHANTOM: |
7273 | if (remain < 1) | 7180 | if (remain < 1) |
7274 | return; | 7181 | return; |
@@ -7283,6 +7190,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7283 | 7190 | ||
7284 | part.ScriptSetPhantomStatus(phantom); | 7191 | part.ScriptSetPhantomStatus(phantom); |
7285 | break; | 7192 | break; |
7193 | |||
7286 | case (int)ScriptBaseClass.PRIM_PHYSICS: | 7194 | case (int)ScriptBaseClass.PRIM_PHYSICS: |
7287 | if (remain < 1) | 7195 | if (remain < 1) |
7288 | return; | 7196 | return; |
@@ -7296,6 +7204,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7296 | 7204 | ||
7297 | part.ScriptSetPhysicsStatus(physics); | 7205 | part.ScriptSetPhysicsStatus(physics); |
7298 | break; | 7206 | break; |
7207 | |||
7299 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | 7208 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: |
7300 | if (remain < 1) | 7209 | if (remain < 1) |
7301 | return; | 7210 | return; |
@@ -7563,7 +7472,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7563 | 7472 | ||
7564 | public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules) | 7473 | public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules) |
7565 | { | 7474 | { |
7566 | |||
7567 | LSL_List res = new LSL_List(); | 7475 | LSL_List res = new LSL_List(); |
7568 | int idx=0; | 7476 | int idx=0; |
7569 | while (idx < rules.Length) | 7477 | while (idx < rules.Length) |
@@ -7625,7 +7533,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7625 | case (int)ScriptBaseClass.PRIM_TYPE: | 7533 | case (int)ScriptBaseClass.PRIM_TYPE: |
7626 | // implementing box | 7534 | // implementing box |
7627 | PrimitiveBaseShape Shape = part.Shape; | 7535 | PrimitiveBaseShape Shape = part.Shape; |
7628 | int primType = getScriptPrimType(part.Shape); | 7536 | int primType = (int)part.GetPrimType(); |
7629 | res.Add(new LSL_Integer(primType)); | 7537 | res.Add(new LSL_Integer(primType)); |
7630 | double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX | 7538 | double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX |
7631 | double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY. | 7539 | double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY. |
@@ -7705,7 +7613,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7705 | Primitive.TextureEntry tex = part.Shape.Textures; | 7613 | Primitive.TextureEntry tex = part.Shape.Textures; |
7706 | if (face == ScriptBaseClass.ALL_SIDES) | 7614 | if (face == ScriptBaseClass.ALL_SIDES) |
7707 | { | 7615 | { |
7708 | for (face = 0 ; face < GetNumberOfSides(part) ; face++) | 7616 | for (face = 0 ; face < GetNumberOfSides(part); face++) |
7709 | { | 7617 | { |
7710 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 7618 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); |
7711 | 7619 | ||
@@ -7747,7 +7655,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7747 | Color4 texcolor; | 7655 | Color4 texcolor; |
7748 | if (face == ScriptBaseClass.ALL_SIDES) | 7656 | if (face == ScriptBaseClass.ALL_SIDES) |
7749 | { | 7657 | { |
7750 | for (face = 0 ; face < GetNumberOfSides(part) ; face++) | 7658 | for (face = 0 ; face < GetNumberOfSides(part); face++) |
7751 | { | 7659 | { |
7752 | texcolor = tex.GetFace((uint)face).RGBA; | 7660 | texcolor = tex.GetFace((uint)face).RGBA; |
7753 | res.Add(new LSL_Vector(texcolor.R, | 7661 | res.Add(new LSL_Vector(texcolor.R, |