CameraNode

open class CameraNode(val engine: Engine, val entity: Entity) : Node, CameraComponent

Represents a virtual camera, which determines the perspective through which the scene is viewed.

All other functionality in Node is supported. You can access the position and rotation of the camera, assign a collision shape to it, or add children to it. Disabling the camera turns off rendering.

Inheritors

Constructors

Link copied to clipboard
constructor(engine: Engine, camera: Camera.() -> Unit = {})
constructor(engine: Engine, entity: Entity)

Properties

Link copied to clipboard
open val aperture: Float

Gets the aperture in f-stops

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The shape to used to detect collisions for this Node.

Link copied to clipboard
Link copied to clipboard
open val cullingFar: Float

Gets the distance to the far plane

Link copied to clipboard

Retrieves the camera's culling matrix. The culling matrix is the same as the projection matrix, except the far plane is finite.

Link copied to clipboard
Link copied to clipboard
val engine: Engine
Link copied to clipboard
Link copied to clipboard
open override var far: Float
Link copied to clipboard
open override var focalLength: Double

Gets the focal length in meters

Link copied to clipboard

The distance from the camera to the focus plane in world units

Link copied to clipboard

Retrieves the camera forward unit vector in world space, that is a unit vector that points in the direction the camera is looking at.

Link copied to clipboard
open override var isEditable: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var isTouchable: Boolean

The node can be selected when a touch event happened.

Link copied to clipboard
open var isVisible: Boolean

The visible state of this node.

Link copied to clipboard

Retrieves the camera left unit vector in world space, that is a unit vector that points to the left of the camera.

Link copied to clipboard

The camera's model matrix.

Link copied to clipboard
open var name: String?
Link copied to clipboard
open override var near: Float

Gets the distance to the near plane

Link copied to clipboard
var onAddedToScene: (scene: Scene) -> Unit?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var onDown: (e: MotionEvent) -> Boolean?
Link copied to clipboard
var onEditingChanged: (editingTransforms: Set<KProperty1<Node, Any>?>) -> Unit?
Link copied to clipboard
var onFling: (e1: MotionEvent?, e2: MotionEvent, velocity: Float2) -> Boolean?
Link copied to clipboard
var onFrame: (frameTimeNanos: Long) -> Unit?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var onRemovedFromScene: (scene: Scene) -> Unit?
Link copied to clipboard
var onRotate: (detector: RotateGestureDetector, e: MotionEvent, rotationDelta: Quaternion) -> Boolean?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var onScale: (detector: ScaleGestureDetector, e: MotionEvent, scaleFactor: Float) -> Boolean?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var onScroll: (e1: MotionEvent?, e2: MotionEvent, distance: Float2) -> Boolean?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var onSmoothEnd: (node: Node) -> Unit?
Link copied to clipboard
var onTouch: (e: MotionEvent, hitResult: HitResult) -> Boolean?
Link copied to clipboard
open var parent: Node?

Changes the parent node.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open var position: Position

Position to locate within the coordinate system the parent.

Link copied to clipboard
open var projectionTransform: Mat4

Retrieves the camera's projection matrix. The projection matrix used for rendering always has its far plane set to infinity. This is why it may differ from the matrix set through setProjection() or setLensProjection().

Link copied to clipboard
open var quaternion: Quaternion

Quaternion rotation.

Link copied to clipboard
open var rotation: Rotation

Orientation in Euler Angles Degrees per axis from 0.0f to 360.0f.

Link copied to clipboard
open var scale: Scale

Scale on each axis.

Link copied to clipboard
open val scaling: Float4

Returns the scaling amount used to scale the projection matrix.

Link copied to clipboard
open val sensitivity: Float

Gets the sensitivity in ISO

Link copied to clipboard

Gets the shutter speed in seconds

Link copied to clipboard
Link copied to clipboard

The smooth position, rotation and scale speed.

Link copied to clipboard

Local transform of the transform component (i.e. relative to the parent).

Link copied to clipboard
Link copied to clipboard
val transformManager: TransformManager
Link copied to clipboard

