aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTeravus Ovares2008-06-19 04:17:04 +0000
committerTeravus Ovares2008-06-19 04:17:04 +0000
commite6ce30d4f142a75bdf581f2cf92ccb5c1d17e2f0 (patch)
treebfd5326ed4af7543996f2697dccfbe6810e90b1b /OpenSim/Region
parentMantis#1566. Thank you kindly for a number of (diff)
downloadopensim-SC-e6ce30d4f142a75bdf581f2cf92ccb5c1d17e2f0.zip
opensim-SC-e6ce30d4f142a75bdf581f2cf92ccb5c1d17e2f0.tar.gz
opensim-SC-e6ce30d4f142a75bdf581f2cf92ccb5c1d17e2f0.tar.bz2
opensim-SC-e6ce30d4f142a75bdf581f2cf92ccb5c1d17e2f0.tar.xz
* 0001571: (PATCH) patch to implement editable sphere meshes for meshmerizer/ode (Initial Implementation) from Dahlia! Thanks Dahlia!!!
* The included patch implements the editor parameters twist, dimple, path cut, and profile cut to the sphere mesh for meshmerizer. The mesh will default back to the geodesic sphere if the parameters are adjusted to beyond a reasonable arbitrarily chosen threshold that would expose too many inverted normals on the mesh.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs128
1 files changed, 111 insertions, 17 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index 9afc7ae..dfcf99a 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -657,6 +657,14 @@ namespace OpenSim.Region.Physics.Meshing
657 //Mesh result = extr.Extrude(m); 657 //Mesh result = extr.Extrude(m);
658 Mesh result = extr.ExtrudeLinearPath(m); 658 Mesh result = extr.ExtrudeLinearPath(m);
659 result.DumpRaw(baseDir, primName, "Z extruded"); 659 result.DumpRaw(baseDir, primName, "Z extruded");
660#if SPAM
661 int vCount = 0;
662
663 foreach (Vertex v in result.vertices)
664 if (v != null)
665 vCount++;
666 System.Console.WriteLine("Mesh vertex count: " + vCount.ToString());
667#endif
660 return result; 668 return result;
661 } 669 }
662 670
@@ -1002,6 +1010,14 @@ namespace OpenSim.Region.Physics.Meshing
1002 //Mesh result = extr.Extrude(m); 1010 //Mesh result = extr.Extrude(m);
1003 Mesh result = extr.ExtrudeLinearPath(m); 1011 Mesh result = extr.ExtrudeLinearPath(m);
1004 result.DumpRaw(baseDir, primName, "Z extruded"); 1012 result.DumpRaw(baseDir, primName, "Z extruded");
1013#if SPAM
1014 int vCount = 0;
1015
1016 foreach (Vertex v in result.vertices)
1017 if (v != null)
1018 vCount++;
1019 System.Console.WriteLine("Mesh vertex count: " + vCount.ToString());
1020#endif
1005 return result; 1021 return result;
1006 } 1022 }
1007 1023
@@ -1238,6 +1254,14 @@ namespace OpenSim.Region.Physics.Meshing
1238 //Mesh result = extr.Extrude(m); 1254 //Mesh result = extr.Extrude(m);
1239 Mesh result = extr.ExtrudeLinearPath(m); 1255 Mesh result = extr.ExtrudeLinearPath(m);
1240 result.DumpRaw(baseDir, primName, "Z extruded"); 1256 result.DumpRaw(baseDir, primName, "Z extruded");
1257#if SPAM
1258 int vCount = 0;
1259
1260 foreach (Vertex v in result.vertices)
1261 if (v != null)
1262 vCount++;
1263 System.Console.WriteLine("Mesh vertex count: " + vCount.ToString());
1264#endif
1241 return result; 1265 return result;
1242 } 1266 }
1243 1267
@@ -1330,6 +1354,14 @@ namespace OpenSim.Region.Physics.Meshing
1330 } 1354 }
1331 // Dump the faces for visualization in blender. 1355 // Dump the faces for visualization in blender.
1332 m.DumpRaw(baseDir, primName, "Icosahedron"); 1356 m.DumpRaw(baseDir, primName, "Icosahedron");
1357#if SPAM
1358 int vCount = 0;
1359
1360 foreach (Vertex v in m.vertices)
1361 if (v != null)
1362 vCount++;
1363 System.Console.WriteLine("Mesh vertex count: " + vCount.ToString());
1364#endif
1333 1365
1334 return m; 1366 return m;
1335 } 1367 }
@@ -1386,9 +1418,6 @@ namespace OpenSim.Region.Physics.Meshing
1386 SimpleHull outerHull = new SimpleHull(); 1418 SimpleHull outerHull = new SimpleHull();
1387 1419
1388 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle) 1420 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
1389
1390 //if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle
1391 // || (primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square)
1392 { 1421 {
1393#if SPAM 1422#if SPAM
1394 Console.WriteLine("Meshmerizer thinks " + primName + " is a TORUS"); 1423 Console.WriteLine("Meshmerizer thinks " + primName + " is a TORUS");
@@ -1458,11 +1487,46 @@ namespace OpenSim.Region.Physics.Meshing
1458#if SPAM 1487#if SPAM
1459 Console.WriteLine("Meshmerizer thinks " + primName + " is a SPHERE"); 1488 Console.WriteLine("Meshmerizer thinks " + primName + " is a SPHERE");
1460#endif 1489#endif
1490
1491 // sanity check here... some spheres have inverted normals which can trap avatars
1492 // so for now if the shape parameters are such that this may happen, revert to the
1493 // geodesic sphere mesh.. the threshold is arbitrary as it seems any twist on a sphere
1494 // will create some inverted normals
1495 if (
1496 (System.Math.Abs(primShape.PathTwist - primShape.PathTwistBegin) > 65)
1497 || (primShape.PathBegin == 0
1498 && primShape.PathEnd == 0
1499 && primShape.PathTwist == 0
1500 && primShape.PathTwistBegin == 0
1501 && primShape.ProfileBegin == 0
1502 && primShape.ProfileEnd == 0
1503 ) // simple sphere, revert to geodesic shape
1504
1505 )
1506 {
1507#if SPAM
1508 System.Console.WriteLine( "reverting to geodesic sphere for prim: " + primName );
1509#endif
1510 return CreateSphereMesh(primName, primShape, size);
1511 }
1512
1461 if (hollowShape == HollowShape.Same) 1513 if (hollowShape == HollowShape.Same)
1462 hollowShape = HollowShape.Circle; 1514 hollowShape = HollowShape.Circle;
1463 1515
1464 // not implemented here, use old routine 1516 outerHull.AddVertex(new Vertex(0.250000f, 0.433013f, 0.0f)); // 60 degrees
1465 return CreateSphereMesh(primName, primShape, size); 1517 outerHull.AddVertex(new Vertex(0.129410f, 0.482963f, 0.0f)); // 75 degrees
1518 outerHull.AddVertex(new Vertex(0.000000f, 0.500000f, 0.0f)); // 90 degrees
1519 outerHull.AddVertex(new Vertex(-0.129410f, 0.482963f, 0.0f)); // 105 degrees
1520 outerHull.AddVertex(new Vertex(-0.250000f, 0.433013f, 0.0f)); // 120 degrees
1521 outerHull.AddVertex(new Vertex(-0.353553f, 0.353553f, 0.0f)); // 135 degrees
1522 outerHull.AddVertex(new Vertex(-0.433013f, 0.250000f, 0.0f)); // 150 degrees
1523 outerHull.AddVertex(new Vertex(-0.482963f, 0.129410f, 0.0f)); // 165 degrees
1524 outerHull.AddVertex(new Vertex(-0.500000f, 0.000000f, 0.0f)); // 180 degrees
1525
1526 outerHull.AddVertex(new Vertex(0.500000f, 0.000000f, 0.0f)); // 0 degrees
1527 outerHull.AddVertex(new Vertex(0.482963f, 0.129410f, 0.0f)); // 15 degrees
1528 outerHull.AddVertex(new Vertex(0.433013f, 0.250000f, 0.0f)); // 30 degrees
1529 outerHull.AddVertex(new Vertex(0.353553f, 0.353553f, 0.0f)); // 45 degrees
1466 } 1530 }
1467 1531
1468 // Deal with cuts now 1532 // Deal with cuts now
@@ -1476,6 +1540,19 @@ namespace OpenSim.Region.Physics.Meshing
1476 if (fProfileBeginAngle < fProfileEndAngle) 1540 if (fProfileBeginAngle < fProfileEndAngle)
1477 fProfileEndAngle -= 360.0; 1541 fProfileEndAngle -= 360.0;
1478 1542
1543 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
1544 { // dimpled sphere uses profile cut but since it's a half circle the angles are smaller
1545
1546 fProfileBeginAngle = 0.0036f * (float)primShape.ProfileBegin;
1547 fProfileEndAngle = 180.0f - 0.0036f * (float)primShape.ProfileEnd;
1548 if (fProfileBeginAngle < fProfileEndAngle)
1549 fProfileEndAngle -= 360.0f;
1550
1551#if SPAM
1552 Console.WriteLine("Sphere dimple: fProfileBeginAngle: " + fProfileBeginAngle.ToString() + " fProfileEndAngle: " + fProfileEndAngle.ToString());
1553#endif
1554 }
1555
1479 // Note, that we don't want to cut out a triangle, even if this is a 1556 // Note, that we don't want to cut out a triangle, even if this is a
1480 // good approximation for small cuts. Indeed we want to cut out an arc 1557 // good approximation for small cuts. Indeed we want to cut out an arc
1481 // and we approximate this arc by a polygon chain 1558 // and we approximate this arc by a polygon chain
@@ -1529,7 +1606,7 @@ namespace OpenSim.Region.Physics.Meshing
1529 { 1606 {
1530 holeHull = new SimpleHull(); 1607 holeHull = new SimpleHull();
1531 1608
1532 float hollowFactorF = (float) hollowFactor / 50000.0f; 1609 float hollowFactorF = (float)hollowFactor * 2.0e-5f;
1533 1610
1534 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle) 1611 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
1535 { 1612 {
@@ -1537,23 +1614,29 @@ namespace OpenSim.Region.Physics.Meshing
1537 holeHull.AddVertex(new Vertex(-0.25f * hollowFactorF, -0f * hollowFactorF, 0.0f)); 1614 holeHull.AddVertex(new Vertex(-0.25f * hollowFactorF, -0f * hollowFactorF, 0.0f));
1538 holeHull.AddVertex(new Vertex(+0.125f * hollowFactorF, +0.1875f * hollowFactorF, 0.0f)); 1615 holeHull.AddVertex(new Vertex(+0.125f * hollowFactorF, +0.1875f * hollowFactorF, 0.0f));
1539 } 1616 }
1617 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
1618 {
1619 holeHull.AddVertex(new Vertex(-0.500000f * hollowFactorF, 0.000000f * hollowFactorF, 0.0f)); // 180 degrees
1620 holeHull.AddVertex(new Vertex(-0.250000f * hollowFactorF, 0.433013f * hollowFactorF, 0.0f)); // 120 degrees
1621 holeHull.AddVertex(new Vertex(0.250000f * hollowFactorF, 0.433013f * hollowFactorF, 0.0f)); // 60 degrees
1622 holeHull.AddVertex(new Vertex(0.500000f * hollowFactorF, 0.000000f * hollowFactorF, 0.0f)); // 0 degrees
1623 }
1540 else 1624 else
1541 { 1625 {
1542 holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, -0.45f * hollowFactorF, 0.0f)); 1626 holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, -0.45f * hollowFactorF, 0.0f));
1543 holeHull.AddVertex(new Vertex(-0.5f * hollowFactorF, -0f * hollowFactorF, 0.0f)); 1627 holeHull.AddVertex(new Vertex(-0.5f * hollowFactorF, -0f * hollowFactorF, 0.0f));
1544 holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, +0.45f * hollowFactorF, 0.0f)); 1628 holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, +0.45f * hollowFactorF, 0.0f));
1629 }
1630 }
1631 else if (hollowShape == HollowShape.Square && (primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
1632 {
1633 holeHull = new SimpleHull();
1545 1634
1546 ////holeHull.AddVertex(new Vertex(-0.5f * hollowFactorF, -0f * hollowFactorF, 0.0f)); 1635 float hollowFactorF = (float)hollowFactor * 2.0e-5f;
1547
1548 ////holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, +0.45f * hollowFactorF, 0.0f));
1549
1550 ////holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, -0.45f * hollowFactorF, 0.0f));
1551 1636
1552 //holeHull.AddVertex(new Vertex(-0.5f * hollowFactorF, +0f * hollowFactorF, 0.0f)); 1637 holeHull.AddVertex(new Vertex(-0.707f * hollowFactorF, 0.0f, 0.0f)); // 180 degrees
1553 //holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, -0.45f * hollowFactorF, 0.0f)); 1638 holeHull.AddVertex(new Vertex(0.0f, 0.707f * hollowFactorF, 0.0f)); // 120 degrees
1554 //holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, +0.45f * hollowFactorF, 0.0f)); 1639 holeHull.AddVertex(new Vertex(0.707f * hollowFactorF, 0.0f, 0.0f)); // 60 degrees
1555 ////holeHull.AddVertex(new Vertex(-0.5f * hollowFactorF, +0f * hollowFactorF, 0.0f));
1556 }
1557 } 1640 }
1558 else 1641 else
1559 { 1642 {
@@ -1687,6 +1770,16 @@ namespace OpenSim.Region.Physics.Meshing
1687 //System.Console.WriteLine("[MESH]: twistTop = " + twistTop.ToString() + "|" + extr.twistTop.ToString() + ", twistMid = " + twistMid.ToString() + "|" + extr.twistMid.ToString() + ", twistbot = " + twistBot.ToString() + "|" + extr.twistBot.ToString()); 1770 //System.Console.WriteLine("[MESH]: twistTop = " + twistTop.ToString() + "|" + extr.twistTop.ToString() + ", twistMid = " + twistMid.ToString() + "|" + extr.twistMid.ToString() + ", twistbot = " + twistBot.ToString() + "|" + extr.twistBot.ToString());
1688 Mesh result = extr.ExtrudeCircularPath(m); 1771 Mesh result = extr.ExtrudeCircularPath(m);
1689 result.DumpRaw(baseDir, primName, "Z extruded"); 1772 result.DumpRaw(baseDir, primName, "Z extruded");
1773
1774#if SPAM
1775 int vCount = 0;
1776
1777 foreach ( Vertex v in result.vertices )
1778 if ( v != null )
1779 vCount++;
1780 System.Console.WriteLine( "Mesh vertex count: " + vCount.ToString());
1781#endif
1782
1690 return result; 1783 return result;
1691 } 1784 }
1692 1785
@@ -1839,7 +1932,8 @@ namespace OpenSim.Region.Physics.Meshing
1839 { 1932 {
1840 if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2) 1933 if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2)
1841 { 1934 {
1842 mesh = CreateSphereMesh(primName, primShape, size); 1935 //mesh = CreateSphereMesh(primName, primShape, size);
1936 mesh = CreateCircularPathMesh(primName, primShape, size);
1843 CalcNormals(mesh); 1937 CalcNormals(mesh);
1844 } 1938 }
1845 } 1939 }