[orx-camera] Improve demo descriptions, add demo
This commit is contained in:
@@ -4,7 +4,7 @@ import org.openrndr.draw.loadFont
|
||||
import org.openrndr.extra.camera.Camera2D
|
||||
|
||||
/**
|
||||
* # Camera2D demo
|
||||
* #### Camera2D demo
|
||||
*
|
||||
* click and drag the mouse for panning, use the mouse wheel for zooming
|
||||
*/
|
||||
|
||||
@@ -10,9 +10,10 @@ import org.openrndr.shape.Rectangle
|
||||
import kotlin.math.sin
|
||||
|
||||
/**
|
||||
* # Camera2D demo with static elements
|
||||
* #### Camera2D demo with static elements
|
||||
*
|
||||
* An approach for having certain elements not affected by the camera
|
||||
* An approach for having certain elements not affected by the camera.
|
||||
* See DemoCamera2DManual01.kt for a new and simpler approach
|
||||
*/
|
||||
fun main() = application {
|
||||
program {
|
||||
|
||||
@@ -3,15 +3,12 @@ import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.extra.camera.Camera2DManual
|
||||
|
||||
/**
|
||||
* Demonstrate the use of `Camera2DManual` for manual camera control.
|
||||
* Demonstrates how to use `Camera2DManual` to have
|
||||
* some elements affected by an interactive 2D camera combined with
|
||||
* other elements not affected by it.
|
||||
*
|
||||
* The application is configured with a 720x720 window size. Within the program, a custom camera (`Camera2DManual`)
|
||||
* is initialized and used to create isolated drawing scopes. The `isolated` method is used to overlay different
|
||||
* drawing operations while maintaining individual camera states, ensuring proper transformations for specific elements.
|
||||
*
|
||||
* Three circles are drawn on the canvas: a small pink one, a medium white one and a large pink one.
|
||||
* Only the pink ones are affected by the interactive `Camera2DManual`, while the middle white circle is outside
|
||||
* the camera's isolated scope.
|
||||
* In this example both PINK circles can be dragged, scaled and rotated
|
||||
* while the white circle in the middle is static.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
|
||||
@@ -61,6 +61,7 @@ fun main() = application {
|
||||
|
||||
// Reset the camera to its default state
|
||||
camera.defaults()
|
||||
camera.rotationCenter = it.position
|
||||
|
||||
// Make the contour under the mouse the active contour
|
||||
activeContour = contours.indexOfLast { mouse.position in it }
|
||||
|
||||
39
orx-camera/src/jvmDemo/kotlin/DemoOrbital01.kt
Normal file
39
orx-camera/src/jvmDemo/kotlin/DemoOrbital01.kt
Normal file
@@ -0,0 +1,39 @@
|
||||
import org.openrndr.WindowMultisample
|
||||
import org.openrndr.application
|
||||
import org.openrndr.color.ColorRGBa
|
||||
import org.openrndr.draw.DrawPrimitive
|
||||
import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.meshgenerators.boxMesh
|
||||
import org.openrndr.extra.meshgenerators.sphereMesh
|
||||
|
||||
/**
|
||||
* Demonstrate the use of `Orbital`, an interactive 3D camera
|
||||
* that can be controlled with a mouse and a keyboard.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
height = 720
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
}
|
||||
program {
|
||||
val sphere = sphereMesh(radius = 25.0)
|
||||
val cube = boxMesh(20.0, 20.0, 5.0, 5, 5, 2)
|
||||
|
||||
extend(Orbital())
|
||||
|
||||
extend {
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.LINE_LOOP)
|
||||
drawer.vertexBuffer(cube, DrawPrimitive.LINE_LOOP)
|
||||
drawer.fill = null
|
||||
drawer.stroke = ColorRGBa.GREEN
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,11 @@ import org.openrndr.extra.meshgenerators.boxMesh
|
||||
import org.openrndr.extra.meshgenerators.sphereMesh
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
/**
|
||||
* Demonstrate the use of `OrbitalCamera`, `OrbitalControls`, `AxisHelper` and `GridHelper`.
|
||||
*
|
||||
* Press the `t` key to toggle camera interaction, or `r` to reset the camera to its defaults.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
@@ -38,9 +43,6 @@ fun main() = application {
|
||||
extend(controls)
|
||||
|
||||
extend {
|
||||
// mouse and keyboard input can be toggled on and off
|
||||
controls.userInteraction = true
|
||||
|
||||
drawer.vertexBuffer(sphere, DrawPrimitive.LINE_LOOP)
|
||||
drawer.vertexBuffer(cube, DrawPrimitive.LINE_LOOP)
|
||||
|
||||
@@ -58,6 +60,10 @@ fun main() = application {
|
||||
if (it.name == "r") {
|
||||
camera.defaults()
|
||||
}
|
||||
if (it.name == "t") {
|
||||
// mouse and keyboard input can be toggled on and off
|
||||
controls.userInteraction = !controls.userInteraction
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,17 @@ import org.openrndr.extra.gui.GUI
|
||||
import org.openrndr.extra.gui.addTo
|
||||
import org.openrndr.extra.meshgenerators.boxMesh
|
||||
|
||||
/**
|
||||
* Demonstrates the use of a `ParametricOrbital` camera.
|
||||
* This 3D camera can't be directly interacted with a mouse or a keyboard,
|
||||
* but only via a GUI (or via code).
|
||||
*
|
||||
* The GUI state is saved when closing the program and loaded
|
||||
* when running it again.
|
||||
*
|
||||
* The GUI also allows randomizing, loading and saving
|
||||
* its state to a file via the top buttons it displays.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
multisample = WindowMultisample.SampleCount(8)
|
||||
|
||||
Reference in New Issue
Block a user