1- // import org.openrndr.application
2- // import org.openrndr.color.ColorRGBa
3- // import org.openrndr.extra.dnk3.dsl.*
4- // import org.openrndr.extra.dnk3.renderers.dryRenderer
5- // import org.openrndr.extra.dnk3.tools.addSkybox
6- // import org.openrndr.extra.noise.simplex
7- // import org.openrndr.extra.camera.Orbital
8- // import org.openrndr.extra.meshgenerators.groundPlaneMesh
9- // import org.openrndr.math.Vector3
10- // import org.openrndr.math.transforms.transform
11- // import org.openrndr.shape.path3D
12- //
13- // fun main() = application {
14- // configure {
15- // width = 1280
16- // height = 720
17- // }
18- //
19- // program {
20- // extend(Orbital()) {
21- // eye = Vector3(4.0, 4.0, 4.0)
22- // }
23- //
24- // val renderer = dryRenderer()
25- // val scene = scene {
26- //
27- // addSkybox("file:demo-data/cubemaps/garage_iem.dds")
28- //
29- // root.hemisphereLight {
30- // upColor = ColorRGBa.WHITE.shade(0.1)
31- // downColor = ColorRGBa.BLACK
32- // }
33- //
34- // root.node {
35- // transform = transform {
36- // translate(0.0, 2.0, 0.0)
37- // }
38- //
39- // pointLight {
40- // constantAttenuation = 0.0
41- // quadraticAttenuation = 1.0
42- // }
43- // }
44- //
45- // root.node {
46- // simpleMesh {
47- // vertexBuffer = groundPlaneMesh(100.0, 100.0)
48- // material = pbrMaterial {
49- // color = ColorRGBa.GREEN
50- // }
51- // }
52- // }
53- //
54- // root.node {
55- // pathMesh {
56- // weight = 10.0
57- // material = pbrMaterial {
58- // color = ColorRGBa.PINK
59- // }
60- // update {
61- // paths = mutableListOf(
62- // path3D {
63- // val t = seconds * 0.1
64- // moveTo(Vector3.ZERO)
65- // val control = Vector3.simplex(3032, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0
66- // val target = Vector3.simplex(5077, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0
67- // val end = Vector3.simplex(9041, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0
68- // curveTo(control, target)
69- // continueTo(end)
70- // }
71- // )
72- // }
73- // }
74- // }
75- // }
76- // extend {
77- // drawer.clear(ColorRGBa.BLACK)
78- // renderer.draw(drawer, scene)
79- // }
80- // }
81- // }
1+ import org.openrndr.application
2+ import org.openrndr.color.ColorRGBa
3+ import org.openrndr.extra.camera.Orbital
4+ import org.openrndr.extra.color.presets.ORANGE
5+ import org.openrndr.extra.dnk3.dsl.*
6+ import org.openrndr.extra.dnk3.renderers.dryRenderer
7+ import org.openrndr.extra.dnk3.tools.addSkybox
8+ import org.openrndr.extra.meshgenerators.groundPlaneMesh
9+ import org.openrndr.extra.meshgenerators.sphereMesh
10+ import org.openrndr.extra.noise.simplex
11+ import org.openrndr.math.Vector3
12+ import org.openrndr.math.transforms.transform
13+ import org.openrndr.shape.path3D
14+ import java.io.File
15+
16+ fun main () = application {
17+ configure {
18+ width = 1280
19+ height = 720
20+ }
21+
22+ program {
23+ extend(Orbital ()) {
24+ eye = Vector3 (4.0 , 4.0 , 4.0 )
25+ }
26+
27+ val renderer = dryRenderer()
28+ val sphere = sphereMesh(32 , 32 , radius = 1.0 )
29+ val scene = scene {
30+ addSkybox(File (" demo-data/cubemaps/garage_iem.dds" ).absolutePath)
31+
32+ root.hemisphereLight {
33+ upColor = ColorRGBa .WHITE .shade(0.1 )
34+ downColor = ColorRGBa .BLACK
35+ }
36+
37+ root.node {
38+ transform = transform {
39+ translate(0.0 , 10.0 , 0.0 )
40+ }
41+
42+ pointLight {
43+ constantAttenuation = 0.0
44+ quadraticAttenuation = 0.3
45+ }
46+ }
47+
48+ root.node {
49+ simpleMesh {
50+ vertexBuffer = groundPlaneMesh(100.0 , 100.0 )
51+ material = pbrMaterial {
52+ color = ColorRGBa .GREEN
53+ }
54+ }
55+ }
56+
57+ root.node {
58+ val mat = pbrMaterial {
59+ metalness = 0.8
60+ roughness = 0.2
61+ color = ColorRGBa .ORANGE
62+ }
63+ simpleMesh {
64+ vertexBuffer = sphere
65+ material = mat
66+ }
67+ pathMesh {
68+ weight = 50.0
69+ material = mat
70+ update {
71+ paths = mutableListOf (
72+ path3D {
73+ val t = seconds * 0.3
74+
75+ // simplex returns values between -1.0 and 1.0. Make sure the y component
76+ // (the elevation) is between 0.0 and 4.0
77+ val control = Vector3 .simplex(3032 , t).let {
78+ it.copy(y = it.y * 0.5 + 0.5 )
79+ } * 4.0
80+ val target = Vector3 .simplex(5077 , t).let {
81+ it.copy(y = it.y * 0.5 + 0.5 )
82+ } * 4.0
83+ val end = Vector3 .simplex(9041 , t).let {
84+ it.copy(y = it.y * 0.5 + 0.5 )
85+ } * 4.0
86+
87+ moveTo(Vector3 .ZERO )
88+ curveTo(control, target)
89+ continueTo(end)
90+ }
91+ )
92+ }
93+ }
94+ }
95+ }
96+ extend {
97+ drawer.clear(ColorRGBa .BLACK )
98+ renderer.draw(drawer, scene)
99+ }
100+ }
101+ }
0 commit comments