Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix orx-camera readme #224

Merged
merged 1 commit into from
Feb 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 37 additions & 17 deletions orx-camera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,44 @@
## Usage

```kotlin
val camera = OrbitalCamera(Vector3.UNIT_Z * 1000.0, Vector3.ZERO, 90.0, 0.1, 2000.0)
val controls = OrbitalControls(camera, keySpeed = 10.0)

val debug3d = Debug3D(1000, 100)

extend(camera)
extend(controls) // adds both mouse and keyboard bindings
extend {
debug3d.draw(drawer)

drawer.perspective(90.0, width*1.0 / height, 0.1, 5000.0)
drawer.shadeStyle = shadeStyle {
vertexTransform = """x_viewMatrix = p_view"""
parameter("view", camera.viewMatrix())
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.extras.camera.AxisHelper
import org.openrndr.extras.camera.GridHelper
import org.openrndr.extras.camera.OrbitalCamera
import org.openrndr.extras.camera.OrbitalControls
import org.openrndr.extras.meshgenerators.boxMesh
import org.openrndr.extras.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)

val sphere = sphereMesh(radius = 25.0)
val cube = boxMesh(20.0, 20.0, 5.0, 5, 5, 2)

extend(camera)
extend(AxisHelper()) // shows XYZ axes as RGB lines
extend(GridHelper(100)) // debug ground plane
extend(controls) // adds both mouse and keyboard bindings
extend {
drawer.vertexBuffer(sphere, DrawPrimitive.LINE_LOOP)
drawer.vertexBuffer(cube, DrawPrimitive.LINE_LOOP)
drawer.stroke = ColorRGBa.WHITE
drawer.fill = null
repeat(10) {
drawer.translate(0.0, 0.0, 10.0)
// 2D primitives are not optimized for 3D and can
// occlude each other
drawer.circle(0.0, 0.0, 50.0)
}
}
}

drawer.fill = ColorRGBa.PINK
drawer.circle(0.0, 0.0, 500.0)
}
```

Expand Down