Class Camera3D

java.lang.Object
arc.graphics.g3d.Camera3D

public class Camera3D extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final Mat3D
    the combined projection and view matrix
    final Vec3
    the unit length direction vector of the camera
    float
    the far clipping plane distance, has to be positive
    float
    field of view.
    final Frustum
    the frustum, for clipping operations
    float
    the viewport width and height
    final Mat3D
    the inverse combined projection and view matrix
    float
    the near clipping plane distance, has to be positive
    boolean
    if set to true, a perspective projection is used.
    final Vec3
    the position of the camera
    final Mat3D
    the projection matrix
    final Vec3
    the unit length up vector of the camera
    final Mat3D
    the view matrix
    float
    the viewport width and height
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
     
    getPickRay(float screenX, float screenY)
    Creates a picking Ray from the coordinates given in screen coordinates.
    getPickRay(float screenX, float screenY, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
    Creates a picking Ray from the coordinates given in screen coordinates.
    void
    lookAt(float x, float y, float z)
     
    void
    lookAt(Vec3 target)
    Recalculates the direction of the camera to look at the point (x, y, z).
    void
    Normalizes the up vector by first calculating the right vector via a cross product between direction and up, and then recalculating the up vector via a cross product between right and direction.
    project(Vec3 worldCoords)
    Projects the Vec3 given in world space to screen coordinates.
    project(Vec3 worldCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
    Projects the Vec3 given in world space to screen coordinates.
    void
    resize(float width, float height)
     
    unproject(Vec3 screenCoords)
    Function to translate a point given in screen coordinates to world space.
    unproject(Vec3 screenCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
    Function to translate a point given in screen coordinates to world space.
    void
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • fov

      public float fov
      field of view.
    • near

      public float near
      the near clipping plane distance, has to be positive
    • far

      public float far
      the far clipping plane distance, has to be positive
    • perspective

      public boolean perspective
      if set to true, a perspective projection is used.
    • width

      public float width
      the viewport width and height
    • height

      public float height
      the viewport width and height
    • position

      public final Vec3 position
      the position of the camera
    • direction

      public final Vec3 direction
      the unit length direction vector of the camera
    • up

      public final Vec3 up
      the unit length up vector of the camera
    • combined

      public final Mat3D combined
      the combined projection and view matrix
    • projection

      public final Mat3D projection
      the projection matrix
    • view

      public final Mat3D view
      the view matrix
    • invProjectionView

      public final Mat3D invProjectionView
      the inverse combined projection and view matrix
    • frustum

      public final Frustum frustum
      the frustum, for clipping operations
  • Constructor Details

    • Camera3D

      public Camera3D()
  • Method Details

    • update

      public void update()
    • resize

      public void resize(float width, float height)
    • lookAt

      public void lookAt(float x, float y, float z)
    • lookAt

      public void lookAt(Vec3 target)
      Recalculates the direction of the camera to look at the point (x, y, z).
      Parameters:
      target - the point to look at
    • normalizeUp

      public void normalizeUp()
      Normalizes the up vector by first calculating the right vector via a cross product between direction and up, and then recalculating the up vector via a cross product between right and direction.
    • unproject

      public Vec3 unproject(Vec3 screenCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
      Function to translate a point given in screen coordinates to world space. It's the same as GLU gluUnProject, but does not rely on OpenGL. The x- and y-coordinate of vec are assumed to be in screen coordinates (origin is the top left corner, y pointing down, x pointing to the right) as reported by the touch methods in Input. A z-coordinate of 0 will return a point on the near plane, a z-coordinate of 1 will return a point on the far plane. This method allows you to specify the viewport position and dimensions in the coordinate system expected by glViewport(int, int, int, int), with the origin in the bottom left corner of the screen.
      Parameters:
      screenCoords - the point in screen coordinates (origin top left)
      viewportX - the coordinate of the bottom left corner of the viewport in glViewport coordinates.
      viewportY - the coordinate of the bottom left corner of the viewport in glViewport coordinates.
      viewportWidth - the width of the viewport in pixels
      viewportHeight - the height of the viewport in pixels
      Returns:
      the mutated and unprojected screenCoords Vec3
    • unproject

      public Vec3 unproject(Vec3 screenCoords)
      Function to translate a point given in screen coordinates to world space. It's the same as GLU gluUnProject but does not rely on OpenGL. The viewport is assumed to span the whole screen and is fetched from Graphics.getWidth() and Graphics.getHeight(). The x- and y-coordinate of vec are assumed to be in screen coordinates (origin is the top left corner, y pointing down, x pointing to the right) as reported by the touch methods in Input. A z-coordinate of 0 will return a point on the near plane, a z-coordinate of 1 will return a point on the far plane.
      Parameters:
      screenCoords - the point in screen coordinates
      Returns:
      the mutated and unprojected screenCoords Vec3
    • project

      public Vec3 project(Vec3 worldCoords)
      Projects the Vec3 given in world space to screen coordinates. It's the same as GLU gluProject with one small deviation: The viewport is assumed to span the whole screen. The screen coordinate system has its origin in the bottom left, with the y-axis pointing upwards and the x-axis pointing to the right. This makes it easily useable in conjunction with Batch and similar classes.
      Returns:
      the mutated and projected worldCoords Vec3
    • project

      public Vec3 project(Vec3 worldCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
      Projects the Vec3 given in world space to screen coordinates. It's the same as GLU gluProject with one small deviation: The viewport is assumed to span the whole screen. The screen coordinate system has its origin in the bottom left, with the y-axis pointing upwards and the x-axis pointing to the right. This makes it easily useable in conjunction with Batch and similar classes. This method allows you to specify the viewport position and dimensions in the coordinate system expected by glViewport(int, int, int, int), with the origin in the bottom left corner of the screen.
      Parameters:
      viewportX - the coordinate of the bottom left corner of the viewport in glViewport coordinates.
      viewportY - the coordinate of the bottom left corner of the viewport in glViewport coordinates.
      viewportWidth - the width of the viewport in pixels
      viewportHeight - the height of the viewport in pixels
      Returns:
      the mutated and projected worldCoords Vec3
    • getMouseRay

      public Ray getMouseRay()
    • getPickRay

      public Ray getPickRay(float screenX, float screenY, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
      Creates a picking Ray from the coordinates given in screen coordinates. It is assumed that the viewport spans the whole screen. The screen coordinates origin is assumed to be in the top left corner, its y-axis pointing down, the x-axis pointing to the right. The returned instance is not a new instance but an internal member only accessible via this function.
      Parameters:
      viewportX - the coordinate of the bottom left corner of the viewport in glViewport coordinates.
      viewportY - the coordinate of the bottom left corner of the viewport in glViewport coordinates.
      viewportWidth - the width of the viewport in pixels
      viewportHeight - the height of the viewport in pixels
      Returns:
      the picking Ray.
    • getPickRay

      public Ray getPickRay(float screenX, float screenY)
      Creates a picking Ray from the coordinates given in screen coordinates. It is assumed that the viewport spans the whole screen. The screen coordinates origin is assumed to be in the top left corner, its y-axis pointing down, the x-axis pointing to the right. The returned instance is not a new instance but an internal member only accessible via this function.
      Returns:
      the picking Ray.