Retrieves the camera up unit vector in world space, that is a unit vector that points up with respect to the camera.

Link copied to clipboard
var view: View?
Link copied to clipboard
val viewport: Viewport?
Link copied to clipboard

Retrieves the camera's view matrix. The view matrix is the inverse of the model matrix.

Link copied to clipboard

World-space position.

Link copied to clipboard
open var worldQuaternion: Quaternion

The world-space quaternion.

Link copied to clipboard

World-space rotation.

Link copied to clipboard
open var worldScale: Scale

World-space scale.

Link copied to clipboard

Transform from the world coordinate system to the coordinate system of this node.

Link copied to clipboard

World transform of a transform component (i.e. relative to the root).

Functions

Link copied to clipboard
fun addChildNode(node: Node): Node
Link copied to clipboard
fun addChildNodes(nodes: Set<Node>): Node
Link copied to clipboard
fun animatePositions(vararg positions: Position): ObjectAnimator
Link copied to clipboard
fun animateQuaternions(vararg quaternions: Quaternion): ObjectAnimator
Link copied to clipboard
fun animateRotations(vararg rotations: Rotation): ObjectAnimator
Link copied to clipboard
fun animateScales(vararg scales: Scale): ObjectAnimator
Link copied to clipboard
fun animateTransforms(vararg transforms: Transform): AnimatorSet
Link copied to clipboard
Link copied to clipboard
open override fun destroy()

Detach and destroy the node and all its children.

Link copied to clipboard
fun getLocalPosition(worldPosition: Position): Float3

Converts a position in the world-space to a local-space of this node.

Link copied to clipboard
fun getLocalQuaternion(worldQuaternion: Quaternion): Quaternion

Converts a quaternion in the world-space to a local-space of this node.

Link copied to clipboard
fun getLocalRotation(worldRotation: Rotation): Float3

Converts a rotation in the world-space to a local-space of this node.

Link copied to clipboard
fun getLocalScale(worldScale: Scale): Float3

Converts a scale in the world-space to a local-space of this node.

Link copied to clipboard
fun getLocalTransform(worldTransform: Transform): Mat4

Converts a transform in the world-space to a local-space of this node.

fun getLocalTransform(node: Node): Mat4

Converts a node transform in the world-space to a local-space of this node.

Link copied to clipboard
open override fun getTransformationMatrix(): Matrix
Link copied to clipboard
fun getWorldPosition(localPosition: Position): Float3

Converts a position in the local-space of this node to world-space.

Link copied to clipboard
fun getWorldQuaternion(quaternion: Quaternion): Quaternion

Converts a quaternion in the local-space of this node to world-space.

Link copied to clipboard
fun getWorldRotation(rotation: Rotation): Float3

Converts a rotation in the local-space of this node to world-space.

Link copied to clipboard
fun getWorldScale(scale: Scale): Float3

Converts a scale in the local-space of this node to world-space.

Link copied to clipboard
fun getWorldTransform(localTransform: Transform): Mat4

Converts a transform in the local-space of this node to world-space.

fun getWorldTransform(node: Node): Mat4

Converts a node transform in the local-space of this node to world-space.

Link copied to clipboard
fun hitTest(motionEvent: MotionEvent): List<HitResult>
fun hitTest(xPx: Float, yPx: Float): List<HitResult>

Tests to see if a ray starting from the screen/camera position is hitting any nodes within the scene and returns a list of HitTestResults containing all of the nodes that were hit, sorted by distance.

Tests to see if a ray is hitting any nodes within the scene and returns a list of HitTestResults containing all of the nodes that were hit, sorted by distance.

Link copied to clipboard
fun hitTestView(xViewPercent: Float = 0.5f, yViewPercent: Float = 0.5f): List<HitResult>

Tests to see if a ray starting from the screen/camera position is hitting any nodes within the scene and returns a list of HitTestResults containing all of the nodes that were hit, sorted by distance.

Link copied to clipboard
open fun lookAt(eye: Position, center: Position, up: Direction)

Sets the camera's model matrix.

