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 hiLighter = 0
var drawEarClip = false var drawEarClip = false
var drawCDT = true var drawCDT = true
var drawcdtMesh = true var drawcdtMesh = false
val nazcaMonkey = "data/nazca_monkey.dat" val nazcaMonkey = "data/nazca_monkey.dat"
val bird = "data/bird.dat" val bird = "data/bird.dat"
@ -273,16 +273,22 @@ class Poly2TriDemo extends BasicGame("Poly2Tri") {
def selectModel(model: String) { def selectModel(model: String) {
model match { model match {
case "data/nazca_monkey.dat" => case "data/nazca_monkey.dat" =>
CDT.clearPoint = 50
loadModel(nazcaMonkey, 4.5f, Point(400, 300), 1500) loadModel(nazcaMonkey, 4.5f, Point(400, 300), 1500)
case "data/bird.dat" => case "data/bird.dat" =>
CDT.clearPoint = 80
loadModel(bird, 25f, Point(400, 300), 350) loadModel(bird, 25f, Point(400, 300), 350)
case "data/i.snake" => case "data/i.snake" =>
CDT.clearPoint = 6
loadModel(snake, 10f, Point(600, 300), 10) loadModel(snake, 10f, Point(600, 300), 10)
case "data/star.dat" => case "data/star.dat" =>
CDT.clearPoint = 6
loadModel(star, -1f, Point(0f, 0f), 10) loadModel(star, -1f, Point(0f, 0f), 10)
case "data/strange.dat" => case "data/strange.dat" =>
CDT.clearPoint = 13
loadModel(strange, -1f, Point(0f, 0f), 15) loadModel(strange, -1f, Point(0f, 0f), 15)
case "data/i.18" => case "data/i.18" =>
CDT.clearPoint = 7
loadModel(i18, 20f, Point(600f, 500f), 20) loadModel(i18, 20f, Point(600f, 500f), 20)
case _ => case _ =>
assert(false) assert(false)

View File

@ -46,6 +46,8 @@ object CDT {
val ALPHA = 0.3f val ALPHA = 0.3f
val SHEER = 0.00001f val SHEER = 0.00001f
var clearPoint = 0
// Triangulate simple polygon // Triangulate simple polygon
def init(points: ArrayBuffer[Point]): CDT = { 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) var triangle = pointEvent(point)
// Process edge events // Process edge events
point.edges.foreach(e => triangle = edgeEvent(e, triangle)) point.edges.foreach(e => triangle = edgeEvent(e, triangle))
if(i == 7) {cleanTri = triangle; mesh.debug += cleanTri} if(i == CDT.clearPoint) {cleanTri = triangle; mesh.debug += cleanTri}
// strange = 13; star & i18 = 7
} }
} }