Add orx-dnk3a
This commit is contained in:
47
orx-dnk3/src/demo/kotlin/DemoObject01.kt
Normal file
47
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
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
55
orx-dnk3/src/demo/kotlin/DemoScene01.kt
Normal file
55
orx-dnk3/src/demo/kotlin/DemoScene01.kt
Normal file
@@ -0,0 +1,55 @@
|
||||
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.extras.camera.Orbital
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
import java.io.File
|
||||
|
||||
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().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)
|
||||
}
|
||||
}
|
||||
}
|
||||
57
orx-dnk3/src/demo/kotlin/DemoScene02.kt
Normal file
57
orx-dnk3/src/demo/kotlin/DemoScene02.kt
Normal file
@@ -0,0 +1,57 @@
|
||||
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.extras.camera.Orbital
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.math.transforms.transform
|
||||
import java.io.File
|
||||
|
||||
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/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, -65.0)
|
||||
}
|
||||
lightNode.entities.add(DirectionalLight())
|
||||
scene.root.entities.add(HemisphereLight().apply {
|
||||
upColor = ColorRGBa.WHITE.shade(0.4)
|
||||
downColor = ColorRGBa.WHITE.shade(0.1)
|
||||
})
|
||||
scene.root.children.add(lightNode)
|
||||
scene.root.children.addAll(gltf.buildSceneNodes().first())
|
||||
|
||||
// -- create a renderer
|
||||
val renderer = dryRenderer()
|
||||
extend(Orbital()) {
|
||||
far = 50.0
|
||||
lookAt = Vector3(0.0, 0.7, 0.0)
|
||||
eye = Vector3(3.0, 0.7, -2.0)
|
||||
fov = 40.0
|
||||
}
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
renderer.draw(drawer, scene)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user