aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-02-01 22:08:00 +0000
committerJustin Clark-Casey (justincc)2010-02-01 22:08:00 +0000
commitecc068fbe0b8a95563281c3aaf8e7392e5ef49e9 (patch)
tree2d8158799882ed27120187f9d45798ec0177fcd7 /OpenSim
parentCopy prim face color setting code from LSL_Api down into SOP so that non-LSL ... (diff)
downloadopensim-SC_OLD-ecc068fbe0b8a95563281c3aaf8e7392e5ef49e9.zip
opensim-SC_OLD-ecc068fbe0b8a95563281c3aaf8e7392e5ef49e9.tar.gz
opensim-SC_OLD-ecc068fbe0b8a95563281c3aaf8e7392e5ef49e9.tar.bz2
opensim-SC_OLD-ecc068fbe0b8a95563281c3aaf8e7392e5ef49e9.tar.xz
remove now duplicated shape code from LSL_Api.cs
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs235
2 files changed, 49 insertions, 194 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 8b5c348..33c3fcf 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3029,8 +3029,8 @@ namespace OpenSim.Region.Framework.Scenes
3029 bool hasDimple; 3029 bool hasDimple;
3030 bool hasProfileCut; 3030 bool hasProfileCut;
3031 3031
3032 PrimType primType = getScriptPrimType(); 3032 PrimType primType = GetScriptPrimType();
3033 hasCutHollowDimpleProfileCut(primType, Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut); 3033 HasCutHollowDimpleProfileCut(primType, Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
3034 3034
3035 switch (primType) 3035 switch (primType)
3036 { 3036 {
@@ -3085,7 +3085,7 @@ namespace OpenSim.Region.Framework.Scenes
3085 /// </summary> 3085 /// </summary>
3086 /// <param name="primShape"></param> 3086 /// <param name="primShape"></param>
3087 /// <returns></returns> 3087 /// <returns></returns>
3088 public PrimType getScriptPrimType() 3088 public PrimType GetScriptPrimType()
3089 { 3089 {
3090 if (Shape.SculptEntry) 3090 if (Shape.SculptEntry)
3091 return PrimType.SCULPT; 3091 return PrimType.SCULPT;
@@ -3129,7 +3129,7 @@ namespace OpenSim.Region.Framework.Scenes
3129 /// <param name="hasHollow"></param> 3129 /// <param name="hasHollow"></param>
3130 /// <param name="hasDimple"></param> 3130 /// <param name="hasDimple"></param>
3131 /// <param name="hasProfileCut"></param> 3131 /// <param name="hasProfileCut"></param>
3132 protected static void hasCutHollowDimpleProfileCut(PrimType primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow, 3132 protected static void HasCutHollowDimpleProfileCut(PrimType primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
3133 out bool hasDimple, out bool hasProfileCut) 3133 out bool hasDimple, out bool hasProfileCut)
3134 { 3134 {
3135 if (primType == PrimType.BOX 3135 if (primType == PrimType.BOX
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 2f00a1a..1437bb7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1330,44 +1330,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1330 { 1330 {
1331 m_host.AddScriptLPS(1); 1331 m_host.AddScriptLPS(1);
1332 1332
1333 SetColor(m_host, color, face); 1333 m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
1334 }
1335
1336 protected void SetColor(SceneObjectPart part, LSL_Vector color, int face)
1337 {
1338 Primitive.TextureEntry tex = part.Shape.Textures;
1339 Color4 texcolor;
1340 if (face >= 0 && face < GetNumberOfSides(part))
1341 {
1342 texcolor = tex.CreateFace((uint)face).RGBA;
1343 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1344 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1345 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1346 tex.FaceTextures[face].RGBA = texcolor;
1347 part.UpdateTexture(tex);
1348 return;
1349 }
1350 else if (face == ScriptBaseClass.ALL_SIDES)
1351 {
1352 for (uint i = 0; i < GetNumberOfSides(part); i++)
1353 {
1354 if (tex.FaceTextures[i] != null)
1355 {
1356 texcolor = tex.FaceTextures[i].RGBA;
1357 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1358 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1359 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1360 tex.FaceTextures[i].RGBA = texcolor;
1361 }
1362 texcolor = tex.DefaultTexture.RGBA;
1363 texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
1364 texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
1365 texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
1366 tex.DefaultTexture.RGBA = texcolor;
1367 }
1368 part.UpdateTexture(tex);
1369 return;
1370 }
1371 } 1334 }
1372 1335
1373 public void SetTexGen(SceneObjectPart part, int face,int style) 1336 public void SetTexGen(SceneObjectPart part, int face,int style)
@@ -1378,7 +1341,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1378 if (style == (int)ScriptBaseClass.PRIM_TEXGEN_PLANAR) 1341 if (style == (int)ScriptBaseClass.PRIM_TEXGEN_PLANAR)
1379 textype = MappingType.Planar; 1342 textype = MappingType.Planar;
1380 1343
1381 if (face >= 0 && face < GetNumberOfSides(part)) 1344 if (face >= 0 && face < part.GetNumberOfSides())
1382 { 1345 {
1383 tex.CreateFace((uint) face); 1346 tex.CreateFace((uint) face);
1384 tex.FaceTextures[face].TexMapType = textype; 1347 tex.FaceTextures[face].TexMapType = textype;
@@ -1387,7 +1350,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1387 } 1350 }
1388 else if (face == ScriptBaseClass.ALL_SIDES) 1351 else if (face == ScriptBaseClass.ALL_SIDES)
1389 { 1352 {
1390 for (uint i = 0; i < GetNumberOfSides(part); i++) 1353 for (uint i = 0; i < part.GetNumberOfSides(); i++)
1391 { 1354 {
1392 if (tex.FaceTextures[i] != null) 1355 if (tex.FaceTextures[i] != null)
1393 { 1356 {
@@ -1403,7 +1366,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1403 public void SetGlow(SceneObjectPart part, int face, float glow) 1366 public void SetGlow(SceneObjectPart part, int face, float glow)
1404 { 1367 {
1405 Primitive.TextureEntry tex = part.Shape.Textures; 1368 Primitive.TextureEntry tex = part.Shape.Textures;
1406 if (face >= 0 && face < GetNumberOfSides(part)) 1369 if (face >= 0 && face < part.GetNumberOfSides())
1407 { 1370 {
1408 tex.CreateFace((uint) face); 1371 tex.CreateFace((uint) face);
1409 tex.FaceTextures[face].Glow = glow; 1372 tex.FaceTextures[face].Glow = glow;
@@ -1412,7 +1375,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1412 } 1375 }
1413 else if (face == ScriptBaseClass.ALL_SIDES) 1376 else if (face == ScriptBaseClass.ALL_SIDES)
1414 { 1377 {
1415 for (uint i = 0; i < GetNumberOfSides(part); i++) 1378 for (uint i = 0; i < part.GetNumberOfSides(); i++)
1416 { 1379 {
1417 if (tex.FaceTextures[i] != null) 1380 if (tex.FaceTextures[i] != null)
1418 { 1381 {
@@ -1450,7 +1413,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1450 } 1413 }
1451 1414
1452 Primitive.TextureEntry tex = part.Shape.Textures; 1415 Primitive.TextureEntry tex = part.Shape.Textures;
1453 if (face >= 0 && face < GetNumberOfSides(part)) 1416 if (face >= 0 && face < part.GetNumberOfSides())
1454 { 1417 {
1455 tex.CreateFace((uint) face); 1418 tex.CreateFace((uint) face);
1456 tex.FaceTextures[face].Shiny = sval; 1419 tex.FaceTextures[face].Shiny = sval;
@@ -1460,7 +1423,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1460 } 1423 }
1461 else if (face == ScriptBaseClass.ALL_SIDES) 1424 else if (face == ScriptBaseClass.ALL_SIDES)
1462 { 1425 {
1463 for (uint i = 0; i < GetNumberOfSides(part); i++) 1426 for (uint i = 0; i < part.GetNumberOfSides(); i++)
1464 { 1427 {
1465 if (tex.FaceTextures[i] != null) 1428 if (tex.FaceTextures[i] != null)
1466 { 1429 {
@@ -1478,7 +1441,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1478 public void SetFullBright(SceneObjectPart part, int face, bool bright) 1441 public void SetFullBright(SceneObjectPart part, int face, bool bright)
1479 { 1442 {
1480 Primitive.TextureEntry tex = part.Shape.Textures; 1443 Primitive.TextureEntry tex = part.Shape.Textures;
1481 if (face >= 0 && face < GetNumberOfSides(part)) 1444 if (face >= 0 && face < part.GetNumberOfSides())
1482 { 1445 {
1483 tex.CreateFace((uint) face); 1446 tex.CreateFace((uint) face);
1484 tex.FaceTextures[face].Fullbright = bright; 1447 tex.FaceTextures[face].Fullbright = bright;
@@ -1487,7 +1450,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1487 } 1450 }
1488 else if (face == ScriptBaseClass.ALL_SIDES) 1451 else if (face == ScriptBaseClass.ALL_SIDES)
1489 { 1452 {
1490 for (uint i = 0; i < GetNumberOfSides(part); i++) 1453 for (uint i = 0; i < part.GetNumberOfSides(); i++)
1491 { 1454 {
1492 if (tex.FaceTextures[i] != null) 1455 if (tex.FaceTextures[i] != null)
1493 { 1456 {
@@ -1514,11 +1477,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1514 { 1477 {
1515 int i; 1478 int i;
1516 double sum = 0.0; 1479 double sum = 0.0;
1517 for (i = 0 ; i < GetNumberOfSides(part) ; i++) 1480 for (i = 0 ; i < part.GetNumberOfSides(); i++)
1518 sum += (double)tex.GetFace((uint)i).RGBA.A; 1481 sum += (double)tex.GetFace((uint)i).RGBA.A;
1519 return sum; 1482 return sum;
1520 } 1483 }
1521 if (face >= 0 && face < GetNumberOfSides(part)) 1484 if (face >= 0 && face < part.GetNumberOfSides())
1522 { 1485 {
1523 return (double)tex.GetFace((uint)face).RGBA.A; 1486 return (double)tex.GetFace((uint)face).RGBA.A;
1524 } 1487 }
@@ -1546,7 +1509,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1546 { 1509 {
1547 Primitive.TextureEntry tex = part.Shape.Textures; 1510 Primitive.TextureEntry tex = part.Shape.Textures;
1548 Color4 texcolor; 1511 Color4 texcolor;
1549 if (face >= 0 && face < GetNumberOfSides(part)) 1512 if (face >= 0 && face < part.GetNumberOfSides())
1550 { 1513 {
1551 texcolor = tex.CreateFace((uint)face).RGBA; 1514 texcolor = tex.CreateFace((uint)face).RGBA;
1552 texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); 1515 texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
@@ -1556,7 +1519,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1556 } 1519 }
1557 else if (face == ScriptBaseClass.ALL_SIDES) 1520 else if (face == ScriptBaseClass.ALL_SIDES)
1558 { 1521 {
1559 for (int i = 0; i < GetNumberOfSides(part); i++) 1522 for (int i = 0; i < part.GetNumberOfSides(); i++)
1560 { 1523 {
1561 if (tex.FaceTextures[i] != null) 1524 if (tex.FaceTextures[i] != null)
1562 { 1525 {
@@ -1661,7 +1624,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1661 { 1624 {
1662 int i; 1625 int i;
1663 1626
1664 for (i = 0 ; i < GetNumberOfSides(part) ; i++) 1627 for (i = 0 ; i < part.GetNumberOfSides(); i++)
1665 { 1628 {
1666 texcolor = tex.GetFace((uint)i).RGBA; 1629 texcolor = tex.GetFace((uint)i).RGBA;
1667 rgb.x += texcolor.R; 1630 rgb.x += texcolor.R;
@@ -1669,13 +1632,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1669 rgb.z += texcolor.B; 1632 rgb.z += texcolor.B;
1670 } 1633 }
1671 1634
1672 rgb.x /= (float)GetNumberOfSides(part); 1635 rgb.x /= (float)part.GetNumberOfSides();
1673 rgb.y /= (float)GetNumberOfSides(part); 1636 rgb.y /= (float)part.GetNumberOfSides();
1674 rgb.z /= (float)GetNumberOfSides(part); 1637 rgb.z /= (float)part.GetNumberOfSides();
1675 1638
1676 return rgb; 1639 return rgb;
1677 } 1640 }
1678 if (face >= 0 && face < GetNumberOfSides(part)) 1641 if (face >= 0 && face < part.GetNumberOfSides())
1679 { 1642 {
1680 texcolor = tex.GetFace((uint)face).RGBA; 1643 texcolor = tex.GetFace((uint)face).RGBA;
1681 rgb.x = texcolor.R; 1644 rgb.x = texcolor.R;
@@ -1722,7 +1685,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1722 1685
1723 Primitive.TextureEntry tex = part.Shape.Textures; 1686 Primitive.TextureEntry tex = part.Shape.Textures;
1724 1687
1725 if (face >= 0 && face < GetNumberOfSides(part)) 1688 if (face >= 0 && face < part.GetNumberOfSides())
1726 { 1689 {
1727 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); 1690 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
1728 texface.TextureID = textureID; 1691 texface.TextureID = textureID;
@@ -1732,7 +1695,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1732 } 1695 }
1733 else if (face == ScriptBaseClass.ALL_SIDES) 1696 else if (face == ScriptBaseClass.ALL_SIDES)
1734 { 1697 {
1735 for (uint i = 0; i < GetNumberOfSides(part); i++) 1698 for (uint i = 0; i < part.GetNumberOfSides(); i++)
1736 { 1699 {
1737 if (tex.FaceTextures[i] != null) 1700 if (tex.FaceTextures[i] != null)
1738 { 1701 {
@@ -1756,7 +1719,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1756 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face) 1719 protected void ScaleTexture(SceneObjectPart part, double u, double v, int face)
1757 { 1720 {
1758 Primitive.TextureEntry tex = part.Shape.Textures; 1721 Primitive.TextureEntry tex = part.Shape.Textures;
1759 if (face >= 0 && face < GetNumberOfSides(part)) 1722 if (face >= 0 && face < part.GetNumberOfSides())
1760 { 1723 {
1761 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); 1724 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
1762 texface.RepeatU = (float)u; 1725 texface.RepeatU = (float)u;
@@ -1767,7 +1730,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1767 } 1730 }
1768 if (face == ScriptBaseClass.ALL_SIDES) 1731 if (face == ScriptBaseClass.ALL_SIDES)
1769 { 1732 {
1770 for (int i = 0; i < GetNumberOfSides(part); i++) 1733 for (int i = 0; i < part.GetNumberOfSides(); i++)
1771 { 1734 {
1772 if (tex.FaceTextures[i] != null) 1735 if (tex.FaceTextures[i] != null)
1773 { 1736 {
@@ -1792,7 +1755,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1792 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face) 1755 protected void OffsetTexture(SceneObjectPart part, double u, double v, int face)
1793 { 1756 {
1794 Primitive.TextureEntry tex = part.Shape.Textures; 1757 Primitive.TextureEntry tex = part.Shape.Textures;
1795 if (face >= 0 && face < GetNumberOfSides(part)) 1758 if (face >= 0 && face < part.GetNumberOfSides())
1796 { 1759 {
1797 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); 1760 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
1798 texface.OffsetU = (float)u; 1761 texface.OffsetU = (float)u;
@@ -1803,7 +1766,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1803 } 1766 }
1804 if (face == ScriptBaseClass.ALL_SIDES) 1767 if (face == ScriptBaseClass.ALL_SIDES)
1805 { 1768 {
1806 for (int i = 0; i < GetNumberOfSides(part); i++) 1769 for (int i = 0; i < part.GetNumberOfSides(); i++)
1807 { 1770 {
1808 if (tex.FaceTextures[i] != null) 1771 if (tex.FaceTextures[i] != null)
1809 { 1772 {
@@ -1828,7 +1791,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1828 protected void RotateTexture(SceneObjectPart part, double rotation, int face) 1791 protected void RotateTexture(SceneObjectPart part, double rotation, int face)
1829 { 1792 {
1830 Primitive.TextureEntry tex = part.Shape.Textures; 1793 Primitive.TextureEntry tex = part.Shape.Textures;
1831 if (face >= 0 && face < GetNumberOfSides(part)) 1794 if (face >= 0 && face < part.GetNumberOfSides())
1832 { 1795 {
1833 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); 1796 Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
1834 texface.Rotation = (float)rotation; 1797 texface.Rotation = (float)rotation;
@@ -1838,7 +1801,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1838 } 1801 }
1839 if (face == ScriptBaseClass.ALL_SIDES) 1802 if (face == ScriptBaseClass.ALL_SIDES)
1840 { 1803 {
1841 for (int i = 0; i < GetNumberOfSides(part); i++) 1804 for (int i = 0; i < part.GetNumberOfSides(); i++)
1842 { 1805 {
1843 if (tex.FaceTextures[i] != null) 1806 if (tex.FaceTextures[i] != null)
1844 { 1807 {
@@ -1864,7 +1827,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1864 { 1827 {
1865 face = 0; 1828 face = 0;
1866 } 1829 }
1867 if (face >= 0 && face < GetNumberOfSides(part)) 1830 if (face >= 0 && face < part.GetNumberOfSides())
1868 { 1831 {
1869 Primitive.TextureEntryFace texface; 1832 Primitive.TextureEntryFace texface;
1870 texface = tex.GetFace((uint)face); 1833 texface = tex.GetFace((uint)face);
@@ -3414,7 +3377,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3414 List<SceneObjectPart> parts = GetLinkParts(linknumber); 3377 List<SceneObjectPart> parts = GetLinkParts(linknumber);
3415 3378
3416 foreach (SceneObjectPart part in parts) 3379 foreach (SceneObjectPart part in parts)
3417 SetColor(part, color, face); 3380 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
3418 } 3381 }
3419 3382
3420 public void llCreateLink(string target, int parent) 3383 public void llCreateLink(string target, int parent)
@@ -4271,127 +4234,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4271 return result; 4234 return result;
4272 } 4235 }
4273 4236
4274 // this function to understand which shape it is (taken from meshmerizer)
4275 // quite useful can be used by meshmerizer to have a centralized point of understanding the shape
4276 // except that it refers to scripting constants
4277 public int getScriptPrimType(PrimitiveBaseShape primShape)
4278 {
4279 if (primShape.SculptEntry)
4280 return ScriptBaseClass.PRIM_TYPE_SCULPT;
4281 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square)
4282 {
4283 if (primShape.PathCurve == (byte)Extrusion.Straight)
4284 return ScriptBaseClass.PRIM_TYPE_BOX;
4285 else if (primShape.PathCurve == (byte)Extrusion.Curve1)
4286 return ScriptBaseClass.PRIM_TYPE_TUBE;
4287 }
4288 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
4289 {
4290 if (primShape.PathCurve == (byte)Extrusion.Straight)
4291 return ScriptBaseClass.PRIM_TYPE_CYLINDER;
4292 // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
4293 else if (primShape.PathCurve == (byte)Extrusion.Curve1)
4294 return ScriptBaseClass.PRIM_TYPE_TORUS;
4295 }
4296 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
4297 {
4298 if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte)Extrusion.Curve2)
4299 return ScriptBaseClass.PRIM_TYPE_SPHERE;
4300 }
4301 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
4302 {
4303 if (primShape.PathCurve == (byte)Extrusion.Straight)
4304 return ScriptBaseClass.PRIM_TYPE_PRISM;
4305 else if (primShape.PathCurve == (byte)Extrusion.Curve1)
4306 return ScriptBaseClass.PRIM_TYPE_RING;
4307 }
4308 return ScriptBaseClass.PRIM_TYPE_BOX;
4309 }
4310
4311 // Helper functions to understand if object has cut, hollow, dimple, and other affecting number of faces
4312 protected void hasCutHollowDimpleProfileCut(int primType, PrimitiveBaseShape shape, out bool hasCut, out bool hasHollow,
4313 out bool hasDimple, out bool hasProfileCut)
4314 {
4315 if (primType == ScriptBaseClass.PRIM_TYPE_BOX
4316 ||
4317 primType == ScriptBaseClass.PRIM_TYPE_CYLINDER
4318 ||
4319 primType == ScriptBaseClass.PRIM_TYPE_PRISM)
4320
4321 hasCut = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0);
4322 else
4323 hasCut = (shape.PathBegin > 0) || (shape.PathEnd > 0);
4324
4325 hasHollow = shape.ProfileHollow > 0;
4326 hasDimple = (shape.ProfileBegin > 0) || (shape.ProfileEnd > 0); // taken from llSetPrimitiveParms
4327 hasProfileCut = hasDimple; // is it the same thing?
4328
4329 }
4330
4331 public LSL_Integer llGetNumberOfSides() 4237 public LSL_Integer llGetNumberOfSides()
4332 { 4238 {
4333 m_host.AddScriptLPS(1); 4239 m_host.AddScriptLPS(1);
4334 4240
4335 return GetNumberOfSides(m_host); 4241 return m_host.GetNumberOfSides();
4336 }
4337
4338 protected int GetNumberOfSides(SceneObjectPart part)
4339 {
4340 int ret = 0;
4341 bool hasCut;
4342 bool hasHollow;
4343 bool hasDimple;
4344 bool hasProfileCut;
4345
4346 int primType = getScriptPrimType(part.Shape);
4347 hasCutHollowDimpleProfileCut(primType, part.Shape, out hasCut, out hasHollow, out hasDimple, out hasProfileCut);
4348
4349 switch (primType)
4350 {
4351 case ScriptBaseClass.PRIM_TYPE_BOX:
4352 ret = 6;
4353 if (hasCut) ret += 2;
4354 if (hasHollow) ret += 1;
4355 break;
4356 case ScriptBaseClass.PRIM_TYPE_CYLINDER:
4357 ret = 3;
4358 if (hasCut) ret += 2;
4359 if (hasHollow) ret += 1;
4360 break;
4361 case ScriptBaseClass.PRIM_TYPE_PRISM:
4362 ret = 5;
4363 if (hasCut) ret += 2;
4364 if (hasHollow) ret += 1;
4365 break;
4366 case ScriptBaseClass.PRIM_TYPE_SPHERE:
4367 ret = 1;
4368 if (hasCut) ret += 2;
4369 if (hasDimple) ret += 2;
4370 if (hasHollow) ret += 3; // Emulate lsl on secondlife (according to documentation it should have added only +1)
4371 break;
4372 case ScriptBaseClass.PRIM_TYPE_TORUS:
4373 ret = 1;
4374 if (hasCut) ret += 2;
4375 if (hasProfileCut) ret += 2;
4376 if (hasHollow) ret += 1;
4377 break;
4378 case ScriptBaseClass.PRIM_TYPE_TUBE:
4379 ret = 4;
4380 if (hasCut) ret += 2;
4381 if (hasProfileCut) ret += 2;
4382 if (hasHollow) ret += 1;
4383 break;
4384 case ScriptBaseClass.PRIM_TYPE_RING:
4385 ret = 3;
4386 if (hasCut) ret += 2;
4387 if (hasProfileCut) ret += 2;
4388 if (hasHollow) ret += 1;
4389 break;
4390 case ScriptBaseClass.PRIM_TYPE_SCULPT:
4391 ret = 1;
4392 break;
4393 }
4394 return ret;
4395 } 4242 }
4396 4243
4397 /* The new / changed functions were tested with the following LSL script: 4244 /* The new / changed functions were tested with the following LSL script:
@@ -4588,7 +4435,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4588 { 4435 {
4589 face = 0; 4436 face = 0;
4590 } 4437 }
4591 if (face >= 0 && face < GetNumberOfSides(part)) 4438 if (face >= 0 && face < part.GetNumberOfSides())
4592 { 4439 {
4593 offset.x = tex.GetFace((uint)face).OffsetU; 4440 offset.x = tex.GetFace((uint)face).OffsetU;
4594 offset.y = tex.GetFace((uint)face).OffsetV; 4441 offset.y = tex.GetFace((uint)face).OffsetV;
@@ -4629,7 +4476,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4629 { 4476 {
4630 face = 0; 4477 face = 0;
4631 } 4478 }
4632 if (face >= 0 && face < GetNumberOfSides(part)) 4479 if (face >= 0 && face < part.GetNumberOfSides())
4633 { 4480 {
4634 return tex.GetFace((uint)face).Rotation; 4481 return tex.GetFace((uint)face).Rotation;
4635 } 4482 }
@@ -7019,10 +6866,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7019 LSL_Vector color=rules.GetVector3Item(idx++); 6866 LSL_Vector color=rules.GetVector3Item(idx++);
7020 double alpha=(double)rules.GetLSLFloatItem(idx++); 6867 double alpha=(double)rules.GetLSLFloatItem(idx++);
7021 6868
7022 SetColor(part, color, face); 6869 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face);
7023 SetAlpha(part, alpha, face); 6870 SetAlpha(part, alpha, face);
7024 6871
7025 break; 6872 break;
6873
7026 case (int)ScriptBaseClass.PRIM_FLEXIBLE: 6874 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
7027 if (remain < 7) 6875 if (remain < 7)
7028 return; 6876 return;
@@ -7038,6 +6886,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7038 SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force); 6886 SetFlexi(part, flexi, softness, gravity, friction, wind, tension, force);
7039 6887
7040 break; 6888 break;
6889
7041 case (int)ScriptBaseClass.PRIM_POINT_LIGHT: 6890 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
7042 if (remain < 5) 6891 if (remain < 5)
7043 return; 6892 return;
@@ -7050,6 +6899,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7050 SetPointLight(part, light, lightcolor, intensity, radius, falloff); 6899 SetPointLight(part, light, lightcolor, intensity, radius, falloff);
7051 6900
7052 break; 6901 break;
6902
7053 case (int)ScriptBaseClass.PRIM_GLOW: 6903 case (int)ScriptBaseClass.PRIM_GLOW:
7054 if (remain < 2) 6904 if (remain < 2)
7055 return; 6905 return;
@@ -7059,6 +6909,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7059 SetGlow(part, face, glow); 6909 SetGlow(part, face, glow);
7060 6910
7061 break; 6911 break;
6912
7062 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 6913 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7063 if (remain < 3) 6914 if (remain < 3)
7064 return; 6915 return;
@@ -7069,6 +6920,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7069 SetShiny(part, face, shiny, bump); 6920 SetShiny(part, face, shiny, bump);
7070 6921
7071 break; 6922 break;
6923
7072 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 6924 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7073 if (remain < 2) 6925 if (remain < 2)
7074 return; 6926 return;
@@ -7076,6 +6928,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7076 bool st = rules.GetLSLIntegerItem(idx++); 6928 bool st = rules.GetLSLIntegerItem(idx++);
7077 SetFullBright(part, face , st); 6929 SetFullBright(part, face , st);
7078 break; 6930 break;
6931
7079 case (int)ScriptBaseClass.PRIM_MATERIAL: 6932 case (int)ScriptBaseClass.PRIM_MATERIAL:
7080 if (remain < 1) 6933 if (remain < 1)
7081 return; 6934 return;
@@ -7085,6 +6938,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7085 6938
7086 part.Material = Convert.ToByte(mat); 6939 part.Material = Convert.ToByte(mat);
7087 break; 6940 break;
6941
7088 case (int)ScriptBaseClass.PRIM_PHANTOM: 6942 case (int)ScriptBaseClass.PRIM_PHANTOM:
7089 if (remain < 1) 6943 if (remain < 1)
7090 return; 6944 return;
@@ -7099,6 +6953,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7099 6953
7100 part.ScriptSetPhantomStatus(phantom); 6954 part.ScriptSetPhantomStatus(phantom);
7101 break; 6955 break;
6956
7102 case (int)ScriptBaseClass.PRIM_PHYSICS: 6957 case (int)ScriptBaseClass.PRIM_PHYSICS:
7103 if (remain < 1) 6958 if (remain < 1)
7104 return; 6959 return;
@@ -7112,6 +6967,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7112 6967
7113 part.ScriptSetPhysicsStatus(physics); 6968 part.ScriptSetPhysicsStatus(physics);
7114 break; 6969 break;
6970
7115 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: 6971 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
7116 if (remain < 1) 6972 if (remain < 1)
7117 return; 6973 return;
@@ -7379,7 +7235,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7379 7235
7380 public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules) 7236 public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules)
7381 { 7237 {
7382
7383 LSL_List res = new LSL_List(); 7238 LSL_List res = new LSL_List();
7384 int idx=0; 7239 int idx=0;
7385 while (idx < rules.Length) 7240 while (idx < rules.Length)
@@ -7441,7 +7296,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7441 case (int)ScriptBaseClass.PRIM_TYPE: 7296 case (int)ScriptBaseClass.PRIM_TYPE:
7442 // implementing box 7297 // implementing box
7443 PrimitiveBaseShape Shape = part.Shape; 7298 PrimitiveBaseShape Shape = part.Shape;
7444 int primType = getScriptPrimType(part.Shape); 7299 int primType = (int)part.GetScriptPrimType();
7445 res.Add(new LSL_Integer(primType)); 7300 res.Add(new LSL_Integer(primType));
7446 double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX 7301 double topshearx = (double)(sbyte)Shape.PathShearX / 100.0; // Fix negative values for PathShearX
7447 double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY. 7302 double topsheary = (double)(sbyte)Shape.PathShearY / 100.0; // and PathShearY.
@@ -7521,7 +7376,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7521 Primitive.TextureEntry tex = part.Shape.Textures; 7376 Primitive.TextureEntry tex = part.Shape.Textures;
7522 if (face == ScriptBaseClass.ALL_SIDES) 7377 if (face == ScriptBaseClass.ALL_SIDES)
7523 { 7378 {
7524 for (face = 0 ; face < GetNumberOfSides(part) ; face++) 7379 for (face = 0 ; face < part.GetNumberOfSides() ; face++)
7525 { 7380 {
7526 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 7381 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7527 7382
@@ -7537,7 +7392,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7537 } 7392 }
7538 else 7393 else
7539 { 7394 {
7540 if (face >= 0 && face < GetNumberOfSides(part)) 7395 if (face >= 0 && face < part.GetNumberOfSides())
7541 { 7396 {
7542 Primitive.TextureEntryFace texface = tex.GetFace((uint)face); 7397 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7543 7398
@@ -7563,7 +7418,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7563 Color4 texcolor; 7418 Color4 texcolor;
7564 if (face == ScriptBaseClass.ALL_SIDES) 7419 if (face == ScriptBaseClass.ALL_SIDES)
7565 { 7420 {
7566 for (face = 0 ; face < GetNumberOfSides(part) ; face++) 7421 for (face = 0 ; face < part.GetNumberOfSides() ; face++)
7567 { 7422 {
7568 texcolor = tex.GetFace((uint)face).RGBA; 7423 texcolor = tex.GetFace((uint)face).RGBA;
7569 res.Add(new LSL_Vector(texcolor.R, 7424 res.Add(new LSL_Vector(texcolor.R,