-
-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd09354
commit f117021
Showing
10 changed files
with
114 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...la/indigoextras/mesh/datatypes/Edge.scala → ...c/main/scala/indigoextras/mesh/Edge.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package indigoextras.mesh.datatypes | ||
package indigoextras.mesh | ||
|
||
import indigo.shared.collections.Batch | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ala/indigoextras/mesh/datatypes/Tri.scala → ...rc/main/scala/indigoextras/mesh/Tri.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package indigoextras.mesh.datatypes | ||
package indigoextras.mesh | ||
|
||
import indigo.shared.collections.Batch | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...ndigoextras/mesh/datatypes/Triangle.scala → ...in/scala/indigoextras/mesh/Triangle.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
indigo/indigo-extras/src/test/scala/indigoextras/mesh/BowyerWatsonTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
indigo/sandbox/src/main/scala/com/example/sandbox/scenes/MeshScene.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.example.sandbox.scenes | ||
|
||
import com.example.sandbox.SandboxGameModel | ||
import com.example.sandbox.SandboxStartupData | ||
import com.example.sandbox.SandboxViewModel | ||
import indigo.* | ||
import indigo.scenes.* | ||
import indigoextras.mesh.* | ||
|
||
object MeshScene extends Scene[SandboxStartupData, SandboxGameModel, SandboxViewModel]: | ||
|
||
type SceneModel = SandboxGameModel | ||
type SceneViewModel = SandboxViewModel | ||
|
||
def eventFilters: EventFilters = | ||
EventFilters.Restricted | ||
|
||
def modelLens: Lens[SandboxGameModel, SandboxGameModel] = | ||
Lens.keepOriginal | ||
|
||
def viewModelLens: Lens[SandboxViewModel, SandboxViewModel] = | ||
Lens.keepOriginal | ||
|
||
def name: SceneName = | ||
SceneName("mesh scene") | ||
|
||
def subSystems: Set[SubSystem[SandboxGameModel]] = | ||
Set() | ||
|
||
def updateModel( | ||
context: SceneContext[SandboxStartupData], | ||
model: SandboxGameModel | ||
): GlobalEvent => Outcome[SandboxGameModel] = | ||
_ => Outcome(model) | ||
|
||
def updateViewModel( | ||
context: SceneContext[SandboxStartupData], | ||
model: SandboxGameModel, | ||
viewModel: SandboxViewModel | ||
): GlobalEvent => Outcome[SandboxViewModel] = | ||
_ => Outcome(viewModel) | ||
|
||
def present( | ||
context: SceneContext[SandboxStartupData], | ||
model: SandboxGameModel, | ||
viewModel: SandboxViewModel | ||
): Outcome[SceneUpdateFragment] = | ||
|
||
Outcome( | ||
SceneUpdateFragment( | ||
drawMesh( | ||
model.meshData.points, | ||
model.meshData.superTriangle, | ||
model.meshData.mesh.toLineSegments | ||
) | ||
) | ||
) | ||
|
||
def drawMesh( | ||
points: Batch[Point], | ||
superTriangle: Triangle, | ||
lines: Batch[LineSegment] | ||
): Batch[SceneNode] = | ||
val pts: Batch[Shape.Circle] = | ||
points.map { pt => | ||
Shape.Circle( | ||
pt, | ||
5, | ||
Fill.Color(RGBA.Green) | ||
) | ||
} | ||
|
||
val st = superTriangle.toLineSegments.map { ls => | ||
Shape.Line(ls.start.toPoint, ls.end.toPoint, Stroke(1, RGBA.Magenta)) | ||
} | ||
|
||
val ml = lines.map { ls => | ||
Shape.Line(ls.start.toPoint, ls.end.toPoint, Stroke(1, RGBA.Cyan)) | ||
} | ||
|
||
pts ++ st ++ ml |