Most visited

Recently visited

Camera

public class Camera
extends Object

java.lang.Object
   ↳ com.viro.core.Camera


The Camera defines the point of view of the user in the Scene. You can display the Scene from the point of view of any Node. To do this, create a Camera and attach it to a Node via setCamera(Camera). Then make that Node the point of view for the renderer by invoking setPointOfView(Node).

Camera is used to change the user's view of the scene. Note that when in AR or VR modes, the point of view is automatically computed based on the device's rotation and position in the world. This class is primarily for use with ViroViewScene.

Because Camera is included in the scene graph, it can be moved, animated, and rotated alongside other Nodes. You can also set the position and orientation of the Camera object itself.

The initial orientation of the camera is pointing in the negative Z direction: that is, into the screen. If no point of view is set in the ViroView, the user will be positioned at the origin looking in the negative Z direction.

For an extended discussion of Camera, refer to the Camera Guide.

Summary

Nested classes

enum Camera.RotationType

Specifies the behavior of the Camera in VR when rotating the headset. 

Public constructors

Camera()

Construct a new Camera.

Public methods

void dispose()

Release native resources associated with this Camera.

float getFieldOfView()

Return the field of view used by this Camera along its major (larger) axis, in degrees.

Vector getOrbitFocalPoint()

Get the focal point around which the Camera will orbit when in ORBIT mode.

Vector getPosition()

Get the position of this Camera in the coordinate space of its parent Node.

Quaternion getRotation()

Get the rotation of this Camera.

Camera.RotationType getRotationType()

Get the Camera.RotationType used by the Camera.

void setFieldOfView(float fov)

Set the field of view for this camera, along the major (larger) axis.

void setOrbitFocalPoint(Vector focalPoint)

Set the focal point around which the Camera will orbit when in ORBIT mode.

void setPosition(Vector position)

Set the position of this Camera in the coordinate space of its parent Node.

void setRotation(Vector rotation)

Set the rotation of this Camera.

void setRotation(Quaternion rotation)

Set the rotation of this Camera.

void setRotationType(Camera.RotationType rotationType)

Set the Camera.RotationType of this Camera in VR.

Public constructors

Camera

Camera ()

Construct a new Camera.

Public methods

dispose

void dispose ()

Release native resources associated with this Camera.

getFieldOfView

float getFieldOfView ()

Return the field of view used by this Camera along its major (larger) axis, in degrees. Field of view is an angle that determines how wide or narrow the camera lens is when rendering the scene.

Returns
float The field of view across the major axis, in degrees.

getOrbitFocalPoint

Vector getOrbitFocalPoint ()

Get the focal point around which the Camera will orbit when in ORBIT mode.

Returns
Vector The focal point as a Vector.

getPosition

Vector getPosition ()

Get the position of this Camera in the coordinate space of its parent Node.

Returns
Vector The position as a Vector.

getRotation

Quaternion getRotation ()

Get the rotation of this Camera.

Returns
Quaternion The rotation as a Quaternion.

getRotationType

Camera.RotationType getRotationType ()

Get the Camera.RotationType used by the Camera.

Returns
Camera.RotationType The Camera.RotationType.

setFieldOfView

void setFieldOfView (float fov)

Set the field of view for this camera, along the major (larger) axis. Field of view is an angle that determines how wide or narrow the camera lens is when rendering the scene.

This value sets the field of view, in degrees, for the major axis. The major axis is the axis with the larger dimension: the X axis in landscape mode, or the Y axis in portrait mode. By specifying the field of view in terms of the major axis, Viro can keep the field of view consistent upon orientation changes, when the major/minor axes swap. The minor axis field of view is automatically computed from the major axis field of view and the viewport.

If this is set to 0, then Viro will use the default field of view: 90 degrees.

This value is ignored on VR and AR platforms, where the FOV is fixed by the VR headset or the AR camera.

Parameters
fov float: The field of view for the major axis, in degrees.

setOrbitFocalPoint

void setOrbitFocalPoint (Vector focalPoint)

Set the focal point around which the Camera will orbit when in ORBIT mode.

Parameters
focalPoint Vector: The focal point as a Vector.

setPosition

void setPosition (Vector position)

Set the position of this Camera in the coordinate space of its parent Node.

Parameters
position Vector: The position as a Vector.

setRotation

void setRotation (Vector rotation)

Set the rotation of this Camera. Note the Camera is also rotated by its parent hierarchy in the scene graph. The default orientation is looking in the negative Z direction (into the screen).

Parameters
rotation Vector: Vector containing the rotation as Euler angles in radians.

setRotation

void setRotation (Quaternion rotation)

Set the rotation of this Camera. Note the Camera is also rotated by its parent hierarchy in the scene graph. The default orientation is looking in the negative Z direction (into the screen).

Parameters
rotation Quaternion: The rotation as a Quaternion.

setRotationType

void setRotationType (Camera.RotationType rotationType)

Set the Camera.RotationType of this Camera in VR. The Camera can either be attached to the headset, in that when the headset moves the camera moves concomitantly, or it can be placed in orbit mode, whereby rotation of the headset causes the camera to orbit around a specific focal point.

Parameters
rotationType Camera.RotationType: The Camera.RotationType for the camera.

Hooray!