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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Returns the eye (camera) world space x coordinate.
    float
    Returns the eye (camera) world space y coordinate.
    float
    Returns the eye (camera) world space z coordinate.
    float[]
    Returns the 16 element column-major projection matrix.
    float[]
    Returns the 16 element column-major view matrix.
    float[]
    Returns the 16 element column-major combined projection * view matrix.
    setAspect(float aspect)
    Sets the viewport aspect ratio (width / height).
    setOrthographic(float height, float near, float far)
    Configures an orthographic projection.
    setPerspective(float fovYDegrees, float near, float far)
    Configures a perspective projection.
    setPosition(float x, float y, float z)
    Sets the eye (camera) world position.
    setTarget(float x, float y, float z)
    Sets the world space point the camera looks at.
    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.