forked from openrndr/orx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DemoObjSaver02.kt
35 lines (32 loc) · 1.05 KB
/
DemoObjSaver02.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import org.openrndr.application
import org.openrndr.draw.loadFont
import org.openrndr.extra.meshgenerators.buildTriangleMesh
import org.openrndr.extra.meshgenerators.sphere
import org.openrndr.extra.objloader.saveOBJ
fun main() = application {
configure {
height = 100
}
program {
val path = "demo-data/obj-models/"
val mesh = buildTriangleMesh {
repeat(4) { x ->
repeat(4) { y ->
repeat(4) { z ->
isolated {
translate(x * 1.0, y * 1.0, z * 1.0)
sphere(8, 8,
(x * 91 + y * 79 + z * 17).mod(5) * 0.2 + 0.1)
}
}
}
}
}
mesh.saveOBJ("$path/sphere-composition-exported.obj")
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 24.0)
extend {
drawer.fontMap = font
drawer.text("Mesh generated and .obj file saved", 10.0, 80.0)
}
}
}