Skip to content

Commit 3c9d2c6

Browse files
authored
[orx-dnk3] Uncomment two demos (#396)
1 parent 87a0d9f commit 3c9d2c6

2 files changed

Lines changed: 182 additions & 161 deletions

File tree

Lines changed: 81 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,81 @@
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.camera.Orbital
7-
//import org.openrndr.extra.meshgenerators.boxMesh
8-
//import org.openrndr.extra.meshgenerators.groundPlaneMesh
9-
//import org.openrndr.math.Vector3
10-
//import org.openrndr.math.transforms.transform
11-
//
12-
//fun main() = application {
13-
// configure {
14-
// width = 1280
15-
// height = 720
16-
// }
17-
//
18-
// program {
19-
// extend(Orbital()) {
20-
// eye = Vector3(4.0, 4.0, 4.0)
21-
// }
22-
//
23-
// val renderer = dryRenderer()
24-
// val scene = scene {
25-
//
26-
// addSkybox("file:demo-data/cubemaps/garage_iem.dds")
27-
//
28-
// root.hemisphereLight {
29-
// upColor = ColorRGBa.WHITE.shade(0.1)
30-
// downColor = ColorRGBa.BLACK
31-
// }
32-
//
33-
// root.node {
34-
// transform = transform {
35-
// translate(0.0, 2.0, 0.0)
36-
// }
37-
//
38-
// pointLight {
39-
// constantAttenuation = 0.0
40-
// quadraticAttenuation = 1.0
41-
// }
42-
// }
43-
//
44-
// root.node {
45-
// simpleMesh {
46-
// vertexBuffer = groundPlaneMesh(100.0, 100.0)
47-
// material = pbrMaterial {
48-
// color = ColorRGBa.GREEN
49-
// }
50-
// }
51-
// }
52-
//
53-
// for (j in -3..3) {
54-
// for (i in -3..3) {
55-
// root.node {
56-
// transform = transform {
57-
// translate(i * 2.0, 1.0, j * 2.0)
58-
// }
59-
// update {
60-
// transform = transform {
61-
// translate(i * 2.0, 1.0, j * 2.0)
62-
// rotate(Vector3.UNIT_Z, seconds* 45.0 + i * 20.0 + j * 50.0)
63-
// }
64-
// }
65-
// simpleMesh {
66-
// vertexBuffer = boxMesh()
67-
// material = pbrMaterial {
68-
// color = ColorRGBa.WHITE
69-
// }
70-
// }
71-
// }
72-
// }
73-
// }
74-
// }
75-
// extend {
76-
// drawer.clear(ColorRGBa.BLACK)
77-
// renderer.draw(drawer, scene)
78-
// }
79-
// }
80-
//}
1+
import org.openrndr.application
2+
import org.openrndr.color.ColorRGBa
3+
import org.openrndr.extra.camera.Orbital
4+
import org.openrndr.extra.dnk3.dsl.*
5+
import org.openrndr.extra.dnk3.renderers.dryRenderer
6+
import org.openrndr.extra.dnk3.tools.addSkybox
7+
import org.openrndr.extra.meshgenerators.boxMesh
8+
import org.openrndr.extra.meshgenerators.groundPlaneMesh
9+
import org.openrndr.math.Vector3
10+
import org.openrndr.math.transforms.transform
11+
import java.io.File
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").absolutePath)
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+
for (j in -3..3) {
55+
for (i in -3..3) {
56+
root.node {
57+
transform = transform {
58+
translate(i * 2.0, 1.0, j * 2.0)
59+
}
60+
update {
61+
transform = transform {
62+
translate(i * 2.0, 1.0, j * 2.0)
63+
rotate(Vector3.UNIT_Z, seconds * 45.0 + i * 20.0 + j * 50.0)
64+
}
65+
}
66+
simpleMesh {
67+
vertexBuffer = boxMesh()
68+
material = pbrMaterial {
69+
color = ColorRGBa.WHITE
70+
}
71+
}
72+
}
73+
}
74+
}
75+
}
76+
extend {
77+
drawer.clear(ColorRGBa.BLACK)
78+
renderer.draw(drawer, scene)
79+
}
80+
}
81+
}
Lines changed: 101 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,101 @@
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

Comments
 (0)