Package arc.graphics

Class Camera

java.lang.Object
arc.graphics.Camera

public class Camera extends Object
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    float
    the viewport width and height
    final Mat
    the inverse view matrix
    final Mat
    the view matrix
    final Vec2
    the position of the camera
    float
    the viewport width and height
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    bounds(Rect out)
    Sets the specified rectangle to this camera's bounds.
    project(float screenX, float screenY)
    project(Vec2 worldCoords)
    Projects the Vec3 given in world space to screen coordinates.
    project(Vec2 worldCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
    Projects the Vec3 given in world space to screen coordinates.
    void
    resize(float viewportWidth, float viewportHeight)
     
    unproject(float screenX, float screenY)
    unproject(Vec2 screenCoords)
    Function to translate a point given in screen coordinates to world space.
    unproject(Vec2 screenCoords, float viewportX, float viewportY, float viewportWidth, float viewportHeight)
    Function to translate a point given in screen coordinates to world space.
    void
    Recalculates the projection and view matrix of this camera.

    Methods inherited from class java.lang.Object

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

    • position

      public final Vec2 position
      the position of the camera
    • mat

      public final Mat mat
      the view matrix
    • inv

      public final Mat inv
      the inverse view matrix
    • width

      public float width
      the viewport width and height
    • height

      public float height
      the viewport width and height
  • Constructor Details

    • Camera

      public Camera()
  • Method Details

    • update

      public void update()
      Recalculates the projection and view matrix of this camera. Use this after you've manipulated any of the attributes of the camera.
    • resize

      public void resize(float viewportWidth, float viewportHeight)
    • unproject

      public Vec2 unproject(Vec2 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 bottom left corner, y pointing up, 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 GL20.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 Vec2 unproject(Vec2 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 bottom left corner, y pointing up, 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
    • unproject

      public Vec2 unproject(float screenX, float screenY)
      See unproject(Vec2). Returns the same Vec2 each time.
    • project

      public Vec2 project(Vec2 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.
      Returns:
      the mutated and projected worldCoords Vec3
    • project

      public Vec2 project(float screenX, float screenY)
      See project(Vec2). Returns the same Vec2 each time.
    • project

      public Vec2 project(Vec2 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 method allows you to specify the viewport position and dimensions in the coordinate system expected by GL20.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
    • bounds

      public Rect bounds(Rect out)
      Sets the specified rectangle to this camera's bounds.