fun lookAt(targetWorldPosition: Position, upDirection: Direction = Direction(y = 1.0f), smooth: Boolean = isSmoothTransformEnabled, smoothSpeed: Float = smoothTransformSpeed): Node

Rotates the node to face a point in world-space.

fun lookAt(targetNode: Node, upDirection: Direction = Direction(y = 1.0f), smooth: Boolean = isSmoothTransformEnabled, smoothSpeed: Float = smoothTransformSpeed): Node

Rotates the node to face another node.

Link copied to clipboard
fun lookTowards(lookDirection: Direction, upDirection: Direction = Direction(y = 1.0f), smooth: Boolean = isSmoothTransformEnabled, smoothSpeed: Float = smoothTransformSpeed): Node

Rotates the node to face a direction in world-space.

Link copied to clipboard
fun motionEventToRay(motionEvent: MotionEvent): Ray
Link copied to clipboard
open fun onAddedToScene(scene: Scene)
Link copied to clipboard
open override fun onContextClick(e: MotionEvent): Boolean
Link copied to clipboard
open override fun onDoubleTap(e: MotionEvent): Boolean
Link copied to clipboard
open override fun onDoubleTapEvent(e: MotionEvent): Boolean
Link copied to clipboard
open override fun onDown(e: MotionEvent): Boolean
Link copied to clipboard
open override fun onFling(e1: MotionEvent?, e2: MotionEvent, velocityX: Float, velocityY: Float): Boolean
Link copied to clipboard
open fun onFrame(frameTimeNanos: Long)
Link copied to clipboard
open override fun onLongPress(e: MotionEvent)
Link copied to clipboard
open override fun onMove(detector: MoveGestureDetector, e: MotionEvent): Boolean

Responds to moving events for a gesture in progress

open fun onMove(detector: MoveGestureDetector, e: MotionEvent, worldPosition: Position): Boolean
Link copied to clipboard
open override fun onMoveBegin(detector: MoveGestureDetector, e: MotionEvent): Boolean

Responds to the beginning of a moving gesture

Link copied to clipboard
open override fun onMoveEnd(detector: MoveGestureDetector, e: MotionEvent)

Responds to the end of a move gesture

Link copied to clipboard
open fun onRemovedFromScene(scene: Scene)
Link copied to clipboard
open override fun onRotate(detector: RotateGestureDetector, e: MotionEvent): Boolean

Responds to rotating events for a gesture in progress.

open fun onRotate(detector: RotateGestureDetector, e: MotionEvent, rotationDelta: Quaternion): Boolean
Link copied to clipboard
open override fun onRotateBegin(detector: RotateGestureDetector, e: MotionEvent): Boolean

Responds to the beginning of a scaling gesture.

Link copied to clipboard
open override fun onRotateEnd(detector: RotateGestureDetector, e: MotionEvent)

Responds to the end of a scale gesture.

Link copied to clipboard
open override fun onScale(detector: ScaleGestureDetector, e: MotionEvent): Boolean

Responds to scaling events for a gesture in progress.

open fun onScale(detector: ScaleGestureDetector, e: MotionEvent, scaleFactor: Float): Boolean
Link copied to clipboard
open override fun onScaleBegin(detector: ScaleGestureDetector, e: MotionEvent): Boolean

Responds to the beginning of a scaling gesture. Reported by new pointers going down.

Link copied to clipboard
open override fun onScaleEnd(detector: ScaleGestureDetector, e: MotionEvent)

Responds to the end of a scale gesture. Reported by existing pointers going up.

