aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
diff options
context:
space:
mode:
authorTeravus Ovares2008-05-29 20:20:50 +0000
committerTeravus Ovares2008-05-29 20:20:50 +0000
commit918f887c0c10fda33633548f3601bdf07d74edfd (patch)
tree2db5459288f52117a071fcc51c7f2d1d7a19a3b3 /OpenSim/Region/Physics/Meshing/Meshmerizer.cs
parentMantis#1416. Thank you very much, Melanie for a patch that: (diff)
downloadopensim-SC_OLD-918f887c0c10fda33633548f3601bdf07d74edfd.zip
opensim-SC_OLD-918f887c0c10fda33633548f3601bdf07d74edfd.tar.gz
opensim-SC_OLD-918f887c0c10fda33633548f3601bdf07d74edfd.tar.bz2
opensim-SC_OLD-918f887c0c10fda33633548f3601bdf07d74edfd.tar.xz
* Applying Dahlia's interim path curve patch. it adds initial support for some tori/ring parameters. Thanks Dahlia!
* Some situations do not match the client's render of the tori, we know and are working on it. This is an initial support patch, so expect it to not be exact. * Some tapers are acting slightly odd. Will fix.
Diffstat (limited to 'OpenSim/Region/Physics/Meshing/Meshmerizer.cs')
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs450
1 files changed, 415 insertions, 35 deletions
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index ba4f941..5ef392c 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -29,6 +29,7 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using OpenSim.Framework; 30using OpenSim.Framework;
31using OpenSim.Region.Physics.Manager; 31using OpenSim.Region.Physics.Manager;
32using libsecondlife;
32 33
33namespace OpenSim.Region.Physics.Meshing 34namespace OpenSim.Region.Physics.Meshing
34{ 35{
@@ -253,7 +254,8 @@ namespace OpenSim.Region.Physics.Meshing
253 holeHull.AddVertex(IPP); 254 holeHull.AddVertex(IPP);
254 holeHull.AddVertex(IPM); 255 holeHull.AddVertex(IPM);
255 } 256 }
256 if (hshape == HollowShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight) 257 //if (hshape == HollowShape.Circle && pbs.PathCurve == (byte)Extrusion.Straight)
258 if ( hshape == HollowShape.Circle )
257 { 259 {
258 float hollowFactorF = (float)fhollowFactor / (float)50000; 260 float hollowFactorF = (float)fhollowFactor / (float)50000;
259 261
@@ -576,7 +578,6 @@ namespace OpenSim.Region.Physics.Meshing
576 } 578 }
577 } 579 }
578 580
579
580 if (pathShearX != 0) 581 if (pathShearX != 0)
581 { 582 {
582 if (pathShearX > 50) 583 if (pathShearX > 50)
@@ -647,7 +648,7 @@ namespace OpenSim.Region.Physics.Meshing
647 return result; 648 return result;
648 } 649 }
649 650
650 private static Mesh CreateCyllinderMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size) 651 private static Mesh CreateCylinderMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size)
651 // Builds the z (+ and -) surfaces of a box shaped prim 652 // Builds the z (+ and -) surfaces of a box shaped prim
652 { 653 {
653 654
@@ -1318,6 +1319,317 @@ namespace OpenSim.Region.Physics.Meshing
1318 return sm; 1319 return sm;
1319 1320
1320 } 1321 }
1322
1323 private static Mesh CreateCircularProfileMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size)
1324 {
1325
1326 UInt16 hollowFactor = primShape.ProfileHollow;
1327 UInt16 profileBegin = primShape.ProfileBegin;
1328 UInt16 profileEnd = primShape.ProfileEnd;
1329 UInt16 taperX = primShape.PathScaleX;
1330 UInt16 taperY = primShape.PathScaleY;
1331 UInt16 pathShearX = primShape.PathShearX;
1332 UInt16 pathShearY = primShape.PathShearY;
1333 Int16 twistBot = primShape.PathTwist;
1334 Int16 twistTop = primShape.PathTwistBegin;
1335 HollowShape hollowShape = primShape.HollowShape;
1336
1337 //Console.WriteLine("pathTwist: " + primShape.PathTwist.ToString() + " pathTwistBegin: " + primShape.PathTwistBegin.ToString());
1338
1339 SimpleHull outerHull = new SimpleHull();
1340
1341 //Console.WriteLine("primShape.ProfileCurve & 0x07: " + Convert.ToString(primShape.ProfileCurve & 0x07));
1342
1343 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
1344
1345 //if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle
1346 // || (primShape.ProfileCurve & 0x07) == (byte) ProfileShape.Square)
1347 {
1348 //Console.WriteLine("Meshmerizer thinks " + primName + " is a TORUS");
1349 if ( hollowShape == HollowShape.Same )
1350 hollowShape = HollowShape.Circle;
1351
1352 // build the profile shape
1353 // counter-clockwise around the quadrants, start at 45 degrees
1354
1355 outerHull.AddVertex(new Vertex(0.353553f, 0.353553f, 0.0f)); // 45 degrees
1356 outerHull.AddVertex(new Vertex(0.250000f, 0.433013f, 0.0f)); // 60 degrees
1357 outerHull.AddVertex(new Vertex(0.129410f, 0.482963f, 0.0f)); // 75 degrees
1358 outerHull.AddVertex(new Vertex(0.000000f, 0.500000f, 0.0f)); // 90 degrees
1359 outerHull.AddVertex(new Vertex(-0.129410f, 0.482963f, 0.0f)); // 105 degrees
1360 outerHull.AddVertex(new Vertex(-0.250000f, 0.433013f, 0.0f)); // 120 degrees
1361 outerHull.AddVertex(new Vertex(-0.353553f, 0.353553f, 0.0f)); // 135 degrees
1362 outerHull.AddVertex(new Vertex(-0.433013f, 0.250000f, 0.0f)); // 150 degrees
1363 outerHull.AddVertex(new Vertex(-0.482963f, 0.129410f, 0.0f)); // 165 degrees
1364 outerHull.AddVertex(new Vertex(-0.500000f, 0.000000f, 0.0f)); // 180 degrees
1365 outerHull.AddVertex(new Vertex(-0.482963f, -0.129410f, 0.0f)); // 195 degrees
1366 outerHull.AddVertex(new Vertex(-0.433013f, -0.250000f, 0.0f)); // 210 degrees
1367 outerHull.AddVertex(new Vertex(-0.353553f, -0.353553f, 0.0f)); // 225 degrees
1368 outerHull.AddVertex(new Vertex(-0.250000f, -0.433013f, 0.0f)); // 240 degrees
1369 outerHull.AddVertex(new Vertex(-0.129410f, -0.482963f, 0.0f)); // 255 degrees
1370 outerHull.AddVertex(new Vertex(0.000000f, -0.500000f, 0.0f)); // 270 degrees
1371 outerHull.AddVertex(new Vertex(0.129410f, -0.482963f, 0.0f)); // 285 degrees
1372 outerHull.AddVertex(new Vertex(0.250000f, -0.433013f, 0.0f)); // 300 degrees
1373 outerHull.AddVertex(new Vertex(0.353553f, -0.353553f, 0.0f)); // 315 degrees
1374 outerHull.AddVertex(new Vertex(0.433013f, -0.250000f, 0.0f)); // 330 degrees
1375 outerHull.AddVertex(new Vertex(0.482963f, -0.129410f, 0.0f)); // 345 degrees
1376 outerHull.AddVertex(new Vertex(0.500000f, 0.000000f, 0.0f)); // 0 degrees
1377 outerHull.AddVertex(new Vertex(0.482963f, 0.129410f, 0.0f)); // 15 degrees
1378 outerHull.AddVertex(new Vertex(0.433013f, 0.250000f, 0.0f)); // 30 degrees
1379 }
1380
1381 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Square) // a ring
1382 {
1383 //Console.WriteLine("Meshmerizer thinks " + primName + " is a TUBE");
1384 if ( hollowShape == HollowShape.Same )
1385 hollowShape = HollowShape.Square;
1386
1387 outerHull.AddVertex(new Vertex(+0.5f, +0.5f, 0.0f));
1388 outerHull.AddVertex(new Vertex(-0.5f, +0.5f, 0.0f));
1389 outerHull.AddVertex(new Vertex(-0.5f, -0.5f, 0.0f));
1390 outerHull.AddVertex(new Vertex(+0.5f, -0.5f, 0.0f));
1391 }
1392
1393 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
1394 {
1395 //Console.WriteLine("Meshmerizer thinks " + primName + " is a RING");
1396 if ( hollowShape == HollowShape.Same )
1397 hollowShape = HollowShape.Triangle;
1398
1399 outerHull.AddVertex(new Vertex(+0.255f, -0.375f, 0.0f));
1400 outerHull.AddVertex(new Vertex(+0.25f, +0.375f, 0.0f));
1401 outerHull.AddVertex(new Vertex(-0.5f, +0.0f, 0.0f));
1402
1403 }
1404
1405 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
1406 {
1407 //Console.WriteLine("Meshmerizer thinks " + primName + " is a SPHERE");
1408 if (hollowShape == HollowShape.Same)
1409 hollowShape = HollowShape.Circle;
1410
1411 // not implemented here, use old routine
1412 return CreateSphereMesh(primName, primShape, size);
1413 }
1414
1415 // Deal with cuts now
1416 if ((profileBegin != 0) || (profileEnd != 0))
1417 {
1418 double fProfileBeginAngle = profileBegin / 50000.0 * 360.0;
1419 // In degree, for easier debugging and understanding
1420 //fProfileBeginAngle -= (90.0 + 45.0); // for some reasons, the SL client counts from the corner -X/-Y
1421 double fProfileEndAngle = 360.0 - profileEnd / 50000.0 * 360.0; // Pathend comes as complement to 1.0
1422 //fProfileEndAngle -= (90.0 + 45.0);
1423 if (fProfileBeginAngle < fProfileEndAngle)
1424 fProfileEndAngle -= 360.0;
1425
1426 // Note, that we don't want to cut out a triangle, even if this is a
1427 // good approximation for small cuts. Indeed we want to cut out an arc
1428 // and we approximate this arc by a polygon chain
1429 // Also note, that these vectors are of length 1.0 and thus their endpoints lay outside the model space
1430 // So it can easily be subtracted from the outer hull
1431 int iSteps = (int)(((fProfileBeginAngle - fProfileEndAngle) / 45.0) + .5);
1432 // how many steps do we need with approximately 45 degree
1433 double dStepWidth = (fProfileBeginAngle - fProfileEndAngle) / iSteps;
1434
1435 Vertex origin = new Vertex(0.0f, 0.0f, 0.0f);
1436
1437 // Note the sequence of vertices here. It's important to have the other rotational sense than in outerHull
1438 SimpleHull cutHull = new SimpleHull();
1439 cutHull.AddVertex(origin);
1440 for (int i = 0; i < iSteps; i++)
1441 {
1442 double angle = fProfileBeginAngle - i * dStepWidth; // we count against the angle orientation!!!!
1443 Vertex v = Vertex.FromAngle(angle * Math.PI / 180.0);
1444 cutHull.AddVertex(v);
1445 }
1446 Vertex legEnd = Vertex.FromAngle(fProfileEndAngle * Math.PI / 180.0);
1447 // Calculated separately to avoid errors
1448 cutHull.AddVertex(legEnd);
1449
1450 // m_log.DebugFormat("Starting cutting of the hollow shape from the prim {1}", 0, primName);
1451 SimpleHull cuttedHull = SimpleHull.SubtractHull(outerHull, cutHull);
1452
1453 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
1454 {
1455 Quaternion zFlip = new Quaternion(new Vertex(0.0f, 0.0f, 1.0f), (float)Math.PI);
1456 Vertex vTmp = new Vertex(0.0f, 0.0f, 0.0f);
1457 foreach (Vertex v in cuttedHull.getVertices())
1458 if (v != null)
1459 {
1460 vTmp = v * zFlip;
1461 v.X = vTmp.X;
1462 v.Y = vTmp.Y;
1463 v.Z = vTmp.Z;
1464 }
1465 }
1466
1467 outerHull = cuttedHull;
1468 }
1469
1470 // Deal with the hole here
1471 if (hollowFactor > 0)
1472 {
1473 SimpleHull holeHull;
1474
1475 if (hollowShape == HollowShape.Triangle)
1476 {
1477 holeHull = new SimpleHull();
1478
1479 float hollowFactorF = (float) hollowFactor / 50000.0f;
1480
1481 if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
1482 {
1483 holeHull.AddVertex(new Vertex(+0.125f * hollowFactorF, -0.1875f * hollowFactorF, 0.0f));
1484 holeHull.AddVertex(new Vertex(-0.25f * hollowFactorF, -0f * hollowFactorF, 0.0f));
1485 holeHull.AddVertex(new Vertex(+0.125f * hollowFactorF, +0.1875f * hollowFactorF, 0.0f));
1486 }
1487 else
1488 {
1489 holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, -0.45f * hollowFactorF, 0.0f));
1490 holeHull.AddVertex(new Vertex(-0.5f * hollowFactorF, -0f * hollowFactorF, 0.0f));
1491 holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, +0.45f * hollowFactorF, 0.0f));
1492
1493 ////holeHull.AddVertex(new Vertex(-0.5f * hollowFactorF, -0f * hollowFactorF, 0.0f));
1494
1495 ////holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, +0.45f * hollowFactorF, 0.0f));
1496
1497 ////holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, -0.45f * hollowFactorF, 0.0f));
1498
1499 //holeHull.AddVertex(new Vertex(-0.5f * hollowFactorF, +0f * hollowFactorF, 0.0f));
1500 //holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, -0.45f * hollowFactorF, 0.0f));
1501 //holeHull.AddVertex(new Vertex(+0.25f * hollowFactorF, +0.45f * hollowFactorF, 0.0f));
1502 ////holeHull.AddVertex(new Vertex(-0.5f * hollowFactorF, +0f * hollowFactorF, 0.0f));
1503 }
1504 }
1505 else
1506 {
1507 holeHull = BuildHoleHull(primShape, primShape.ProfileShape, primShape.HollowShape, hollowFactor);
1508 }
1509
1510 if (holeHull != null)
1511 {
1512 SimpleHull hollowedHull = SimpleHull.SubtractHull(outerHull, holeHull);
1513
1514 outerHull = hollowedHull;
1515 }
1516 }
1517
1518 Mesh m = new Mesh();
1519
1520 Vertex Seed1 = new Vertex(0.0f, -10.0f, 0.0f);
1521 Vertex Seed2 = new Vertex(-10.0f, 10.0f, 0.0f);
1522 Vertex Seed3 = new Vertex(10.0f, 10.0f, 0.0f);
1523
1524 m.Add(Seed1);
1525 m.Add(Seed2);
1526 m.Add(Seed3);
1527
1528 m.Add(new Triangle(Seed1, Seed2, Seed3));
1529 m.Add(outerHull.getVertices());
1530
1531 InsertVertices(m.vertices, 3, m.triangles);
1532 m.DumpRaw(baseDir, primName, "Proto first Mesh");
1533
1534 m.Remove(Seed1);
1535 m.Remove(Seed2);
1536 m.Remove(Seed3);
1537 m.DumpRaw(baseDir, primName, "Proto seeds removed");
1538
1539 m.RemoveTrianglesOutside(outerHull);
1540 m.DumpRaw(baseDir, primName, "Proto outsides removed");
1541
1542 foreach (Triangle t in m.triangles)
1543 t.invertNormal();
1544
1545 Vertex vTemp = new Vertex(0.0f, 0.0f, 0.0f);
1546
1547 //Console.WriteLine("primShape.PathScaleX: " + primShape.PathScaleX.ToString() + " primShape.PathScaleY: " + primShape.PathScaleY.ToString());
1548 //Console.WriteLine("primShape.PathSkew: " + primShape.PathSkew.ToString() + " primShape.PathRadiusOffset: " + primShape.PathRadiusOffset.ToString() + " primShape.pathRevolutions: " + primShape.PathRevolutions.ToString());
1549
1550 float skew = primShape.PathSkew * 0.01f;
1551 float pathScaleX = (float)(200 - primShape.PathScaleX) * 0.01f;
1552 float pathScaleY = (float)(200 - primShape.PathScaleY) * 0.01f;
1553 //Console.WriteLine("PathScaleX: " + pathScaleX.ToString() + " pathScaleY: " + pathScaleY.ToString());
1554
1555 float profileXComp = pathScaleX * (1.0f - Math.Abs(skew));
1556 foreach (Vertex v in m.vertices)
1557 if (v != null)
1558 {
1559 v.X *= profileXComp;
1560 v.Y *= pathScaleY;
1561 //v.Y *= 0.5f; // torus profile is scaled in y axis
1562 }
1563
1564 Extruder extr = new Extruder();
1565
1566 extr.size = size;
1567 extr.pathScaleX = pathScaleX;
1568 extr.pathScaleY = pathScaleY;
1569 extr.pathCutBegin = 0.00002f * primShape.PathBegin;
1570 extr.pathCutEnd = 0.00002f * (50000 - primShape.PathEnd);
1571 extr.pathBegin = primShape.PathBegin;
1572 extr.pathEnd = primShape.PathEnd;
1573 extr.skew = skew;
1574 extr.revolutions = 1.0f + (float)primShape.PathRevolutions * 3.0f / 200.0f;
1575
1576 //System.Console.WriteLine("primShape.PathBegin: " + primShape.PathBegin.ToString() + " primShape.PathEnd: " + primShape.PathEnd.ToString());
1577 //System.Console.WriteLine("extr.pathCutBegin: " + extr.pathCutBegin.ToString() + " extr.pathCutEnd: " + extr.pathCutEnd.ToString());
1578 //System.Console.WriteLine("extr.revolutions: " + extr.revolutions.ToString());
1579
1580 //System.Console.WriteLine("primShape.PathTaperX: " + primShape.PathTaperX.ToString());
1581 //System.Console.WriteLine("primShape.PathTaperY: " + primShape.PathTaperY.ToString());
1582
1583 extr.pathTaperX = 0.01f * (float)primShape.PathTaperX;
1584 extr.pathTaperY = 0.01f * (float)primShape.PathTaperY;
1585
1586 extr.radius = 0.01f * (float)primShape.PathRadiusOffset;
1587 //System.Console.WriteLine("primShape.PathRadiusOffset: " + primShape.PathRadiusOffset.ToString());
1588
1589
1590
1591
1592
1593 if (pathShearX != 0)
1594 {
1595 if (pathShearX > 50)
1596 {
1597 // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50
1598 extr.pushX = (((float)(256 - pathShearX) / 100) * -1f);
1599 //m_log.Warn("pushX: " + extr.pushX);
1600 }
1601 else
1602 {
1603 extr.pushX = (float)pathShearX / 100;
1604 //m_log.Warn("pushX: " + extr.pushX);
1605 }
1606 }
1607
1608 if (pathShearY != 0)
1609 {
1610 if (pathShearY > 50)
1611 {
1612 // Complimentary byte. Negative values wrap around the byte. Positive values go up to 50
1613 extr.pushY = (((float)(256 - pathShearY) / 100) * -1f);
1614 //m_log.Warn("pushY: " + extr.pushY);
1615 }
1616 else
1617 {
1618 extr.pushY = (float)pathShearY / 100;
1619 //m_log.Warn("pushY: " + extr.pushY);
1620 }
1621
1622 }
1623
1624 extr.twistTop = (float)primShape.PathTwist * (float)Math.PI * 0.02f;
1625 extr.twistBot = (float)primShape.PathTwistBegin * (float)Math.PI * 0.02f;
1626
1627 //System.Console.WriteLine("[MESH]: twistTop = " + twistTop.ToString() + "|" + extr.twistTop.ToString() + ", twistMid = " + twistMid.ToString() + "|" + extr.twistMid.ToString() + ", twistbot = " + twistBot.ToString() + "|" + extr.twistBot.ToString());
1628 Mesh result = extr.ExtrudeCircularPath(m);
1629 result.DumpRaw(baseDir, primName, "Z extruded");
1630 return result;
1631 }
1632
1321 public static void CalcNormals(Mesh mesh) 1633 public static void CalcNormals(Mesh mesh)
1322 { 1634 {
1323 int iTriangles = mesh.triangles.Count; 1635 int iTriangles = mesh.triangles.Count;
@@ -1432,43 +1744,111 @@ namespace OpenSim.Region.Physics.Meshing
1432 mesh = (Mesh)smesh; 1744 mesh = (Mesh)smesh;
1433 CalcNormals(mesh); 1745 CalcNormals(mesh);
1434 } 1746 }
1435 else 1747 else if ((primShape.ProfileCurve & (byte)ProfileShape.Square) == (byte)ProfileShape.Square)
1748 {
1749 if (primShape.PathCurve == (byte)LLObject.PathCurve.Line)
1750 { // its a box
1751 mesh = CreateBoxMesh(primName, primShape, size);
1752 CalcNormals(mesh);
1753 }
1754 else if (primShape.PathCurve == (byte)LLObject.PathCurve.Circle)
1755 { // tube
1756 // do a cylinder for now
1757 //mesh = CreateCylinderMesh(primName, primShape, size);
1758 mesh = CreateCircularProfileMesh(primName, primShape, size);
1759 CalcNormals(mesh);
1760 }
1761 }
1762 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.Circle)
1436 { 1763 {
1437 switch (primShape.ProfileShape) 1764 if (primShape.PathCurve == (byte)Extrusion.Straight)
1438 { 1765 {
1439 case ProfileShape.Square: 1766 mesh = CreateCylinderMesh(primName, primShape, size);
1440 mesh = CreateBoxMesh(primName, primShape, size); 1767 CalcNormals(mesh);
1441 CalcNormals(mesh); 1768 }
1442 break;
1443 case ProfileShape.Circle:
1444 if (primShape.PathCurve == (byte)Extrusion.Straight)
1445 {
1446 mesh = CreateCyllinderMesh(primName, primShape, size);
1447 CalcNormals(mesh);
1448 }
1449 break;
1450 case ProfileShape.HalfCircle:
1451 if (primShape.PathCurve == (byte)Extrusion.Curve1)
1452 {
1453 mesh = CreateSphereMesh(primName, primShape, size);
1454 CalcNormals(mesh);
1455 }
1456 break;
1457
1458 case ProfileShape.EquilateralTriangle:
1459 mesh = CreatePrismMesh(primName, primShape, size);
1460 CalcNormals(mesh);
1461 break;
1462 1769
1463 default: 1770 // look at LLObject.cs in libsecondlife for how to know the prim type
1464 mesh = CreateBoxMesh(primName, primShape, size); 1771 // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
1465 CalcNormals(mesh); 1772 else if (primShape.PathCurve == (byte) Extrusion.Curve1 && LLObject.UnpackPathScale(primShape.PathScaleY) <= 0.75f)
1466 //Set default mesh to cube otherwise it'll return 1773 { // dahlia's favorite, a torus :)
1467 // null and crash on the 'setMesh' method in the physics plugins. 1774 mesh = CreateCircularProfileMesh(primName, primShape, size);
1468 //mesh = null; 1775 CalcNormals(mesh);
1469 break;
1470 } 1776 }
1471 } 1777 }
1778 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.HalfCircle)
1779 {
1780 if (primShape.PathCurve == (byte)Extrusion.Curve1 || primShape.PathCurve == (byte) Extrusion.Curve2)
1781 {
1782 mesh = CreateSphereMesh(primName, primShape, size);
1783 CalcNormals(mesh);
1784 }
1785 }
1786 else if ((primShape.ProfileCurve & 0x07) == (byte)ProfileShape.EquilateralTriangle)
1787 {
1788 if (primShape.PathCurve == (byte)Extrusion.Straight)
1789 {
1790 mesh = CreatePrismMesh(primName, primShape, size);
1791 CalcNormals(mesh);
1792 }
1793 else if (primShape.PathCurve == (byte) Extrusion.Curve1)
1794 { // a ring - do a cylinder for now
1795 //mesh = CreateCylinderMesh(primName, primShape, size);
1796 mesh = CreateCircularProfileMesh(primName, primShape, size);
1797 CalcNormals(mesh);
1798 }
1799 }
1800 else // just do a box
1801 {
1802 mesh = CreateBoxMesh(primName, primShape, size);
1803 CalcNormals(mesh);
1804 }
1805
1806 //else
1807 //{
1808 // switch (primShape.ProfileShape)
1809 // {
1810 // case ProfileShape.Square:
1811 // mesh = CreateBoxMesh(primName, primShape, size);
1812 // CalcNormals(mesh);
1813 // break;
1814 // case ProfileShape.Circle:
1815 // if (primShape.PathCurve == (byte)Extrusion.Straight)
1816 // {
1817 // mesh = CreateCylinderMesh(primName, primShape, size);
1818 // CalcNormals(mesh);
1819 // }
1820
1821 // // look at LLObject.cs in libsecondlife for how to know the prim type
1822 // // ProfileCurve seems to combine hole shape and profile curve so we need to only compare against the lower 3 bits
1823 // else if ((primShape.ProfileCurve & 0x07) == (byte)LLObject.ProfileCurve.Circle && LLObject.UnpackPathScale(primShape.PathScaleY) <= 0.75f)
1824 // { // dahlia's favorite, a torus :)
1825 // mesh = CreateCylinderMesh(primName, primShape, size);
1826 // CalcNormals(mesh);
1827 // }
1828
1829 // break;
1830 // case ProfileShape.HalfCircle:
1831 // if (primShape.PathCurve == (byte)Extrusion.Curve1)
1832 // {
1833 // mesh = CreateSphereMesh(primName, primShape, size);
1834 // CalcNormals(mesh);
1835 // }
1836 // break;
1837
1838 // case ProfileShape.EquilateralTriangle:
1839 // mesh = CreatePrismMesh(primName, primShape, size);
1840 // CalcNormals(mesh);
1841 // break;
1842
1843 // default:
1844 // mesh = CreateBoxMesh(primName, primShape, size);
1845 // CalcNormals(mesh);
1846 // //Set default mesh to cube otherwise it'll return
1847 // // null and crash on the 'setMesh' method in the physics plugins.
1848 // //mesh = null;
1849 // break;
1850 // }
1851 //}
1472 1852
1473 return mesh; 1853 return mesh;
1474 } 1854 }