# Class Camera

java.lang.Object
com.codename1.gpu.Camera

public final class Camera extends Object
A perspective or orthographic camera. The camera builds a view matrix from an eye position, a look-at target and an up vector, and a projection matrix from its lens parameters. Combine the two through `getViewProjection()` which the device multiplies with each model matrix.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Camera()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `float`
  `getEyeX()`
  Returns the eye (camera) world space x coordinate.
  `float`
  `getEyeY()`
  Returns the eye (camera) world space y coordinate.
  `float`
  `getEyeZ()`
  Returns the eye (camera) world space z coordinate.
  `float[]`
  `getProjectionMatrix()`
  Returns the 16 element column-major projection matrix.
  `float[]`
  `getViewMatrix()`
  Returns the 16 element column-major view matrix.
  `float[]`
  `getViewProjection()`
  Returns the 16 element column-major combined projection * view matrix.
  `Camera`
  `setAspect(float aspect)`
  Sets the viewport aspect ratio (width / height).
  `Camera`
  `setOrthographic(float height, float near, float far)`
  Configures an orthographic projection.
  `Camera`
  `setPerspective(float fovYDegrees, float near, float far)`
  Configures a perspective projection.
  `Camera`
  `setPosition(float x, float y, float z)`
  Sets the eye (camera) world position.
  `Camera`
  `setTarget(float x, float y, float z)`
  Sets the world space point the camera looks at.
  `Camera`
  `setUp(float x, float y, float z)`
  Sets the camera up vector.

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Camera

    public Camera()

- ## Method Details

  - ### setPerspective

    public Camera setPerspective(float fovYDegrees, float near, float far)

    Configures a perspective projection.

    ###### Parameters

    - `fovYDegrees`: the vertical field of view in degrees

    - `near`: the near clip plane distance

    - `far`: the far clip plane distance

    ###### Returns

    this camera for chaining

  - ### setOrthographic

    public Camera setOrthographic(float height, float near, float far)

    Configures an orthographic projection.

    ###### Parameters

    - `height`: the visible world height; width is derived from the aspect

    - `near`: the near clip plane distance

    - `far`: the far clip plane distance

    ###### Returns

    this camera for chaining

  - ### setAspect

    public Camera setAspect(float aspect)

    Sets the viewport aspect ratio (width / height). The `RenderView` normally calls this from `Renderer.onResize`.

    ###### Parameters

    - `aspect`: the width / height ratio

    ###### Returns

    this camera for chaining

  - ### setPosition

    public Camera setPosition(float x, float y, float z)
    Sets the eye (camera) world position.

  - ### setTarget

    public Camera setTarget(float x, float y, float z)
    Sets the world space point the camera looks at.

  - ### setUp

    public Camera setUp(float x, float y, float z)
    Sets the camera up vector.

  - ### getEyeX

    public float getEyeX()
    Returns the eye (camera) world space x coordinate.

  - ### getEyeY

    public float getEyeY()
    Returns the eye (camera) world space y coordinate.

  - ### getEyeZ

    public float getEyeZ()
    Returns the eye (camera) world space z coordinate.

  - ### getViewMatrix

    public float[] getViewMatrix()
    Returns the 16 element column-major view matrix.

  - ### getProjectionMatrix

    public float[] getProjectionMatrix()
    Returns the 16 element column-major projection matrix.

  - ### getViewProjection

    public float[] getViewProjection()
    Returns the 16 element column-major combined projection * view matrix.