[orx-jvm] Move panel, gui, dnk3, keyframer, triangulation to orx-jvm
This commit is contained in:
59
orx-jvm/orx-dnk3/src/demo/kotlin/DemoAnimations01.kt
Normal file
59
orx-jvm/orx-dnk3/src/demo/kotlin/DemoAnimations01.kt
Normal file
@@ -0,0 +1,59 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.mod_
|
||||
import org.openrndr.math.transforms.transform
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
//multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/box-animated/BoxAnimated.glb"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
// -- add some lights
|
||||
val lightNode = SceneNode()
|
||||
lightNode.transform = transform {
|
||||
translate(0.0, 10.0, 0.0)
|
||||
rotate(Vector3.UNIT_X, -65.0)
|
||||
}
|
||||
lightNode.entities.add(DirectionalLight())
|
||||
scene.root.entities.add(HemisphereLight().apply {
|
||||
upColor = ColorRGBa.BLUE.shade(0.4)
|
||||
downColor = ColorRGBa.GRAY.shade(0.1)
|
||||
})
|
||||
scene.root.children.add(lightNode)
|
||||
val sceneData = gltf.buildSceneNodes()
|
||||
scene.root.children.addAll(sceneData.scenes.first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
extend(Orbital()) {
|
||||
far = 50.0
|
||||
eye = Vector3(1.5, 0.0, 3.0)
|
||||
fov = 40.0
|
||||
}
|
||||
extend {
|
||||
sceneData.animations[0].applyToTargets(seconds.mod_(sceneData.animations[0].duration))
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
49
orx-jvm/orx-dnk3/src/demo/kotlin/DemoCamera01.kt
Normal file
49
orx-jvm/orx-dnk3/src/demo/kotlin/DemoCamera01.kt
Normal file
@@ -0,0 +1,49 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.math.*
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
//multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/camera/Scene.glb"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
scene.root.entities.add(HemisphereLight().apply {
|
||||
upColor = ColorRGBa(0.1, 0.1, 0.4)
|
||||
downColor = ColorRGBa(0.1, 0.0, 0.0)
|
||||
})
|
||||
|
||||
val sceneData = gltf.buildSceneNodes()
|
||||
scene.root.children.addAll(sceneData.scenes.first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
|
||||
val cameras = scene.root.findContent { this as? PerspectiveCamera }
|
||||
|
||||
extend {
|
||||
sceneData.animations[0].applyToTargets(seconds.mod_(sceneData.animations[0].duration))
|
||||
drawer.view = cameras[0].content.viewMatrix
|
||||
drawer.projection = cameras[0].content.projectionMatrix
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
86
orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL01.kt
Normal file
86
orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL01.kt
Normal file
@@ -0,0 +1,86 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.dsl.*
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extra.dnk3.tools.addSkybox
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.extras.meshgenerators.boxMesh
|
||||
import org.openrndr.extras.meshgenerators.groundPlaneMesh
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
extend(Orbital()) {
|
||||
eye = Vector3(4.0, 4.0, 4.0)
|
||||
}
|
||||
|
||||
val renderer = dryRenderer()
|
||||
val scene = scene {
|
||||
|
||||
addSkybox("file:demo-data/cubemaps/garage_iem.dds")
|
||||
|
||||
root.hemisphereLight {
|
||||
upColor = ColorRGBa.WHITE.shade(0.1)
|
||||
downColor = ColorRGBa.BLACK
|
||||
}
|
||||
|
||||
root.node {
|
||||
transform = transform {
|
||||
translate(0.0, 2.0, 0.0)
|
||||
}
|
||||
|
||||
pointLight {
|
||||
constantAttenuation = 0.0
|
||||
quadraticAttenuation = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
root.node {
|
||||
simpleMesh {
|
||||
vertexBuffer = groundPlaneMesh(100.0, 100.0)
|
||||
material = pbrMaterial {
|
||||
color = ColorRGBa.GREEN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (j in -3..3) {
|
||||
for (i in -3..3) {
|
||||
root.node {
|
||||
transform = transform {
|
||||
translate(i * 2.0, 1.0, j * 2.0)
|
||||
}
|
||||
update {
|
||||
transform = transform {
|
||||
translate(i * 2.0, 1.0, j * 2.0)
|
||||
rotate(Vector3.UNIT_Z, seconds* 45.0 + i * 20.0 + j * 50.0)
|
||||
}
|
||||
}
|
||||
simpleMesh {
|
||||
vertexBuffer = boxMesh()
|
||||
material = pbrMaterial {
|
||||
color = ColorRGBa.WHITE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
87
orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL02.kt
Normal file
87
orx-jvm/orx-dnk3/src/demo/kotlin/DemoDSL02.kt
Normal file
@@ -0,0 +1,87 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.dsl.*
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extra.dnk3.tools.addSkybox
|
||||
import org.openrndr.extra.noise.simplex
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.extras.meshgenerators.groundPlaneMesh
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
import org.openrndr.shape.path3D
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
extend(Orbital()) {
|
||||
eye = Vector3(4.0, 4.0, 4.0)
|
||||
}
|
||||
|
||||
val renderer = dryRenderer()
|
||||
val scene = scene {
|
||||
|
||||
addSkybox("file:demo-data/cubemaps/garage_iem.dds")
|
||||
|
||||
root.hemisphereLight {
|
||||
upColor = ColorRGBa.WHITE.shade(0.1)
|
||||
downColor = ColorRGBa.BLACK
|
||||
}
|
||||
|
||||
root.node {
|
||||
transform = transform {
|
||||
translate(0.0, 2.0, 0.0)
|
||||
}
|
||||
|
||||
pointLight {
|
||||
constantAttenuation = 0.0
|
||||
quadraticAttenuation = 1.0
|
||||
}
|
||||
}
|
||||
|
||||
root.node {
|
||||
simpleMesh {
|
||||
vertexBuffer = groundPlaneMesh(100.0, 100.0)
|
||||
material = pbrMaterial {
|
||||
color = ColorRGBa.GREEN
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
root.node {
|
||||
pathMesh {
|
||||
weight = 10.0
|
||||
material = pbrMaterial {
|
||||
color = ColorRGBa.PINK
|
||||
}
|
||||
update {
|
||||
paths = mutableListOf(
|
||||
path3D {
|
||||
val t = seconds * 0.1
|
||||
moveTo(Vector3.ZERO)
|
||||
val control = Vector3.simplex(3032, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0
|
||||
val target = Vector3.simplex(5077, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0
|
||||
val end = Vector3.simplex(9041, t).let { it.copy(y = it.y * 0.5 + 0.5) } * 4.0
|
||||
curveTo(control, target)
|
||||
continueTo(end)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
115
orx-jvm/orx-dnk3/src/demo/kotlin/DemoIrrProbe01.kt
Normal file
115
orx-jvm/orx-dnk3/src/demo/kotlin/DemoIrrProbe01.kt
Normal file
@@ -0,0 +1,115 @@
|
||||
import kotlinx.coroutines.yield
|
||||
import org.openrndr.*
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.BufferMultisample
|
||||
import org.openrndr.draw.ColorFormat
|
||||
import org.openrndr.draw.ColorType
|
||||
import org.openrndr.draw.DrawPrimitive
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.features.IrradianceSH
|
||||
import org.openrndr.extra.dnk3.features.addIrradianceSH
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.post.ScreenspaceReflections
|
||||
import org.openrndr.extra.dnk3.post.VolumetricIrradiance
|
||||
import org.openrndr.extra.dnk3.renderers.postRenderer
|
||||
import org.openrndr.extra.shaderphrases.annotations.ShaderPhrases
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.extras.meshgenerators.sphereMesh
|
||||
import org.openrndr.ffmpeg.ScreenRecorder
|
||||
import org.openrndr.filter.color.Delinearize
|
||||
import org.openrndr.math.Matrix44
|
||||
import org.openrndr.math.Spherical
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.scale
|
||||
import org.openrndr.math.transforms.transform
|
||||
import org.openrndr.math.transforms.translate
|
||||
import java.io.File
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/irradiance-probes/model.glb"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
val probeBox = sphereMesh(16, 16, 0.1)
|
||||
val probeGeometry = Geometry(listOf(probeBox), null, DrawPrimitive.TRIANGLES, 0, probeBox.vertexCount)
|
||||
|
||||
val c = 5
|
||||
scene.addIrradianceSH(c, c, c, 3.0 / c, cubemapSize = 32, offset = Vector3(0.0, 0.0, 0.0))
|
||||
|
||||
|
||||
val sceneData = gltf.buildSceneNodes()
|
||||
scene.root.children.addAll(sceneData.scenes.first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = postRenderer()
|
||||
|
||||
|
||||
// renderer.postSteps.add(
|
||||
// FilterPostStep(1.0, ScreenspaceReflections(), listOf("color", "clipDepth", "viewNormal"), "reflections", ColorFormat.RGB, ColorType.FLOAT16) {
|
||||
// val p = Matrix44.scale(drawer.width / 2.0, drawer.height / 2.0, 1.0) * Matrix44.translate(Vector3(1.0, 1.0, 0.0)) * drawer.projection
|
||||
// this.projection = p
|
||||
// this.projectionMatrixInverse = drawer.projection.inversed
|
||||
// }
|
||||
// )
|
||||
|
||||
// renderer.postSteps.add(
|
||||
// FilterPostStep(1.0, VolumetricIrradiance(), listOf("color", "clipDepth"), "volumetric-irradiance", ColorFormat.RGB, ColorType.FLOAT16) {
|
||||
// this.irradianceSH = scene.features[0] as IrradianceSH
|
||||
// this.projectionMatrixInverse = drawer.projection.inversed
|
||||
// this.viewMatrixInverse = drawer.view.inversed
|
||||
// }
|
||||
// )
|
||||
|
||||
renderer.postSteps.add(
|
||||
FilterPostStep(1.0, Delinearize(), listOf("color"), "ldr", ColorFormat.RGB, ColorType.FLOAT16)
|
||||
)
|
||||
|
||||
val orb = extend(Orbital()) {
|
||||
this.fov = 20.0
|
||||
camera.setView(Vector3(-0.49, -0.24, 0.20), Spherical(26.56, 90.0, 6.533), 40.0)
|
||||
}
|
||||
|
||||
renderer.draw(drawer, scene)
|
||||
|
||||
val dynNode = SceneNode()
|
||||
val dynMaterial = PBRMaterial()
|
||||
val dynPrimitive = MeshPrimitive(probeGeometry, dynMaterial)
|
||||
val dynMesh = Mesh(listOf(dynPrimitive))
|
||||
dynNode.entities.add(dynMesh)
|
||||
scene.root.children.add(dynNode)
|
||||
|
||||
scene.dispatcher.launch {
|
||||
while (true) {
|
||||
dynNode.transform = transform {
|
||||
translate(cos(seconds) * 0.5, 0.5, sin(seconds) * 0.5)
|
||||
scale(2.0)
|
||||
}
|
||||
yield()
|
||||
}
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
renderer.draw(drawer, scene)
|
||||
drawer.defaults()
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
49
orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights01.kt
Normal file
49
orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights01.kt
Normal file
@@ -0,0 +1,49 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.math.*
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
//multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/point-light/Scene.glb"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
scene.root.entities.add(HemisphereLight().apply {
|
||||
upColor = ColorRGBa(0.1, 0.1, 0.4)
|
||||
downColor = ColorRGBa(0.1, 0.0, 0.0)
|
||||
})
|
||||
|
||||
val sceneData = gltf.buildSceneNodes()
|
||||
scene.root.children.addAll(sceneData.scenes.first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
val orb = extend(Orbital()) {
|
||||
far = 50.0
|
||||
camera.setView(Vector3.ZERO, Spherical(30.50, 26.0, 5.6), 40.0)
|
||||
}
|
||||
extend {
|
||||
sceneData.animations[0].applyToTargets(seconds.mod_(sceneData.animations[0].duration))
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
50
orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights02.kt
Normal file
50
orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights02.kt
Normal file
@@ -0,0 +1,50 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.math.*
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
//multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/spot-light/Scene.glb"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
scene.root.entities.add(HemisphereLight().apply {
|
||||
upColor = ColorRGBa(0.1, 0.1, 0.4)
|
||||
downColor = ColorRGBa(0.1, 0.0, 0.0)
|
||||
})
|
||||
|
||||
|
||||
val sceneData = gltf.buildSceneNodes()
|
||||
scene.root.children.addAll(sceneData.scenes.first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
val orb = extend(Orbital()) {
|
||||
far = 50.0
|
||||
camera.setView(Vector3(-0.514, -0.936, -1.122), Spherical(454.346, 25.0, 8.444), 40.0)
|
||||
}
|
||||
extend {
|
||||
sceneData.animations[0].applyToTargets(seconds.mod_(sceneData.animations[0].duration))
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
49
orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights03.kt
Normal file
49
orx-jvm/orx-dnk3/src/demo/kotlin/DemoLights03.kt
Normal file
@@ -0,0 +1,49 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.math.*
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
//multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/directional-light/Scene.glb"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
scene.root.entities.add(HemisphereLight().apply {
|
||||
upColor = ColorRGBa(0.1, 0.1, 0.4)
|
||||
downColor = ColorRGBa(0.1, 0.0, 0.0)
|
||||
})
|
||||
|
||||
val sceneData = gltf.buildSceneNodes()
|
||||
scene.root.children.addAll(sceneData.scenes.first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
val orb = extend(Orbital()) {
|
||||
camera.setView(Vector3(-0.49, -0.24, 0.20), Spherical(26.56, 90.0, 6.533), 40.0)
|
||||
}
|
||||
|
||||
extend {
|
||||
sceneData.animations[0].applyToTargets(seconds.mod_(sceneData.animations[0].duration))
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
47
orx-jvm/orx-dnk3/src/demo/kotlin/DemoObject01.kt
Normal file
47
orx-jvm/orx-dnk3/src/demo/kotlin/DemoObject01.kt
Normal file
@@ -0,0 +1,47 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.draw.DrawPrimitive
|
||||
import org.openrndr.draw.shadeStyle
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.math.Vector3
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/duck/Duck.gltf"))
|
||||
val meshes = gltf.meshes.map {
|
||||
it.createDrawCommands(gltf)
|
||||
}
|
||||
|
||||
extend(Orbital()) {
|
||||
far = 400.0
|
||||
lookAt = Vector3(0.0, 50.0, 0.0)
|
||||
eye = Vector3(100.0, 200.0, 150.0)
|
||||
fov = 45.0
|
||||
}
|
||||
|
||||
extend {
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
x_fill.rgb = vec3(v_viewNormal.z);
|
||||
""".trimIndent()
|
||||
}
|
||||
for (mesh in meshes) {
|
||||
for (primitive in mesh) {
|
||||
if (primitive.indexBuffer == null) {
|
||||
drawer.vertexBuffer(primitive.vertexBuffer, DrawPrimitive.TRIANGLES)
|
||||
} else {
|
||||
drawer.vertexBuffer(primitive.indexBuffer!!, listOf(primitive.vertexBuffer), DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
56
orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene01.kt
Normal file
56
orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene01.kt
Normal file
@@ -0,0 +1,56 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
//multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/suzanne/Suzanne.gltf"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
// -- add some lights
|
||||
val lightNode = SceneNode()
|
||||
lightNode.transform = transform {
|
||||
translate(0.0, 10.0, 0.0)
|
||||
rotate(Vector3.UNIT_X, -65.0)
|
||||
}
|
||||
lightNode.entities.add(DirectionalLight())
|
||||
scene.root.entities.add(HemisphereLight().apply {
|
||||
upColor = ColorRGBa.BLUE.shade(0.4)
|
||||
downColor = ColorRGBa.GRAY.shade(0.1)
|
||||
})
|
||||
scene.root.children.add(lightNode)
|
||||
scene.root.children.addAll(gltf.buildSceneNodes().scenes.first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
extend(Orbital()) {
|
||||
far = 50.0
|
||||
eye = Vector3(1.5, 0.0, 3.0)
|
||||
fov = 40.0
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
58
orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene02.kt
Normal file
58
orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene02.kt
Normal file
@@ -0,0 +1,58 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/duck/Duck.gltf"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
// -- add some lights
|
||||
val lightNode = SceneNode()
|
||||
lightNode.transform = transform {
|
||||
translate(0.0, 10.0, 0.0)
|
||||
rotate(Vector3.UNIT_X, -90.0)
|
||||
}
|
||||
lightNode.entities.add(DirectionalLight())
|
||||
|
||||
scene.root.entities.add(HemisphereLight().apply {
|
||||
upColor = ColorRGBa.WHITE.shade(1.0)
|
||||
downColor = ColorRGBa.WHITE.shade(0.1)
|
||||
})
|
||||
scene.root.children.add(lightNode)
|
||||
scene.root.children.addAll(gltf.buildSceneNodes().scenes.first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
extend(Orbital()) {
|
||||
far = 500.0
|
||||
lookAt = Vector3(0.0, 0.8, 0.0)
|
||||
eye = Vector3(3.0, 0.8, -2.0)
|
||||
fov = 30.0
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
60
orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene03.kt
Normal file
60
orx-jvm/orx-dnk3/src/demo/kotlin/DemoScene03.kt
Normal file
@@ -0,0 +1,60 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.DrawPrimitive
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.extras.meshgenerators.sphereMesh
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
//multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val root = SceneNode()
|
||||
val scene = Scene(root)
|
||||
|
||||
val lightNode = SceneNode()
|
||||
lightNode.transform = transform {
|
||||
translate(0.0, 10.0, 0.0)
|
||||
}
|
||||
lightNode.entities.add(PointLight())
|
||||
lightNode.entities.add(HemisphereLight(upColor = ColorRGBa.PINK, downColor = ColorRGBa(0.1,0.1,0.1)))
|
||||
scene.root.children.add(lightNode)
|
||||
|
||||
val meshNode = SceneNode()
|
||||
val box = sphereMesh(32, 32)
|
||||
val geometry = Geometry(listOf(box), null, DrawPrimitive.TRIANGLES, 0, box.vertexCount)
|
||||
val material = PBRMaterial()
|
||||
val primitive = MeshPrimitive(geometry, material)
|
||||
val mesh = Mesh(listOf(primitive))
|
||||
meshNode.entities.add(mesh)
|
||||
root.children.add(meshNode)
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
extend(Orbital()) {
|
||||
far = 500.0
|
||||
lookAt = Vector3(0.0, 0.0, 0.0)
|
||||
eye = Vector3(3.0, 2.0, -3.0)
|
||||
fov = 30.0
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
49
orx-jvm/orx-dnk3/src/demo/kotlin/DemoSegmentContours01.kt
Normal file
49
orx-jvm/orx-dnk3/src/demo/kotlin/DemoSegmentContours01.kt
Normal file
@@ -0,0 +1,49 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.BufferMultisample
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.segmentContourRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.mod_
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
//multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/fox/Fox.glb"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
val sceneData = gltf.buildSceneNodes()
|
||||
scene.root.children.addAll(sceneData.scenes.first())
|
||||
|
||||
// -- create a renderer, try it with BufferMultisample.SampleCount(8) for better results
|
||||
val renderer = segmentContourRenderer(BufferMultisample.Disabled)
|
||||
extend(Orbital()) {
|
||||
far = 500.0
|
||||
lookAt = Vector3(0.0, 40.0, 0.0)
|
||||
eye = Vector3(150.0, 40.0, 200.0)
|
||||
fov = 40.0
|
||||
}
|
||||
|
||||
extend {
|
||||
sceneData.animations[2].applyToTargets(seconds.mod_(sceneData.animations[2].duration))
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
53
orx-jvm/orx-dnk3/src/demo/kotlin/DemoSkinning01.kt
Normal file
53
orx-jvm/orx-dnk3/src/demo/kotlin/DemoSkinning01.kt
Normal file
@@ -0,0 +1,53 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.dryRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.mod_
|
||||
import java.io.File
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
//multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/fox/Fox.glb"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
scene.root.entities.add(HemisphereLight().apply {
|
||||
upColor = ColorRGBa.WHITE.shade(0.4)
|
||||
downColor = ColorRGBa.GRAY.shade(0.1)
|
||||
})
|
||||
val sceneData = gltf.buildSceneNodes()
|
||||
scene.root.children.addAll(sceneData.scenes.first())
|
||||
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
extend(Orbital()) {
|
||||
far = 500.0
|
||||
lookAt = Vector3(0.0, 40.0, 0.0)
|
||||
eye = Vector3(150.0, 40.0, 200.0)
|
||||
fov = 40.0
|
||||
}
|
||||
|
||||
extend {
|
||||
sceneData.animations[2].applyToTargets(seconds.mod_(sceneData.animations[2].duration))
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
114
orx-jvm/orx-dnk3/src/demo/kotlin/DemoVoxelConeTracing01.kt
Normal file
114
orx-jvm/orx-dnk3/src/demo/kotlin/DemoVoxelConeTracing01.kt
Normal file
@@ -0,0 +1,114 @@
|
||||
import kotlinx.coroutines.yield
|
||||
import org.openrndr.*
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.*
|
||||
import org.openrndr.extensions.SingleScreenshot
|
||||
import org.openrndr.extra.dnk3.*
|
||||
import org.openrndr.extra.dnk3.features.addVoxelConeTracing
|
||||
import org.openrndr.extra.dnk3.gltf.buildSceneNodes
|
||||
import org.openrndr.extra.dnk3.gltf.loadGltfFromFile
|
||||
import org.openrndr.extra.dnk3.renderers.postRenderer
|
||||
import org.openrndr.extras.camera.Orbital
|
||||
import org.openrndr.extras.meshgenerators.sphereMesh
|
||||
import org.openrndr.filter.color.Delinearize
|
||||
import org.openrndr.math.Spherical
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
import java.io.File
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.sin
|
||||
|
||||
suspend fun main() = application {
|
||||
configure {
|
||||
width = 1280
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
|
||||
if (System.getProperty("takeScreenshot") == "true") {
|
||||
extend(SingleScreenshot()) {
|
||||
this.outputFile = System.getProperty("screenshotPath")
|
||||
}
|
||||
}
|
||||
|
||||
val gltf = loadGltfFromFile(File("demo-data/gltf-models/irradiance-probes/model.glb"))
|
||||
val scene = Scene(SceneNode())
|
||||
|
||||
val probeBox = sphereMesh(16, 16, 0.1)
|
||||
val probeGeometry = Geometry(listOf(probeBox), null, DrawPrimitive.TRIANGLES, 0, probeBox.vertexCount)
|
||||
|
||||
val c = 5
|
||||
// scene.addIrradianceSH(c, c, c, 3.0 / c, cubemapSize = 32, offset = Vector3(0.0, 0.0, 0.0))
|
||||
val vctFeature = scene.addVoxelConeTracing(64,64,64, 0.1)
|
||||
|
||||
|
||||
|
||||
val sceneData = gltf.buildSceneNodes()
|
||||
scene.root.children.addAll(sceneData.scenes.first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = postRenderer()
|
||||
|
||||
|
||||
// renderer.postSteps.add(
|
||||
// FilterPostStep(1.0, ScreenspaceReflections(), listOf("color", "clipDepth", "viewNormal"), "reflections", ColorFormat.RGB, ColorType.FLOAT16) {
|
||||
// val p = Matrix44.scale(drawer.width / 2.0, drawer.height / 2.0, 1.0) * Matrix44.translate(Vector3(1.0, 1.0, 0.0)) * drawer.projection
|
||||
// this.projection = p
|
||||
// this.projectionMatrixInverse = drawer.projection.inversed
|
||||
// }
|
||||
// )
|
||||
|
||||
// renderer.postSteps.add(
|
||||
// FilterPostStep(1.0, VolumetricIrradiance(), listOf("color", "clipDepth"), "volumetric-irradiance", ColorFormat.RGB, ColorType.FLOAT16) {
|
||||
// this.irradianceSH = scene.features[0] as IrradianceSH
|
||||
// this.projectionMatrixInverse = drawer.projection.inversed
|
||||
// this.viewMatrixInverse = drawer.view.inversed
|
||||
// }
|
||||
// )
|
||||
|
||||
renderer.postSteps.add(
|
||||
FilterPostStep(1.0, Delinearize(), listOf("color"), "ldr", ColorFormat.RGB, ColorType.FLOAT16)
|
||||
)
|
||||
|
||||
val orb = extend(Orbital()) {
|
||||
this.fov = 20.0
|
||||
camera.setView(Vector3(-0.49, -0.24, 0.20), Spherical(26.56, 90.0, 6.533), 40.0)
|
||||
}
|
||||
|
||||
renderer.draw(drawer, scene)
|
||||
|
||||
val dynNode = SceneNode()
|
||||
val dynMaterial = PBRMaterial()
|
||||
val dynPrimitive = MeshPrimitive(probeGeometry, dynMaterial)
|
||||
val dynMesh = Mesh(listOf(dynPrimitive))
|
||||
dynNode.entities.add(dynMesh)
|
||||
scene.root.children.add(dynNode)
|
||||
|
||||
scene.dispatcher.launch {
|
||||
while (true) {
|
||||
dynNode.transform = transform {
|
||||
translate(cos(seconds) * 0.5, 0.5, sin(seconds) * 0.5)
|
||||
scale(2.0)
|
||||
}
|
||||
yield()
|
||||
}
|
||||
}
|
||||
|
||||
val viz = colorBuffer(64,64)
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.BLACK)
|
||||
renderer.draw(drawer, scene)
|
||||
drawer.defaults()
|
||||
|
||||
for (i in 0 until 128) {
|
||||
vctFeature.voxelMap?.let {
|
||||
it.copyTo(viz, i)
|
||||
}
|
||||
drawer.image(viz, (i * 128) % width + 0.0, ((i * 128)/width * 128 + 0.0 ))
|
||||
}
|
||||
drawer.image(vctFeature.voxelRenderTarget!!.colorBuffer(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user