diff --git a/orx-camera/src/jvmDemo/kotlin/DemoCamera2D01.kt b/orx-camera/src/jvmDemo/kotlin/DemoCamera2D01.kt index bf12a1e4..84ee2b56 100644 --- a/orx-camera/src/jvmDemo/kotlin/DemoCamera2D01.kt +++ b/orx-camera/src/jvmDemo/kotlin/DemoCamera2D01.kt @@ -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 */ diff --git a/orx-camera/src/jvmDemo/kotlin/DemoCamera2D02.kt b/orx-camera/src/jvmDemo/kotlin/DemoCamera2D02.kt index 7291d65b..223d0c60 100644 --- a/orx-camera/src/jvmDemo/kotlin/DemoCamera2D02.kt +++ b/orx-camera/src/jvmDemo/kotlin/DemoCamera2D02.kt @@ -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 { diff --git a/orx-camera/src/jvmDemo/kotlin/DemoCamera2DManual01.kt b/orx-camera/src/jvmDemo/kotlin/DemoCamera2DManual01.kt index b668dad4..9081c6b9 100644 --- a/orx-camera/src/jvmDemo/kotlin/DemoCamera2DManual01.kt +++ b/orx-camera/src/jvmDemo/kotlin/DemoCamera2DManual01.kt @@ -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 { diff --git a/orx-camera/src/jvmDemo/kotlin/DemoCamera2DManual02.kt b/orx-camera/src/jvmDemo/kotlin/DemoCamera2DManual02.kt index 72f7ea76..ba2b464b 100644 --- a/orx-camera/src/jvmDemo/kotlin/DemoCamera2DManual02.kt +++ b/orx-camera/src/jvmDemo/kotlin/DemoCamera2DManual02.kt @@ -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 } diff --git a/orx-camera/src/jvmDemo/kotlin/DemoOrbital01.kt b/orx-camera/src/jvmDemo/kotlin/DemoOrbital01.kt new file mode 100644 index 00000000..f4c86dd6 --- /dev/null +++ b/orx-camera/src/jvmDemo/kotlin/DemoOrbital01.kt @@ -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) + } + } + } +} \ No newline at end of file diff --git a/orx-camera/src/jvmDemo/kotlin/DemoOrbitalCamera01.kt b/orx-camera/src/jvmDemo/kotlin/DemoOrbitalCamera01.kt index c30ac9fb..d2a82b29 100644 --- a/orx-camera/src/jvmDemo/kotlin/DemoOrbitalCamera01.kt +++ b/orx-camera/src/jvmDemo/kotlin/DemoOrbitalCamera01.kt @@ -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 + } } } } \ No newline at end of file diff --git a/orx-camera/src/jvmDemo/kotlin/DemoParametricOrbital01.kt b/orx-camera/src/jvmDemo/kotlin/DemoParametricOrbital01.kt index 2c92df0f..590a87a2 100644 --- a/orx-camera/src/jvmDemo/kotlin/DemoParametricOrbital01.kt +++ b/orx-camera/src/jvmDemo/kotlin/DemoParametricOrbital01.kt @@ -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)