Package graphics

Class Camera

java.lang.Object
graphics.Camera

public class Camera extends Object

Azurite

Represents a basic camera. The purpose of a digital camera capturing a digital point of view is to translate the 3D locations in game onto the 2 dimensions of your monitor (if you come from the future with holograms in it, Hi! welcome to the past!) The camera does so by way of linear algebra; points in 3D space can be projected onto a 2D plane using matrix transformations.

Specifically, the digital camera used in this engine is composed of two matrices: the projection and the view matrices. The projection matrix is used to define an in game width and height to your perspective by defining how many in-game coordinate units can be seen horizontally and vertically on your monitor. The view matrix defines the direction and orientation of the camera; it's usually the matrix defined in terms of camera position, pitch, and yaw.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    org.joml.Vector2f
    Position of the camera
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new Camera positioned at (0, 0) Projection matrix is set to default: 0 to Window's width from left to right, 0 to Window's height from top to bottom
    Camera(org.joml.Vector2f position)
    Creates a new Camera with a certain position Projection matrix is set to default: 0 to Window's width from left to right, 0 to Window's height from top to bottom
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Recalculate Projection Matrix
    org.joml.Vector2f
    Get the camera's position
    org.joml.Matrix4f
    Get the camera's projection matrix
    org.joml.Matrix4f
    Recalculates and returns the view marix
    void
    smoothFollow(org.joml.Vector2f c)
    Smoothly center the camera on to a transform

    Methods inherited from class java.lang.Object

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

    • position

      public org.joml.Vector2f position
      Position of the camera
  • Constructor Details

    • Camera

      public Camera(org.joml.Vector2f position)
      Creates a new Camera with a certain position Projection matrix is set to default: 0 to Window's width from left to right, 0 to Window's height from top to bottom
      Parameters:
      position - initial position
    • Camera

      public Camera()
      Creates a new Camera positioned at (0, 0) Projection matrix is set to default: 0 to Window's width from left to right, 0 to Window's height from top to bottom
  • Method Details

    • adjustProjection

      public void adjustProjection()
      Recalculate Projection Matrix
    • getViewMatrix

      public org.joml.Matrix4f getViewMatrix()
      Recalculates and returns the view marix
    • getProjectionMatrix

      public org.joml.Matrix4f getProjectionMatrix()
      Get the camera's projection matrix
    • smoothFollow

      public void smoothFollow(org.joml.Vector2f c)
      Smoothly center the camera on to a transform
    • getPosition

      public org.joml.Vector2f getPosition()
      Get the camera's position