Fixes and move to jvmDemo (#286)
This commit is contained in:
25
orx-camera/src/jvmDemo/kotlin/DemoCamera2D01.kt
Normal file
25
orx-camera/src/jvmDemo/kotlin/DemoCamera2D01.kt
Normal file
@@ -0,0 +1,25 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.loadFont
|
||||
import org.openrndr.extra.camera.Camera2D
|
||||
|
||||
/**
|
||||
* # Camera2D demo
|
||||
*
|
||||
* click and drag the mouse for panning, use the mouse wheel for zooming
|
||||
*/
|
||||
fun main() = application {
|
||||
program {
|
||||
val font = loadFont("demo-data/fonts/IBMPlexMono-Regular.ttf", 72.0)
|
||||
|
||||
extend(Camera2D())
|
||||
extend {
|
||||
drawer.circle(drawer.bounds.center, 300.0)
|
||||
|
||||
drawer.fontMap = font
|
||||
drawer.fill = ColorRGBa.PINK
|
||||
drawer.text("click and drag mouse", 50.0, 400.0)
|
||||
drawer.text("use mouse wheel", 50.0, 500.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
52
orx-camera/src/jvmDemo/kotlin/DemoOrbitalCamera01.kt
Normal file
52
orx-camera/src/jvmDemo/kotlin/DemoOrbitalCamera01.kt
Normal file
@@ -0,0 +1,52 @@
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.DrawPrimitive
|
||||
import org.openrndr.extra.camera.AxisHelper
|
||||
import org.openrndr.extra.camera.GridHelper
|
||||
import org.openrndr.extra.camera.OrbitalCamera
|
||||
import org.openrndr.extra.camera.OrbitalControls
|
||||
import org.openrndr.extra.meshgenerators.boxMesh
|
||||
import org.openrndr.extra.meshgenerators.sphereMesh
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() = application {
|
||||
program {
|
||||
val camera = OrbitalCamera(
|
||||
Vector3.UNIT_Z * 90.0, Vector3.ZERO, 90.0, 0.1, 5000.0
|
||||
)
|
||||
val controls = OrbitalControls(camera, keySpeed = 10.0)
|
||||
controls.userInteraction = false
|
||||
|
||||
val sphere = sphereMesh(radius = 25.0)
|
||||
val cube = boxMesh(20.0, 20.0, 5.0, 5, 5, 2)
|
||||
|
||||
extend(camera)
|
||||
|
||||
// shows XYZ axes as RGB lines
|
||||
extend(AxisHelper())
|
||||
|
||||
// debug ground plane
|
||||
extend(GridHelper(100))
|
||||
|
||||
// adds mouse and keyboard bindings
|
||||
extend(controls)
|
||||
|
||||
extend {
|
||||
// mouse and keyboard input can be toggled on and off
|
||||
controls.userInteraction = seconds.toInt() % 4 < 2
|
||||
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.LINE_LOOP)
|
||||
drawer.vertexBuffer(cube, DrawPrimitive.LINE_LOOP)
|
||||
|
||||
drawer.stroke = if(controls.userInteraction) ColorRGBa.GREEN else ColorRGBa.WHITE
|
||||
drawer.fill = null
|
||||
|
||||
repeat(10) {
|
||||
drawer.translate(0.0, 0.0, 10.0)
|
||||
// Note: 2D primitives are not optimized for 3D and can
|
||||
// occlude each other
|
||||
drawer.circle(0.0, 0.0, 50.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
orx-camera/src/jvmDemo/kotlin/DemoParametricOrbital01.kt
Normal file
37
orx-camera/src/jvmDemo/kotlin/DemoParametricOrbital01.kt
Normal file
@@ -0,0 +1,37 @@
|
||||
import org.openrndr.WindowMultisample
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.DrawPrimitive
|
||||
import org.openrndr.draw.shadeStyle
|
||||
import org.openrndr.extra.camera.*
|
||||
import org.openrndr.extra.gui.GUI
|
||||
import org.openrndr.extra.gui.addTo
|
||||
import org.openrndr.extra.meshgenerators.boxMesh
|
||||
import org.openrndr.extra.meshgenerators.sphereMesh
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
fun main() = application {
|
||||
configure {
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
|
||||
program {
|
||||
val gui = GUI()
|
||||
val po = ParametricOrbital()
|
||||
po.addTo(gui)
|
||||
extend(gui)
|
||||
extend(po)
|
||||
|
||||
val bm = boxMesh()
|
||||
extend {
|
||||
drawer.clear(ColorRGBa.PINK)
|
||||
drawer.shadeStyle = shadeStyle {
|
||||
fragmentTransform = """
|
||||
vec3 n = normalize(v_viewNormal) * 0.5 + 0.5;
|
||||
x_fill = vec4(n, 1.0);
|
||||
""".trimIndent()
|
||||
}
|
||||
drawer.vertexBuffer(bm, DrawPrimitive.TRIANGLES)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user