diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 224 |
1 files changed, 136 insertions, 88 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 054c326..c7de12f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -252,7 +252,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
252 | } | 252 | } |
253 | 253 | ||
254 | //These are the implementations of the various ll-functions used by the LSL scripts. | 254 | //These are the implementations of the various ll-functions used by the LSL scripts. |
255 | //starting out, we use the System.Math library for trig functions. - ckrinke 8-14-07 | ||
256 | public LSL_Types.LSLFloat llSin(double f) | 255 | public LSL_Types.LSLFloat llSin(double f) |
257 | { | 256 | { |
258 | m_host.AddScriptLPS(1); | 257 | m_host.AddScriptLPS(1); |
@@ -1040,7 +1039,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1040 | { | 1039 | { |
1041 | Primitive.TextureEntry tex = part.Shape.Textures; | 1040 | Primitive.TextureEntry tex = part.Shape.Textures; |
1042 | Color4 texcolor; | 1041 | Color4 texcolor; |
1043 | if (face > -1) | 1042 | if (face >= 0 && face < GetNumberOfSides(part)) |
1044 | { | 1043 | { |
1045 | texcolor = tex.CreateFace((uint)face).RGBA; | 1044 | texcolor = tex.CreateFace((uint)face).RGBA; |
1046 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); | 1045 | texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f); |
@@ -1050,7 +1049,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1050 | part.UpdateTexture(tex); | 1049 | part.UpdateTexture(tex); |
1051 | return; | 1050 | return; |
1052 | } | 1051 | } |
1053 | else if (face == -1) | 1052 | else if (face == ScriptBaseClass.ALL_SIDES) |
1054 | { | 1053 | { |
1055 | for (uint i = 0; i < GetNumberOfSides(part); i++) | 1054 | for (uint i = 0; i < GetNumberOfSides(part); i++) |
1056 | { | 1055 | { |
@@ -1076,14 +1075,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1076 | public void SetGlow(SceneObjectPart part, int face, float glow) | 1075 | public void SetGlow(SceneObjectPart part, int face, float glow) |
1077 | { | 1076 | { |
1078 | Primitive.TextureEntry tex = part.Shape.Textures; | 1077 | Primitive.TextureEntry tex = part.Shape.Textures; |
1079 | if (face > -1) | 1078 | if (face >= 0 && face < GetNumberOfSides(part)) |
1080 | { | 1079 | { |
1081 | tex.CreateFace((uint) face); | 1080 | tex.CreateFace((uint) face); |
1082 | tex.FaceTextures[face].Glow = glow; | 1081 | tex.FaceTextures[face].Glow = glow; |
1083 | part.UpdateTexture(tex); | 1082 | part.UpdateTexture(tex); |
1084 | return; | 1083 | return; |
1085 | } | 1084 | } |
1086 | else if (face == -1) | 1085 | else if (face == ScriptBaseClass.ALL_SIDES) |
1087 | { | 1086 | { |
1088 | for (uint i = 0; i < GetNumberOfSides(part); i++) | 1087 | for (uint i = 0; i < GetNumberOfSides(part); i++) |
1089 | { | 1088 | { |
@@ -1123,7 +1122,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1123 | } | 1122 | } |
1124 | 1123 | ||
1125 | Primitive.TextureEntry tex = part.Shape.Textures; | 1124 | Primitive.TextureEntry tex = part.Shape.Textures; |
1126 | if (face > -1) | 1125 | if (face >= 0 && face < GetNumberOfSides(part)) |
1127 | { | 1126 | { |
1128 | tex.CreateFace((uint) face); | 1127 | tex.CreateFace((uint) face); |
1129 | tex.FaceTextures[face].Shiny = sval; | 1128 | tex.FaceTextures[face].Shiny = sval; |
@@ -1131,9 +1130,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1131 | part.UpdateTexture(tex); | 1130 | part.UpdateTexture(tex); |
1132 | return; | 1131 | return; |
1133 | } | 1132 | } |
1134 | else if (face == -1) | 1133 | else if (face == ScriptBaseClass.ALL_SIDES) |
1135 | { | 1134 | { |
1136 | for (uint i = 0; i < 32; i++) | 1135 | for (uint i = 0; i < GetNumberOfSides(part); i++) |
1137 | { | 1136 | { |
1138 | if (tex.FaceTextures[i] != null) | 1137 | if (tex.FaceTextures[i] != null) |
1139 | { | 1138 | { |
@@ -1151,16 +1150,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1151 | public void SetFullBright(SceneObjectPart part, int face, bool bright) | 1150 | public void SetFullBright(SceneObjectPart part, int face, bool bright) |
1152 | { | 1151 | { |
1153 | Primitive.TextureEntry tex = part.Shape.Textures; | 1152 | Primitive.TextureEntry tex = part.Shape.Textures; |
1154 | if (face > -1) | 1153 | if (face >= 0 && face < GetNumberOfSides(part)) |
1155 | { | 1154 | { |
1156 | tex.CreateFace((uint) face); | 1155 | tex.CreateFace((uint) face); |
1157 | tex.FaceTextures[face].Fullbright = bright; | 1156 | tex.FaceTextures[face].Fullbright = bright; |
1158 | part.UpdateTexture(tex); | 1157 | part.UpdateTexture(tex); |
1159 | return; | 1158 | return; |
1160 | } | 1159 | } |
1161 | else if (face == -1) | 1160 | else if (face == ScriptBaseClass.ALL_SIDES) |
1162 | { | 1161 | { |
1163 | for (uint i = 0; i < 32; i++) | 1162 | for (uint i = 0; i < GetNumberOfSides(part); i++) |
1164 | { | 1163 | { |
1165 | if (tex.FaceTextures[i] != null) | 1164 | if (tex.FaceTextures[i] != null) |
1166 | { | 1165 | { |
@@ -1176,16 +1175,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1176 | public LSL_Types.LSLFloat llGetAlpha(int face) | 1175 | public LSL_Types.LSLFloat llGetAlpha(int face) |
1177 | { | 1176 | { |
1178 | m_host.AddScriptLPS(1); | 1177 | m_host.AddScriptLPS(1); |
1179 | Primitive.TextureEntry tex = m_host.Shape.Textures; | 1178 | |
1180 | if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color | 1179 | return GetAlpha(m_host, face); |
1180 | } | ||
1181 | |||
1182 | private LSL_Types.LSLFloat GetAlpha(SceneObjectPart part, int face) | ||
1183 | { | ||
1184 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1185 | if (face == ScriptBaseClass.ALL_SIDES) | ||
1181 | { | 1186 | { |
1182 | return (double)((tex.DefaultTexture.RGBA.A * 255) / 255); | 1187 | int i; |
1188 | double sum = 0.0; | ||
1189 | for (i = 0 ; i < GetNumberOfSides(part) ; i++) | ||
1190 | sum += (double)((tex.GetFace((uint)i).RGBA.A * 255) / 255); | ||
1191 | return sum; | ||
1183 | } | 1192 | } |
1184 | if (face > -1) | 1193 | if (face >= 0 && face < GetNumberOfSides(part)) |
1185 | { | 1194 | { |
1186 | return (double)((tex.GetFace((uint)face).RGBA.A * 255) / 255); | 1195 | return (double)((tex.GetFace((uint)face).RGBA.A * 255) / 255); |
1187 | } | 1196 | } |
1188 | return 0; | 1197 | return 0.0; |
1189 | } | 1198 | } |
1190 | 1199 | ||
1191 | public void llSetAlpha(double alpha, int face) | 1200 | public void llSetAlpha(double alpha, int face) |
@@ -1199,7 +1208,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1199 | { | 1208 | { |
1200 | Primitive.TextureEntry tex = part.Shape.Textures; | 1209 | Primitive.TextureEntry tex = part.Shape.Textures; |
1201 | Color4 texcolor; | 1210 | Color4 texcolor; |
1202 | if (face > -1) | 1211 | if (face >= 0 && face < GetNumberOfSides(part)) |
1203 | { | 1212 | { |
1204 | texcolor = tex.CreateFace((uint)face).RGBA; | 1213 | texcolor = tex.CreateFace((uint)face).RGBA; |
1205 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); | 1214 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); |
@@ -1207,7 +1216,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1207 | part.UpdateTexture(tex); | 1216 | part.UpdateTexture(tex); |
1208 | return; | 1217 | return; |
1209 | } | 1218 | } |
1210 | else if (face == -1) | 1219 | else if (face == ScriptBaseClass.ALL_SIDES) |
1211 | { | 1220 | { |
1212 | for (int i = 0; i < GetNumberOfSides(part); i++) | 1221 | for (int i = 0; i < GetNumberOfSides(part); i++) |
1213 | { | 1222 | { |
@@ -1325,23 +1334,38 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1325 | public LSL_Types.Vector3 llGetColor(int face) | 1334 | public LSL_Types.Vector3 llGetColor(int face) |
1326 | { | 1335 | { |
1327 | m_host.AddScriptLPS(1); | 1336 | m_host.AddScriptLPS(1); |
1328 | Primitive.TextureEntry tex = m_host.Shape.Textures; | 1337 | return GetColor(m_host, face); |
1338 | } | ||
1339 | |||
1340 | private LSL_Types.Vector3 GetColor(SceneObjectPart part, int face) | ||
1341 | { | ||
1342 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1329 | Color4 texcolor; | 1343 | Color4 texcolor; |
1330 | LSL_Types.Vector3 rgb; | 1344 | LSL_Types.Vector3 rgb = new LSL_Types.Vector3(); |
1331 | if (face == -1) // TMP: Until we can determine number of sides, ALL_SIDES (-1) will return default color | 1345 | if (face == ScriptBaseClass.ALL_SIDES) |
1332 | { | 1346 | { |
1333 | texcolor = tex.DefaultTexture.RGBA; | 1347 | int i; |
1334 | rgb.x = (255 - (texcolor.R * 255)) / 255; | 1348 | |
1335 | rgb.y = (255 - (texcolor.G * 255)) / 255; | 1349 | for (i = 0 ; i < GetNumberOfSides(part) ; i++) |
1336 | rgb.z = (255 - (texcolor.B * 255)) / 255; | 1350 | { |
1351 | texcolor = tex.GetFace((uint)i).RGBA; | ||
1352 | rgb.x += texcolor.R; | ||
1353 | rgb.y += texcolor.G; | ||
1354 | rgb.z += texcolor.B; | ||
1355 | } | ||
1356 | |||
1357 | rgb.x /= (float)GetNumberOfSides(part); | ||
1358 | rgb.y /= (float)GetNumberOfSides(part); | ||
1359 | rgb.z /= (float)GetNumberOfSides(part); | ||
1360 | |||
1337 | return rgb; | 1361 | return rgb; |
1338 | } | 1362 | } |
1339 | if (face > -1) | 1363 | if (face >= 0 && face < GetNumberOfSides(part)) |
1340 | { | 1364 | { |
1341 | texcolor = tex.GetFace((uint)face).RGBA; | 1365 | texcolor = tex.GetFace((uint)face).RGBA; |
1342 | rgb.x = (255 - (texcolor.R * 255)) / 255; | 1366 | rgb.x = texcolor.R; |
1343 | rgb.y = (255 - (texcolor.G * 255)) / 255; | 1367 | rgb.y = texcolor.G; |
1344 | rgb.z = (255 - (texcolor.B * 255)) / 255; | 1368 | rgb.z = texcolor.B; |
1345 | return rgb; | 1369 | return rgb; |
1346 | } | 1370 | } |
1347 | else | 1371 | else |
@@ -1371,7 +1395,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1371 | 1395 | ||
1372 | Primitive.TextureEntry tex = part.Shape.Textures; | 1396 | Primitive.TextureEntry tex = part.Shape.Textures; |
1373 | 1397 | ||
1374 | if (face > -1) | 1398 | if (face >= 0 && face < GetNumberOfSides(part)) |
1375 | { | 1399 | { |
1376 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); | 1400 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); |
1377 | texface.TextureID = textureID; | 1401 | texface.TextureID = textureID; |
@@ -1379,9 +1403,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1379 | part.UpdateTexture(tex); | 1403 | part.UpdateTexture(tex); |
1380 | return; | 1404 | return; |
1381 | } | 1405 | } |
1382 | else if (face == -1) | 1406 | else if (face == ScriptBaseClass.ALL_SIDES) |
1383 | { | 1407 | { |
1384 | for (uint i = 0; i < 32; i++) | 1408 | for (uint i = 0; i < GetNumberOfSides(part); i++) |
1385 | { | 1409 | { |
1386 | if (tex.FaceTextures[i] != null) | 1410 | if (tex.FaceTextures[i] != null) |
1387 | { | 1411 | { |
@@ -1405,7 +1429,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1405 | private void ScaleTexture(SceneObjectPart part, double u, double v, int face) | 1429 | private void ScaleTexture(SceneObjectPart part, double u, double v, int face) |
1406 | { | 1430 | { |
1407 | Primitive.TextureEntry tex = part.Shape.Textures; | 1431 | Primitive.TextureEntry tex = part.Shape.Textures; |
1408 | if (face > -1) | 1432 | if (face >= 0 && face < GetNumberOfSides(part)) |
1409 | { | 1433 | { |
1410 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); | 1434 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); |
1411 | texface.RepeatU = (float)u; | 1435 | texface.RepeatU = (float)u; |
@@ -1414,9 +1438,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1414 | part.UpdateTexture(tex); | 1438 | part.UpdateTexture(tex); |
1415 | return; | 1439 | return; |
1416 | } | 1440 | } |
1417 | if (face == -1) | 1441 | if (face == ScriptBaseClass.ALL_SIDES) |
1418 | { | 1442 | { |
1419 | for (int i = 0; i < 32; i++) | 1443 | for (int i = 0; i < GetNumberOfSides(part); i++) |
1420 | { | 1444 | { |
1421 | if (tex.FaceTextures[i] != null) | 1445 | if (tex.FaceTextures[i] != null) |
1422 | { | 1446 | { |
@@ -1441,7 +1465,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1441 | private void OffsetTexture(SceneObjectPart part, double u, double v, int face) | 1465 | private void OffsetTexture(SceneObjectPart part, double u, double v, int face) |
1442 | { | 1466 | { |
1443 | Primitive.TextureEntry tex = part.Shape.Textures; | 1467 | Primitive.TextureEntry tex = part.Shape.Textures; |
1444 | if (face > -1) | 1468 | if (face >= 0 && face < GetNumberOfSides(part)) |
1445 | { | 1469 | { |
1446 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); | 1470 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); |
1447 | texface.OffsetU = (float)u; | 1471 | texface.OffsetU = (float)u; |
@@ -1450,9 +1474,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1450 | part.UpdateTexture(tex); | 1474 | part.UpdateTexture(tex); |
1451 | return; | 1475 | return; |
1452 | } | 1476 | } |
1453 | if (face == -1) | 1477 | if (face == ScriptBaseClass.ALL_SIDES) |
1454 | { | 1478 | { |
1455 | for (int i = 0; i < 32; i++) | 1479 | for (int i = 0; i < GetNumberOfSides(part); i++) |
1456 | { | 1480 | { |
1457 | if (tex.FaceTextures[i] != null) | 1481 | if (tex.FaceTextures[i] != null) |
1458 | { | 1482 | { |
@@ -1477,7 +1501,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1477 | private void RotateTexture(SceneObjectPart part, double rotation, int face) | 1501 | private void RotateTexture(SceneObjectPart part, double rotation, int face) |
1478 | { | 1502 | { |
1479 | Primitive.TextureEntry tex = part.Shape.Textures; | 1503 | Primitive.TextureEntry tex = part.Shape.Textures; |
1480 | if (face > -1) | 1504 | if (face >= 0 && face < GetNumberOfSides(part)) |
1481 | { | 1505 | { |
1482 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); | 1506 | Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); |
1483 | texface.Rotation = (float)rotation; | 1507 | texface.Rotation = (float)rotation; |
@@ -1485,9 +1509,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1485 | part.UpdateTexture(tex); | 1509 | part.UpdateTexture(tex); |
1486 | return; | 1510 | return; |
1487 | } | 1511 | } |
1488 | if (face == -1) | 1512 | if (face == ScriptBaseClass.ALL_SIDES) |
1489 | { | 1513 | { |
1490 | for (int i = 0; i < 32; i++) | 1514 | for (int i = 0; i < GetNumberOfSides(part); i++) |
1491 | { | 1515 | { |
1492 | if (tex.FaceTextures[i] != null) | 1516 | if (tex.FaceTextures[i] != null) |
1493 | { | 1517 | { |
@@ -1503,12 +1527,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1503 | public LSL_Types.LSLString llGetTexture(int face) | 1527 | public LSL_Types.LSLString llGetTexture(int face) |
1504 | { | 1528 | { |
1505 | m_host.AddScriptLPS(1); | 1529 | m_host.AddScriptLPS(1); |
1506 | Primitive.TextureEntry tex = m_host.Shape.Textures; | 1530 | return GetTexture(m_host, face); |
1507 | if (face == -1) | 1531 | } |
1532 | |||
1533 | private LSL_Types.LSLString GetTexture(SceneObjectPart part, int face) | ||
1534 | { | ||
1535 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
1536 | if (face == ScriptBaseClass.ALL_SIDES) | ||
1508 | { | 1537 | { |
1509 | face = 0; | 1538 | face = 0; |
1510 | } | 1539 | } |
1511 | if (face > -1) | 1540 | if (face >= 0 && face < GetNumberOfSides(part)) |
1512 | { | 1541 | { |
1513 | Primitive.TextureEntryFace texface; | 1542 | Primitive.TextureEntryFace texface; |
1514 | texface = tex.GetFace((uint)face); | 1543 | texface = tex.GetFace((uint)face); |
@@ -3469,7 +3498,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3469 | return GetNumberOfSides(m_host); | 3498 | return GetNumberOfSides(m_host); |
3470 | } | 3499 | } |
3471 | 3500 | ||
3472 | public LSL_Types.LSLInteger GetNumberOfSides(SceneObjectPart part) | 3501 | private int GetNumberOfSides(SceneObjectPart part) |
3473 | { | 3502 | { |
3474 | int ret = 0; | 3503 | int ret = 0; |
3475 | bool hasCut; | 3504 | bool hasCut; |
@@ -3701,16 +3730,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3701 | public LSL_Types.Vector3 llGetTextureOffset(int face) | 3730 | public LSL_Types.Vector3 llGetTextureOffset(int face) |
3702 | { | 3731 | { |
3703 | m_host.AddScriptLPS(1); | 3732 | m_host.AddScriptLPS(1); |
3704 | Primitive.TextureEntry tex = m_host.Shape.Textures; | 3733 | return GetTextureOffset(m_host, face); |
3705 | LSL_Types.Vector3 offset; | 3734 | } |
3706 | if (face == -1) | 3735 | |
3736 | private LSL_Types.Vector3 GetTextureOffset(SceneObjectPart part, int face) | ||
3737 | { | ||
3738 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
3739 | LSL_Types.Vector3 offset = new LSL_Types.Vector3(); | ||
3740 | if (face == ScriptBaseClass.ALL_SIDES) | ||
3707 | { | 3741 | { |
3708 | face = 0; | 3742 | face = 0; |
3709 | } | 3743 | } |
3710 | offset.x = tex.GetFace((uint)face).OffsetU; | 3744 | if(face >= 0 && face < GetNumberOfSides(part)) |
3711 | offset.y = tex.GetFace((uint)face).OffsetV; | 3745 | { |
3712 | offset.z = 0.0; | 3746 | offset.x = tex.GetFace((uint)face).OffsetU; |
3713 | return offset; | 3747 | offset.y = tex.GetFace((uint)face).OffsetV; |
3748 | offset.z = 0.0; | ||
3749 | return offset; | ||
3750 | } | ||
3751 | else | ||
3752 | { | ||
3753 | return offset; | ||
3754 | } | ||
3714 | } | 3755 | } |
3715 | 3756 | ||
3716 | public LSL_Types.Vector3 llGetTextureScale(int side) | 3757 | public LSL_Types.Vector3 llGetTextureScale(int side) |
@@ -3731,12 +3772,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3731 | public LSL_Types.LSLFloat llGetTextureRot(int face) | 3772 | public LSL_Types.LSLFloat llGetTextureRot(int face) |
3732 | { | 3773 | { |
3733 | m_host.AddScriptLPS(1); | 3774 | m_host.AddScriptLPS(1); |
3734 | Primitive.TextureEntry tex = m_host.Shape.Textures; | 3775 | return GetTextureRot(m_host, face); |
3776 | } | ||
3777 | |||
3778 | private LSL_Types.LSLFloat GetTextureRot(SceneObjectPart part, int face) | ||
3779 | { | ||
3780 | Primitive.TextureEntry tex = part.Shape.Textures; | ||
3735 | if (face == -1) | 3781 | if (face == -1) |
3736 | { | 3782 | { |
3737 | face = 0; | 3783 | face = 0; |
3738 | } | 3784 | } |
3739 | return tex.GetFace((uint)face).Rotation; | 3785 | if (face >= 0 && face < GetNumberOfSides(part)) |
3786 | { | ||
3787 | return tex.GetFace((uint)face).Rotation; | ||
3788 | } | ||
3789 | else | ||
3790 | { | ||
3791 | return 0.0; | ||
3792 | } | ||
3740 | } | 3793 | } |
3741 | 3794 | ||
3742 | public LSL_Types.LSLInteger llSubStringIndex(string source, string pattern) | 3795 | public LSL_Types.LSLInteger llSubStringIndex(string source, string pattern) |
@@ -4385,7 +4438,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4385 | pTexAnim.Flags = (Primitive.TextureAnimMode)mode; | 4438 | pTexAnim.Flags = (Primitive.TextureAnimMode)mode; |
4386 | 4439 | ||
4387 | //ALL_SIDES | 4440 | //ALL_SIDES |
4388 | if (face == -1) | 4441 | if (face == ScriptBaseClass.ALL_SIDES) |
4389 | face = 255; | 4442 | face = 255; |
4390 | 4443 | ||
4391 | pTexAnim.Face = (uint)face; | 4444 | pTexAnim.Face = (uint)face; |
@@ -5807,11 +5860,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5807 | case (int)ScriptBaseClass.PRIM_GLOW: | 5860 | case (int)ScriptBaseClass.PRIM_GLOW: |
5808 | if (remain < 2) | 5861 | if (remain < 2) |
5809 | return; | 5862 | return; |
5810 | // TODO: LSL constant ALL_SIDES (value -1) is inserted into LSL_Types.list | 5863 | face = rules.GetLSLIntegerItem(idx++); |
5811 | // as a raw CLI Int32. When / if this is inserted as an | ||
5812 | // LSL_Types.LSLInteger extract value using LSL_Types.list.GetLSLIntegerItem | ||
5813 | // face = rules.GetLSLIntegerItem(idx++); | ||
5814 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
5815 | float glow = (float)rules.GetLSLFloatItem(idx++); | 5864 | float glow = (float)rules.GetLSLFloatItem(idx++); |
5816 | 5865 | ||
5817 | SetGlow(part, face, glow); | 5866 | SetGlow(part, face, glow); |
@@ -5830,11 +5879,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5830 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 5879 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
5831 | if (remain < 2) | 5880 | if (remain < 2) |
5832 | return; | 5881 | return; |
5833 | // TODO: LSL constant ALL_SIDES (value -1) is inserted into LSL_Types.list | 5882 | face = rules.GetLSLIntegerItem(idx++); |
5834 | // as a raw CLI Int32. When / if this is inserted as an | ||
5835 | // LSL_Types.LSLInteger extract value using LSL_Types.list.GetLSLIntegerItem | ||
5836 | // face = rules.GetLSLIntegerItem(idx++); | ||
5837 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
5838 | bool st = rules.GetLSLIntegerItem(idx++); | 5883 | bool st = rules.GetLSLIntegerItem(idx++); |
5839 | SetFullBright(part, face , st); | 5884 | SetFullBright(part, face , st); |
5840 | break; | 5885 | break; |
@@ -6019,7 +6064,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6019 | { | 6064 | { |
6020 | Primitive.TextureEntry tex = part.Shape.Textures; | 6065 | Primitive.TextureEntry tex = part.Shape.Textures; |
6021 | Color4 texcolor; | 6066 | Color4 texcolor; |
6022 | if (face > -1) | 6067 | if (face >= 0 && face < GetNumberOfSides(m_host)) |
6023 | { | 6068 | { |
6024 | texcolor = tex.CreateFace((uint)face).RGBA; | 6069 | texcolor = tex.CreateFace((uint)face).RGBA; |
6025 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); | 6070 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); |
@@ -6027,12 +6072,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6027 | part.UpdateTexture(tex); | 6072 | part.UpdateTexture(tex); |
6028 | return; | 6073 | return; |
6029 | } | 6074 | } |
6030 | else if (face == -1) | 6075 | else if (face == ScriptBaseClass.ALL_SIDES) |
6031 | { | 6076 | { |
6032 | texcolor = tex.DefaultTexture.RGBA; | 6077 | texcolor = tex.DefaultTexture.RGBA; |
6033 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); | 6078 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); |
6034 | tex.DefaultTexture.RGBA = texcolor; | 6079 | tex.DefaultTexture.RGBA = texcolor; |
6035 | for (uint i = 0; i < 32; i++) | 6080 | for (uint i = 0; i < GetNumberOfSides(m_host); i++) |
6036 | { | 6081 | { |
6037 | if (tex.FaceTextures[i] != null) | 6082 | if (tex.FaceTextures[i] != null) |
6038 | { | 6083 | { |
@@ -6242,7 +6287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6242 | 6287 | ||
6243 | int face = (int)rules.GetLSLIntegerItem(idx++); | 6288 | int face = (int)rules.GetLSLIntegerItem(idx++); |
6244 | Primitive.TextureEntry tex = m_host.Shape.Textures; | 6289 | Primitive.TextureEntry tex = m_host.Shape.Textures; |
6245 | if (face == -1) // ALL_SIDES | 6290 | if (face == ScriptBaseClass.ALL_SIDES) |
6246 | { | 6291 | { |
6247 | for (face = 0 ; face < GetNumberOfSides(m_host) ; face++) | 6292 | for (face = 0 ; face < GetNumberOfSides(m_host) ; face++) |
6248 | { | 6293 | { |
@@ -6260,16 +6305,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6260 | } | 6305 | } |
6261 | else | 6306 | else |
6262 | { | 6307 | { |
6263 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); | 6308 | if (face >= 0 && face < GetNumberOfSides(m_host)) |
6264 | 6309 | { | |
6265 | res.Add(new LSL_Types.LSLString(texface.TextureID.ToString())); | 6310 | Primitive.TextureEntryFace texface = tex.GetFace((uint)face); |
6266 | res.Add(new LSL_Types.Vector3(texface.RepeatU, | 6311 | |
6267 | texface.RepeatV, | 6312 | res.Add(new LSL_Types.LSLString(texface.TextureID.ToString())); |
6268 | 0)); | 6313 | res.Add(new LSL_Types.Vector3(texface.RepeatU, |
6269 | res.Add(new LSL_Types.Vector3(texface.OffsetU, | 6314 | texface.RepeatV, |
6270 | texface.OffsetV, | 6315 | 0)); |
6271 | 0)); | 6316 | res.Add(new LSL_Types.Vector3(texface.OffsetU, |
6272 | res.Add(new LSL_Types.LSLFloat(texface.Rotation)); | 6317 | texface.OffsetV, |
6318 | 0)); | ||
6319 | res.Add(new LSL_Types.LSLFloat(texface.Rotation)); | ||
6320 | } | ||
6273 | } | 6321 | } |
6274 | break; | 6322 | break; |
6275 | 6323 | ||
@@ -6281,24 +6329,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6281 | 6329 | ||
6282 | tex = m_host.Shape.Textures; | 6330 | tex = m_host.Shape.Textures; |
6283 | Color4 texcolor; | 6331 | Color4 texcolor; |
6284 | if (face == -1) // ALL_SIDES | 6332 | if (face == ScriptBaseClass.ALL_SIDES) |
6285 | { | 6333 | { |
6286 | for (face = 0 ; face < GetNumberOfSides(m_host) ; face++) | 6334 | for (face = 0 ; face < GetNumberOfSides(m_host) ; face++) |
6287 | { | 6335 | { |
6288 | texcolor = tex.GetFace((uint)face).RGBA; | 6336 | texcolor = tex.GetFace((uint)face).RGBA; |
6289 | res.Add(new LSL_Types.Vector3((255 - (texcolor.R * 255)) / 255, | 6337 | res.Add(new LSL_Types.Vector3(texcolor.R, |
6290 | (255 - (texcolor.G * 255)) / 255, | 6338 | texcolor.G, |
6291 | (255 - (texcolor.B * 255)) / 255)); | 6339 | texcolor.B)); |
6292 | res.Add(new LSL_Types.LSLFloat((texcolor.A * 255) / 255)); | 6340 | res.Add(new LSL_Types.LSLFloat(texcolor.A)); |
6293 | } | 6341 | } |
6294 | } | 6342 | } |
6295 | else | 6343 | else |
6296 | { | 6344 | { |
6297 | texcolor = tex.GetFace((uint)face).RGBA; | 6345 | texcolor = tex.GetFace((uint)face).RGBA; |
6298 | res.Add(new LSL_Types.Vector3((255 - (texcolor.R * 255)) / 255, | 6346 | res.Add(new LSL_Types.Vector3(texcolor.R, |
6299 | (255 - (texcolor.G * 255)) / 255, | 6347 | texcolor.G, |
6300 | (255 - (texcolor.B * 255)) / 255)); | 6348 | texcolor.B)); |
6301 | res.Add(new LSL_Types.LSLFloat((texcolor.A * 255) / 255)); | 6349 | res.Add(new LSL_Types.LSLFloat(texcolor.A)); |
6302 | } | 6350 | } |
6303 | break; | 6351 | break; |
6304 | 6352 | ||