From d48d3f4fc0ca560eba1645d334754868c5c44209 Mon Sep 17 00:00:00 2001 From: zzzzrrr Date: Sun, 9 Aug 2009 10:29:29 -0400 Subject: [PATCH] updates --- src/org/poly2tri/Poly2Tri.scala | 8 +++++++- src/org/poly2tri/cdt/CDT.scala | 9 +++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/org/poly2tri/Poly2Tri.scala b/src/org/poly2tri/Poly2Tri.scala index cdfea10..f8244a8 100644 --- a/src/org/poly2tri/Poly2Tri.scala +++ b/src/org/poly2tri/Poly2Tri.scala @@ -76,7 +76,7 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") { var hiLighter = 0 var drawEarClip = false var drawCDT = true - var drawcdtMesh = true + var drawcdtMesh = false val nazcaMonkey = "data/nazca_monkey.dat" val bird = "data/bird.dat" @@ -273,16 +273,22 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") { def selectModel(model: String) { model match { case "data/nazca_monkey.dat" => + CDT.clearPoint = 50 loadModel(nazcaMonkey, 4.5f, Point(400, 300), 1500) case "data/bird.dat" => + CDT.clearPoint = 80 loadModel(bird, 25f, Point(400, 300), 350) case "data/i.snake" => + CDT.clearPoint = 6 loadModel(snake, 10f, Point(600, 300), 10) case "data/star.dat" => + CDT.clearPoint = 6 loadModel(star, -1f, Point(0f, 0f), 10) case "data/strange.dat" => + CDT.clearPoint = 13 loadModel(strange, -1f, Point(0f, 0f), 15) case "data/i.18" => + CDT.clearPoint = 7 loadModel(i18, 20f, Point(600f, 500f), 20) case _ => assert(false) diff --git a/src/org/poly2tri/cdt/CDT.scala b/src/org/poly2tri/cdt/CDT.scala index b2735ec..c0d7c7d 100644 --- a/src/org/poly2tri/cdt/CDT.scala +++ b/src/org/poly2tri/cdt/CDT.scala @@ -46,6 +46,8 @@ object CDT { val ALPHA = 0.3f val SHEER = 0.00001f + var clearPoint = 0 + // Triangulate simple polygon def init(points: ArrayBuffer[Point]): CDT = { @@ -135,8 +137,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian var triangle = pointEvent(point) // Process edge events point.edges.foreach(e => triangle = edgeEvent(e, triangle)) - if(i == 7) {cleanTri = triangle; mesh.debug += cleanTri} - // strange = 13; star & i18 = 7 + if(i == CDT.clearPoint) {cleanTri = triangle; mesh.debug += cleanTri} } } @@ -152,7 +153,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian private def pointEvent(point: Point): Triangle = { val node = aFront.locate(point) - /* + /* // Projected point coincides with existing point; create two triangles if(point.x == node.point.x && node.prev != null) { @@ -185,7 +186,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian newNode.triangle } else { - */ + */ // Projected point hits advancing front; create new triangle val cwPoint = node.next.point val ccwPoint = node.point