This commit is contained in:
zzzzrrr 2009-08-09 10:29:29 -04:00
parent 8428c47904
commit d48d3f4fc0
2 changed files with 12 additions and 5 deletions

View File

@ -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)

View File

@ -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