Link copied to clipboard
open override fun onScroll(e1: MotionEvent?, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean
Link copied to clipboard
open override fun onShowPress(e: MotionEvent)
Link copied to clipboard
Link copied to clipboard
open override fun onSingleTapUp(e: MotionEvent): Boolean
Link copied to clipboard
open fun onTouchEvent(e: MotionEvent, hitResult: HitResult): Boolean
Link copied to clipboard

The transformation (position, rotation or scale) of the Node has changed.

Link copied to clipboard

The transformation (position, rotation or scale) of the Node has changed.

Link copied to clipboard
fun overlapTest(): Node?

Tests to see if this node collision shape overlaps the collision shape of any other nodes in the scene using Node.collisionShape.

Link copied to clipboard
fun overlapTestAll(): List<Node>

Tests to see if a node is overlapping any other nodes within the scene using Node.collisionShape.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Calculates a ray in world space going from the near-plane of the camera and going through a point in screen space.

Link copied to clipboard
open fun setCustomProjection(inProjection: Transform, near: Double = camera.near.toDouble(), far: Double = camera.cullingFar.toDouble(), inProjectionForCulling: Transform = inProjection)

Sets a custom projection matrix.

Link copied to clipboard
open fun setExposure(exposure: Float)

Sets this camera's exposure directly. Calling this method will set the aperture to 1.0, the shutter speed to 1.2 and the sensitivity will be computed to match the requested exposure (for a desired exposure of 1.0, the sensitivity will be set to 100 ISO).

open fun setExposure(aperture: Float, shutterSpeed: Float, sensitivity: Float)

Sets this camera's exposure (default is f/16, 1/125s, 100 ISO)

Link copied to clipboard
open fun setLensProjection(focalLength: Double, aspect: Double, near: Double, far: Double)

Sets the projection matrix from the focal length.

Link copied to clipboard
open fun setProjection(fovInDegrees: Double, aspect: Double, near: Double, far: Double, direction: Camera.Fov)
fun setProjection(fovInDegrees: Double, near: Float = _near, far: Float = _far, direction: Camera.Fov = Camera.Fov.VERTICAL, aspect: Double = getViewPortAspect())

Sets the projection matrix from the field-of-view.

open fun setProjection(projection: Camera.Projection, left: Double, right: Double, bottom: Double, top: Double, near: Double, far: Double)

Sets the projection matrix from a frustum defined by six planes.

Link copied to clipboard
fun setScale(scale: Float)

The node scale.

Link copied to clipboard
open fun setScaling(scaling: Float2)

Sets an additional matrix that scales the projection matrix.

Link copied to clipboard
open fun setShift(xShift: Double, yShift: Double)

Sets an additional matrix that shifts (translates) the projection matrix.

Link copied to clipboard
open fun transform(transform: Transform, smooth: Boolean = isSmoothTransformEnabled, smoothSpeed: Float = smoothTransformSpeed): Node
fun transform(position: Position = this.position, rotation: Rotation, scale: Scale = this.scale, smooth: Boolean = isSmoothTransformEnabled, smoothSpeed: Float = smoothTransformSpeed): Node
fun transform(position: Position = this.position, quaternion: Quaternion = this.quaternion, scale: Scale = this.scale, smooth: Boolean = isSmoothTransformEnabled, smoothSpeed: Float = smoothTransformSpeed): Node

Change the node transform.

Link copied to clipboard
open fun updateProjection(focalLength: Double = _focalLength, near: Float = _near, far: Float = _far, aspect: Double = getViewPortAspect())

Sets the projection matrix from the focal length.

Link copied to clipboard
open fun viewToRay(viewPosition: Float2): Ray

Calculates a ray in world space going from the near-plane of the camera and through a point in view space.

Link copied to clipboard
open fun viewToWorld(viewPosition: Float2, z: Float = 1.0f): Float3

Get a world space position from a view space position.

Link copied to clipboard

Convert a point from world space into screen space.

Link copied to clipboard
open fun worldToView(worldPosition: Position): Float2

Get a view space position from a world position.

Link copied to clipboard
open fun worldTransform(worldTransform: Transform, smooth: Boolean = isSmoothTransformEnabled, smoothSpeed: Float = smoothTransformSpeed): Node
fun worldTransform(position: Position = this.worldPosition, rotation: Rotation, scale: Scale = this.worldScale, smooth: Boolean = isSmoothTransformEnabled, smoothSpeed: Float = smoothTransformSpeed): Node
fun worldTransform(position: Position = this.worldPosition, quaternion: Quaternion = this.worldQuaternion, scale: Scale = this.worldScale, smooth: Boolean = isSmoothTransformEnabled, smoothSpeed: Float = smoothTransformSpeed): Node

Change the node world transform.