mirror of
https://github.com/jhasse/poly2tri.git
synced 2024-11-05 22:09:52 +01:00
updates
This commit is contained in:
parent
8428c47904
commit
d48d3f4fc0
@ -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)
|
||||||
|
@ -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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ class CDT(val points: List[Point], val segments: List[Segment], iTriangle: Trian
|
|||||||
private def pointEvent(point: Point): Triangle = {
|
private def pointEvent(point: Point): Triangle = {
|
||||||
|
|
||||||
val node = aFront.locate(point)
|
val node = aFront.locate(point)
|
||||||
/*
|
/*
|
||||||
// Projected point coincides with existing point; create two triangles
|
// Projected point coincides with existing point; create two triangles
|
||||||
if(point.x == node.point.x && node.prev != null) {
|
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
|
newNode.triangle
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
*/
|
*/
|
||||||
// Projected point hits advancing front; create new triangle
|
// Projected point hits advancing front; create new triangle
|
||||||
val cwPoint = node.next.point
|
val cwPoint = node.next.point
|
||||||
val ccwPoint = node.point
|
val ccwPoint = node.point
|
||||||
|
Loading…
Reference in New Issue
Block a user