diff options
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/PrimMesher.cs')
-rw-r--r-- | OpenSim/Region/Physics/Meshing/PrimMesher.cs | 188 |
1 files changed, 50 insertions, 138 deletions
diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index 6494cf5..55b8b1b 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs | |||
@@ -339,12 +339,6 @@ namespace PrimMesher | |||
339 | Coord edge1 = new Coord(this.n2.X - this.n1.X, this.n2.Y - this.n1.Y, this.n2.Z - this.n1.Z); | 339 | Coord edge1 = new Coord(this.n2.X - this.n1.X, this.n2.Y - this.n1.Y, this.n2.Z - this.n1.Z); |
340 | Coord edge2 = new Coord(this.n3.X - this.n1.X, this.n3.Y - this.n1.Y, this.n3.Z - this.n1.Z); | 340 | Coord edge2 = new Coord(this.n3.X - this.n1.X, this.n3.Y - this.n1.Y, this.n3.Z - this.n1.Z); |
341 | 341 | ||
342 | //Coord normal = Coord.Cross(edge1, edge2).Normalize(); | ||
343 | |||
344 | //this.n1 = normal; | ||
345 | //this.n2 = normal; | ||
346 | //this.n3 = normal; | ||
347 | |||
348 | this.n1 = this.n2 = this.n3 = Coord.Cross(edge1, edge2).Normalize(); | 342 | this.n1 = this.n2 = this.n3 = Coord.Cross(edge1, edge2).Normalize(); |
349 | } | 343 | } |
350 | } | 344 | } |
@@ -573,7 +567,6 @@ namespace PrimMesher | |||
573 | List<Coord> hollowNormals = new List<Coord>(); | 567 | List<Coord> hollowNormals = new List<Coord>(); |
574 | List<float> hollowUs = new List<float>(); | 568 | List<float> hollowUs = new List<float>(); |
575 | 569 | ||
576 | //Quat rot180 = new Quat(new Coord(0.0f, 0.0f, 1.0f), (float)Math.PI); ; | ||
577 | bool hasHollow = (hollow > 0.0f); | 570 | bool hasHollow = (hollow > 0.0f); |
578 | 571 | ||
579 | bool hasProfileCut = (profileStart > 0.0f || profileEnd < 1.0f); | 572 | bool hasProfileCut = (profileStart > 0.0f || profileEnd < 1.0f); |
@@ -591,7 +584,6 @@ namespace PrimMesher | |||
591 | 584 | ||
592 | float startAngle = profileStart * twoPi; | 585 | float startAngle = profileStart * twoPi; |
593 | float stopAngle = profileEnd * twoPi; | 586 | float stopAngle = profileEnd * twoPi; |
594 | // float stepSize = twoPi / sides; | ||
595 | 587 | ||
596 | try { angles.makeAngles(sides, startAngle, stopAngle); } | 588 | try { angles.makeAngles(sides, startAngle, stopAngle); } |
597 | catch (Exception ex) | 589 | catch (Exception ex) |
@@ -625,8 +617,9 @@ namespace PrimMesher | |||
625 | else if (!simpleFace) | 617 | else if (!simpleFace) |
626 | { | 618 | { |
627 | this.coords.Add(center); | 619 | this.coords.Add(center); |
628 | if (this.calcVertexNormals)// && sides > 4) | 620 | if (this.calcVertexNormals) |
629 | this.vertexNormals.Add(new Coord(0.0f, 0.0f, 1.0f)); | 621 | this.vertexNormals.Add(new Coord(0.0f, 0.0f, 1.0f)); |
622 | this.us.Add(0.0f); | ||
630 | } | 623 | } |
631 | 624 | ||
632 | float z = 0.0f; | 625 | float z = 0.0f; |
@@ -646,9 +639,6 @@ namespace PrimMesher | |||
646 | hollowCoords.Add(newVert); | 639 | hollowCoords.Add(newVert); |
647 | if (this.calcVertexNormals) | 640 | if (this.calcVertexNormals) |
648 | { | 641 | { |
649 | //Coord hollowNormal = new Coord(angle.X, angle.Y, 0.0f); | ||
650 | //hollowNormal *= rot180; | ||
651 | //hollowNormals.Add(hollowNormal); | ||
652 | hollowNormals.Add(new Coord(-angle.X, -angle.Y, 0.0f)); | 642 | hollowNormals.Add(new Coord(-angle.X, -angle.Y, 0.0f)); |
653 | hollowUs.Add(angle.angle); | 643 | hollowUs.Add(angle.angle); |
654 | } | 644 | } |
@@ -658,8 +648,6 @@ namespace PrimMesher | |||
658 | int index = 0; | 648 | int index = 0; |
659 | int numAngles = angles.angles.Count; | 649 | int numAngles = angles.angles.Count; |
660 | 650 | ||
661 | //float sideIncrement = 1.0f / (float)sides; | ||
662 | |||
663 | for (int i = 0; i < numAngles; i++) | 651 | for (int i = 0; i < numAngles; i++) |
664 | { | 652 | { |
665 | angle = angles.angles[i]; | 653 | angle = angles.angles[i]; |
@@ -673,8 +661,6 @@ namespace PrimMesher | |||
673 | if (sides < 5) | 661 | if (sides < 5) |
674 | { | 662 | { |
675 | float u = angle.angle; | 663 | float u = angle.angle; |
676 | //u %= sideIncrement; | ||
677 | //u *= sides; | ||
678 | this.us.Add(u); | 664 | this.us.Add(u); |
679 | } | 665 | } |
680 | else | 666 | else |
@@ -691,9 +677,6 @@ namespace PrimMesher | |||
691 | hollowCoords.Add(newVert); | 677 | hollowCoords.Add(newVert); |
692 | if (this.calcVertexNormals) | 678 | if (this.calcVertexNormals) |
693 | { | 679 | { |
694 | //Coord hollowNormal = new Coord(angle.X, angle.Y, 0.0f); | ||
695 | //hollowNormal *= rot180; | ||
696 | //hollowNormals.Add(hollowNormal); | ||
697 | hollowNormals.Add(new Coord(-angle.X, -angle.Y, 0.0f)); | 680 | hollowNormals.Add(new Coord(-angle.X, -angle.Y, 0.0f)); |
698 | hollowUs.Add(angle.angle); | 681 | hollowUs.Add(angle.angle); |
699 | } | 682 | } |
@@ -976,16 +959,11 @@ namespace PrimMesher | |||
976 | this.faceNormal.Y = -this.faceNormal.Y; | 959 | this.faceNormal.Y = -this.faceNormal.Y; |
977 | this.faceNormal.Z = -this.faceNormal.Z; | 960 | this.faceNormal.Z = -this.faceNormal.Z; |
978 | 961 | ||
979 | //int numUs = this.us.Count; | ||
980 | //for (int i = 0; i < numUs; i++) | ||
981 | // this.us[i] | ||
982 | |||
983 | int numfaceUVs = this.faceUVs.Count; | 962 | int numfaceUVs = this.faceUVs.Count; |
984 | for (i = 0; i < numfaceUVs; i++) | 963 | for (i = 0; i < numfaceUVs; i++) |
985 | { | 964 | { |
986 | UVCoord uv = this.faceUVs[i]; | 965 | UVCoord uv = this.faceUVs[i]; |
987 | uv.U = 1.0f - uv.U; | 966 | uv.U = 1.0f - uv.U; |
988 | //uv.V = 1.0f - uv.V; | ||
989 | this.faceUVs[i] = uv; | 967 | this.faceUVs[i] = uv; |
990 | } | 968 | } |
991 | } | 969 | } |
@@ -1077,6 +1055,7 @@ namespace PrimMesher | |||
1077 | public int stepsPerRevolution = 24; | 1055 | public int stepsPerRevolution = 24; |
1078 | 1056 | ||
1079 | private bool hasProfileCut = false; | 1057 | private bool hasProfileCut = false; |
1058 | private bool hasHollow = false; | ||
1080 | public bool calcVertexNormals = false; | 1059 | public bool calcVertexNormals = false; |
1081 | private bool normalsProcessed = false; | 1060 | private bool normalsProcessed = false; |
1082 | public bool viewerMode = false; | 1061 | public bool viewerMode = false; |
@@ -1139,6 +1118,7 @@ namespace PrimMesher | |||
1139 | this.hollow = 0.0f; | 1118 | this.hollow = 0.0f; |
1140 | 1119 | ||
1141 | this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f); | 1120 | this.hasProfileCut = (this.profileStart > 0.0f || this.profileEnd < 1.0f); |
1121 | this.hasHollow = (this.hollow > 0.001f); | ||
1142 | } | 1122 | } |
1143 | 1123 | ||
1144 | public void ExtrudeLinear() | 1124 | public void ExtrudeLinear() |
@@ -1216,6 +1196,14 @@ namespace PrimMesher | |||
1216 | 1196 | ||
1217 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true, calcVertexNormals); | 1197 | Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true, calcVertexNormals); |
1218 | 1198 | ||
1199 | int cut1Vert = -1; | ||
1200 | int cut2Vert = -1; | ||
1201 | if (hasProfileCut) | ||
1202 | { | ||
1203 | cut1Vert = hasHollow ? profile.coords.Count - 1 : 0; | ||
1204 | cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts; | ||
1205 | } | ||
1206 | |||
1219 | if (initialProfileRot != 0.0f) | 1207 | if (initialProfileRot != 0.0f) |
1220 | { | 1208 | { |
1221 | profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); | 1209 | profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot)); |
@@ -1308,22 +1296,26 @@ namespace PrimMesher | |||
1308 | if (step > 0) | 1296 | if (step > 0) |
1309 | { | 1297 | { |
1310 | int startVert = coordsLen + 1; | 1298 | int startVert = coordsLen + 1; |
1311 | int endVert = this.coords.Count - 1; | 1299 | int endVert = this.coords.Count; |
1312 | 1300 | ||
1313 | if (sides < 5 || this.hasProfileCut || hollow > 0.0f) | 1301 | if (sides < 5 || this.hasProfileCut || hollow > 0.0f) |
1314 | startVert--; | 1302 | startVert--; |
1315 | 1303 | ||
1316 | for (int i = startVert; i < endVert; i++) | 1304 | for (int i = startVert; i < endVert; i++) |
1317 | { | 1305 | { |
1306 | int iNext = i + 1; | ||
1307 | if (i == endVert - 1) | ||
1308 | iNext = startVert; | ||
1309 | |||
1318 | int whichVert = i - startVert; | 1310 | int whichVert = i - startVert; |
1319 | 1311 | ||
1320 | newFace.v1 = i; | 1312 | newFace.v1 = i; |
1321 | newFace.v2 = i - numVerts; | 1313 | newFace.v2 = i - numVerts; |
1322 | newFace.v3 = i - numVerts + 1; | 1314 | newFace.v3 = iNext - numVerts; |
1323 | this.faces.Add(newFace); | 1315 | this.faces.Add(newFace); |
1324 | 1316 | ||
1325 | newFace.v2 = i - numVerts + 1; | 1317 | newFace.v2 = iNext - numVerts; |
1326 | newFace.v3 = i + 1; | 1318 | newFace.v3 = iNext; |
1327 | this.faces.Add(newFace); | 1319 | this.faces.Add(newFace); |
1328 | 1320 | ||
1329 | if (this.viewerMode) | 1321 | if (this.viewerMode) |
@@ -1346,12 +1338,16 @@ namespace PrimMesher | |||
1346 | u2 -= whichVert; | 1338 | u2 -= whichVert; |
1347 | if (u2 < 0.1f) | 1339 | if (u2 < 0.1f) |
1348 | u2 = 1.0f; | 1340 | u2 = 1.0f; |
1349 | //u1 = 0.0f; | ||
1350 | //u2 = 1.0f; | ||
1351 | 1341 | ||
1352 | newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; | 1342 | newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1; |
1353 | } | 1343 | } |
1354 | 1344 | ||
1345 | if (whichVert == cut1Vert || whichVert == cut2Vert) | ||
1346 | { | ||
1347 | u1 = 0.0f; | ||
1348 | u2 = 1.0f; | ||
1349 | } | ||
1350 | |||
1355 | newViewerFace1.uv1.U = u1; | 1351 | newViewerFace1.uv1.U = u1; |
1356 | newViewerFace1.uv2.U = u1; | 1352 | newViewerFace1.uv2.U = u1; |
1357 | newViewerFace1.uv3.U = u2; | 1353 | newViewerFace1.uv3.U = u2; |
@@ -1370,13 +1366,13 @@ namespace PrimMesher | |||
1370 | 1366 | ||
1371 | newViewerFace1.v1 = this.coords[i]; | 1367 | newViewerFace1.v1 = this.coords[i]; |
1372 | newViewerFace1.v2 = this.coords[i - numVerts]; | 1368 | newViewerFace1.v2 = this.coords[i - numVerts]; |
1373 | newViewerFace1.v3 = this.coords[i - numVerts + 1]; | 1369 | newViewerFace1.v3 = this.coords[iNext - numVerts]; |
1374 | 1370 | ||
1375 | newViewerFace2.v1 = this.coords[i]; | 1371 | newViewerFace2.v1 = this.coords[i]; |
1376 | newViewerFace2.v2 = this.coords[i - numVerts + 1]; | 1372 | newViewerFace2.v2 = this.coords[iNext - numVerts]; |
1377 | newViewerFace2.v3 = this.coords[i + 1]; | 1373 | newViewerFace2.v3 = this.coords[iNext]; |
1378 | 1374 | ||
1379 | if (whichVert == newLayer.numOuterVerts - 1 && hasProfileCut) | 1375 | if (whichVert == cut1Vert) |
1380 | { // start profile cut faces | 1376 | { // start profile cut faces |
1381 | 1377 | ||
1382 | newViewerFace1.n2 = newViewerFace1.n1 = lastCutNormal1; | 1378 | newViewerFace1.n2 = newViewerFace1.n1 = lastCutNormal1; |
@@ -1397,11 +1393,11 @@ namespace PrimMesher | |||
1397 | { | 1393 | { |
1398 | newViewerFace1.n1 = this.normals[i]; | 1394 | newViewerFace1.n1 = this.normals[i]; |
1399 | newViewerFace1.n2 = this.normals[i - numVerts]; | 1395 | newViewerFace1.n2 = this.normals[i - numVerts]; |
1400 | newViewerFace1.n3 = this.normals[i - numVerts + 1]; | 1396 | newViewerFace1.n3 = this.normals[iNext - numVerts]; |
1401 | 1397 | ||
1402 | newViewerFace2.n1 = this.normals[i]; | 1398 | newViewerFace2.n1 = this.normals[i]; |
1403 | newViewerFace2.n2 = this.normals[i - numVerts + 1]; | 1399 | newViewerFace2.n2 = this.normals[iNext - numVerts]; |
1404 | newViewerFace2.n3 = this.normals[i + 1]; | 1400 | newViewerFace2.n3 = this.normals[iNext]; |
1405 | } | 1401 | } |
1406 | } | 1402 | } |
1407 | 1403 | ||
@@ -1413,7 +1409,7 @@ namespace PrimMesher | |||
1413 | 1409 | ||
1414 | if (this.hasProfileCut) | 1410 | if (this.hasProfileCut) |
1415 | { // add the end cut face to the list of viewerFaces here | 1411 | { // add the end cut face to the list of viewerFaces here |
1416 | // the first cut face was filled in the above loop | 1412 | // the prior cut face was filled in the above loop |
1417 | newFace.v1 = coordsLen - 1; | 1413 | newFace.v1 = coordsLen - 1; |
1418 | newFace.v2 = coordsLen - numVerts; | 1414 | newFace.v2 = coordsLen - numVerts; |
1419 | newFace.v3 = coordsLen; | 1415 | newFace.v3 = coordsLen; |
@@ -1423,43 +1419,6 @@ namespace PrimMesher | |||
1423 | newFace.v2 = coordsLen - 1; | 1419 | newFace.v2 = coordsLen - 1; |
1424 | newFace.v3 = coordsLen; | 1420 | newFace.v3 = coordsLen; |
1425 | this.faces.Add(newFace); | 1421 | this.faces.Add(newFace); |
1426 | |||
1427 | if (this.viewerMode) | ||
1428 | { | ||
1429 | ViewerFace newViewerFace = new ViewerFace(); | ||
1430 | newViewerFace.v1 = this.coords[coordsLen - 1]; // last vert in prior layer | ||
1431 | newViewerFace.v2 = this.coords[coordsLen - numVerts]; // first vert in prior layer | ||
1432 | newViewerFace.v3 = this.coords[coordsLen]; // first vert in new layer | ||
1433 | |||
1434 | float u1 = newLayer.us[0]; | ||
1435 | float u2 = newLayer.us[newLayer.us.Count - 1]; | ||
1436 | |||
1437 | newViewerFace.n2 = newViewerFace.n1 = lastCutNormal2; | ||
1438 | newViewerFace.n3 = newLayer.cutNormal2; | ||
1439 | |||
1440 | newViewerFace.uv3.U = newViewerFace.uv1.U = u2; | ||
1441 | newViewerFace.uv2.U = u1; | ||
1442 | |||
1443 | newViewerFace.uv1.V = newViewerFace.uv2.V = lastV; | ||
1444 | newViewerFace.uv3.V = 1.0f - percentOfPath; | ||
1445 | |||
1446 | this.viewerFaces.Add(newViewerFace); | ||
1447 | |||
1448 | newViewerFace.v1 = this.coords[coordsLen + numVerts - 1]; // last vert in new layer | ||
1449 | newViewerFace.v2 = this.coords[coordsLen - 1]; // last vert in prior layer | ||
1450 | newViewerFace.v3 = this.coords[coordsLen]; // first vert in new layer | ||
1451 | |||
1452 | newViewerFace.n3 = newViewerFace.n1 = newLayer.cutNormal2; | ||
1453 | newViewerFace.n2 = lastCutNormal2; | ||
1454 | |||
1455 | newViewerFace.uv2.U = newViewerFace.uv1.U = u1; | ||
1456 | newViewerFace.uv3.U = u2; | ||
1457 | |||
1458 | newViewerFace.uv3.V = newViewerFace.uv1.V = 1.0f - percentOfPath; | ||
1459 | newViewerFace.uv2.V = lastV; | ||
1460 | |||
1461 | this.viewerFaces.Add(newViewerFace); | ||
1462 | } | ||
1463 | } | 1422 | } |
1464 | 1423 | ||
1465 | } | 1424 | } |
@@ -1729,23 +1688,26 @@ namespace PrimMesher | |||
1729 | if (step > firstStep) | 1688 | if (step > firstStep) |
1730 | { | 1689 | { |
1731 | int startVert = coordsLen + 1; | 1690 | int startVert = coordsLen + 1; |
1732 | int endVert = this.coords.Count - 1; | 1691 | int endVert = this.coords.Count; |
1733 | 1692 | ||
1734 | if (sides < 5 || this.hasProfileCut || hollow > 0.0f) | 1693 | if (sides < 5 || this.hasProfileCut || hollow > 0.0f) |
1735 | startVert--; | 1694 | startVert--; |
1736 | 1695 | ||
1737 | for (int i = startVert; i < endVert; i++) | 1696 | for (int i = startVert; i < endVert; i++) |
1738 | //for (int i = coordsLen; i < this.coords.Count - 1; i++) | ||
1739 | { | 1697 | { |
1698 | int iNext = i + 1; | ||
1699 | if (i == endVert - 1) | ||
1700 | iNext = startVert; | ||
1701 | |||
1740 | int whichVert = i - startVert; | 1702 | int whichVert = i - startVert; |
1741 | 1703 | ||
1742 | newFace.v1 = i; | 1704 | newFace.v1 = i; |
1743 | newFace.v2 = i - numVerts; | 1705 | newFace.v2 = i - numVerts; |
1744 | newFace.v3 = i - numVerts + 1; | 1706 | newFace.v3 = iNext - numVerts; |
1745 | this.faces.Add(newFace); | 1707 | this.faces.Add(newFace); |
1746 | 1708 | ||
1747 | newFace.v2 = i - numVerts + 1; | 1709 | newFace.v2 = iNext - numVerts; |
1748 | newFace.v3 = i + 1; | 1710 | newFace.v3 = iNext; |
1749 | this.faces.Add(newFace); | 1711 | this.faces.Add(newFace); |
1750 | 1712 | ||
1751 | if (this.viewerMode) | 1713 | if (this.viewerMode) |
@@ -1776,11 +1738,11 @@ namespace PrimMesher | |||
1776 | 1738 | ||
1777 | newViewerFace1.v1 = this.coords[i]; | 1739 | newViewerFace1.v1 = this.coords[i]; |
1778 | newViewerFace1.v2 = this.coords[i - numVerts]; | 1740 | newViewerFace1.v2 = this.coords[i - numVerts]; |
1779 | newViewerFace1.v3 = this.coords[i - numVerts + 1]; | 1741 | newViewerFace1.v3 = this.coords[iNext - numVerts]; |
1780 | 1742 | ||
1781 | newViewerFace2.v1 = this.coords[i]; | 1743 | newViewerFace2.v1 = this.coords[i]; |
1782 | newViewerFace2.v2 = this.coords[i - numVerts + 1]; | 1744 | newViewerFace2.v2 = this.coords[iNext - numVerts]; |
1783 | newViewerFace2.v3 = this.coords[i + 1]; | 1745 | newViewerFace2.v3 = this.coords[iNext]; |
1784 | 1746 | ||
1785 | if (whichVert == newLayer.numOuterVerts - 1 && hasProfileCut) | 1747 | if (whichVert == newLayer.numOuterVerts - 1 && hasProfileCut) |
1786 | { // start profile cut faces | 1748 | { // start profile cut faces |
@@ -1803,11 +1765,11 @@ namespace PrimMesher | |||
1803 | { | 1765 | { |
1804 | newViewerFace1.n1 = this.normals[i]; | 1766 | newViewerFace1.n1 = this.normals[i]; |
1805 | newViewerFace1.n2 = this.normals[i - numVerts]; | 1767 | newViewerFace1.n2 = this.normals[i - numVerts]; |
1806 | newViewerFace1.n3 = this.normals[i - numVerts + 1]; | 1768 | newViewerFace1.n3 = this.normals[iNext - numVerts]; |
1807 | 1769 | ||
1808 | newViewerFace2.n1 = this.normals[i]; | 1770 | newViewerFace2.n1 = this.normals[i]; |
1809 | newViewerFace2.n2 = this.normals[i - numVerts + 1]; | 1771 | newViewerFace2.n2 = this.normals[iNext - numVerts]; |
1810 | newViewerFace2.n3 = this.normals[i + 1]; | 1772 | newViewerFace2.n3 = this.normals[iNext]; |
1811 | } | 1773 | } |
1812 | } | 1774 | } |
1813 | 1775 | ||
@@ -1816,57 +1778,6 @@ namespace PrimMesher | |||
1816 | 1778 | ||
1817 | } | 1779 | } |
1818 | } | 1780 | } |
1819 | |||
1820 | if (this.hasProfileCut) | ||
1821 | { // add the end cut face to the list of viewerFaces here | ||
1822 | // the first cut face was filled in the above loop | ||
1823 | newFace.v1 = coordsLen - 1; | ||
1824 | newFace.v2 = coordsLen - numVerts; | ||
1825 | newFace.v3 = coordsLen; | ||
1826 | this.faces.Add(newFace); | ||
1827 | |||
1828 | newFace.v1 = coordsLen + numVerts - 1; | ||
1829 | newFace.v2 = coordsLen - 1; | ||
1830 | newFace.v3 = coordsLen; | ||
1831 | this.faces.Add(newFace); | ||
1832 | |||
1833 | if (this.viewerMode) | ||
1834 | { | ||
1835 | ViewerFace newViewerFace = new ViewerFace(); | ||
1836 | newViewerFace.v1 = this.coords[coordsLen - 1]; // last vert in prior layer | ||
1837 | newViewerFace.v2 = this.coords[coordsLen - numVerts]; // first vert in prior layer | ||
1838 | newViewerFace.v3 = this.coords[coordsLen]; // first vert in new layer | ||
1839 | |||
1840 | float u1 = newLayer.us[0]; | ||
1841 | float u2 = newLayer.us[newLayer.us.Count - 1]; | ||
1842 | |||
1843 | newViewerFace.n2 = newViewerFace.n1 = lastCutNormal2; | ||
1844 | newViewerFace.n3 = newLayer.cutNormal2; | ||
1845 | |||
1846 | newViewerFace.uv3.U = newViewerFace.uv1.U = u2; | ||
1847 | newViewerFace.uv2.U = u1; | ||
1848 | |||
1849 | newViewerFace.uv1.V = newViewerFace.uv2.V = lastV; | ||
1850 | newViewerFace.uv3.V = 1.0f - percentOfPath; | ||
1851 | |||
1852 | this.viewerFaces.Add(newViewerFace); | ||
1853 | |||
1854 | newViewerFace.v1 = this.coords[coordsLen + numVerts - 1]; // last vert in new layer | ||
1855 | newViewerFace.v2 = this.coords[coordsLen - 1]; // last vert in prior layer | ||
1856 | newViewerFace.v3 = this.coords[coordsLen]; // first vert in new layer | ||
1857 | |||
1858 | newViewerFace.n3 = newViewerFace.n1 = newLayer.cutNormal2; | ||
1859 | newViewerFace.n2 = lastCutNormal2; | ||
1860 | |||
1861 | newViewerFace.uv2.U = newViewerFace.uv1.U = u1; | ||
1862 | newViewerFace.uv3.U = u2; | ||
1863 | |||
1864 | newViewerFace.uv3.V = newViewerFace.uv1.V = 1.0f - percentOfPath; | ||
1865 | newViewerFace.uv2.V = lastV; | ||
1866 | |||
1867 | this.viewerFaces.Add(newViewerFace); | ||
1868 | } | ||
1869 | } | ||
1870 | } | 1781 | } |
1871 | 1782 | ||
1872 | lastCutNormal1 = newLayer.cutNormal1; | 1783 | lastCutNormal1 = newLayer.cutNormal1; |
@@ -1930,7 +1841,8 @@ namespace PrimMesher | |||
1930 | 1841 | ||
1931 | public Coord SurfaceNormal(int faceIndex) | 1842 | public Coord SurfaceNormal(int faceIndex) |
1932 | { | 1843 | { |
1933 | if (faceIndex < 0 || faceIndex >= faces.Count) | 1844 | int numFaces = faces.Count; |
1845 | if (faceIndex < 0 || faceIndex >= numFaces) | ||
1934 | throw new Exception("faceIndex out of range"); | 1846 | throw new Exception("faceIndex out of range"); |
1935 | 1847 | ||
1936 | //return new Coord(0.0f, 0.0f, 0.0f); | 1848 | //return new Coord(0.0f, 0.0f, 0.0f); |