[orx-camera] Add OrbitalManual, add instant parameter to OrbitalCamera functions

This commit is contained in:
Edwin Jakobs
2025-08-06 18:10:39 +02:00
parent 68f2505351
commit 95581bc6f1
7 changed files with 298 additions and 44 deletions

View File

@@ -1,3 +1,4 @@
import org.openrndr.PresentationMode
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.isolatedWithTarget

View File

@@ -1,3 +1,4 @@
import org.openrndr.WindowMultisample
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
@@ -10,6 +11,11 @@ import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
fun main() = application {
configure {
width = 720
height = 720
multisample = WindowMultisample.SampleCount(8)
}
program {
val camera = OrbitalCamera(
Vector3.UNIT_Z * 90.0, Vector3.ZERO, 90.0, 0.1, 5000.0
@@ -33,7 +39,7 @@ fun main() = application {
extend {
// mouse and keyboard input can be toggled on and off
controls.userInteraction = seconds.toInt() % 4 < 2
controls.userInteraction = true
drawer.vertexBuffer(sphere, DrawPrimitive.LINE_LOOP)
drawer.vertexBuffer(cube, DrawPrimitive.LINE_LOOP)

View File

@@ -0,0 +1,49 @@
import org.openrndr.WindowMultisample
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.extra.camera.OrbitalManual
import org.openrndr.extra.meshgenerators.boxMesh
import org.openrndr.extra.meshgenerators.sphereMesh
import org.openrndr.math.Vector3
/**
* Demonstrate the use of an orbital camera to render a sphere and a cube in 3D space as wireframe meshes, positioned
* and rendered independently using the camera's isolated drawing state. A stationary pink circle is also drawn in the
* center of the scene.
*
* Functionality:
* - Initializes a sphere mesh and a cube mesh with predefined dimensions.
* - Spawns an orbital camera, initially positioned away from the origin, to allow for focused rendering.
* - Renders 3D wireframe shapes (sphere and cube) using the camera's isolated perspective.
* - Draws a static 2D pink circle overlay at the window center.
*/
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)
val camera = OrbitalManual()
camera.camera.rotateTo(Vector3(0.0, 0.0, 30.0), instant = true)
extend {
camera.isolated {
drawer.fill = ColorRGBa.WHITE
drawer.vertexBuffer(sphere, DrawPrimitive.LINE_LOOP)
}
drawer.fill = ColorRGBa.PINK
drawer.circle(drawer.bounds.center, 250.0)
camera.isolated {
drawer.fill = ColorRGBa.WHITE
drawer.vertexBuffer(cube, DrawPrimitive.LINE_LOOP)
}
}
}
}