Class Camera

java.lang.Object
com.ijurnove.cpu3d.Camera
All Implemented Interfaces:
Rotatable, Scalable, Translatable

public class Camera extends Object implements Translatable, Rotatable, Scalable
Camera objects define a viewpoint from which a Scene can be rendered.
  • Constructor Details

    • Camera

      protected Camera(Scene parent, Point3d pos, double phi, double theta, double fov)
    • Camera

      public Camera(Point3d pos, double phi, double theta, double fov)
      Constructs a Camera with specified pos, phi, theta, and FOV.
      Parameters:
      pos - the starting position
      phi - vertical rotation, in radians
      theta - horizontal rotation, in radians
      fov - field of view
  • Method Details

    • getPos

      public Point3d getPos()
      Returns the position.
      Returns:
      the position of this Camera
    • getPhi

      public double getPhi()
      Returns the vertical rotation, in radians.
      Returns:
      the vertical rotation of this Camera
    • getTheta

      public double getTheta()
      Returns the horizontal rotation, in radians.
      Returns:
      the horizontal rotation of this Camera
    • getFov

      public double getFov()
      Returns the field of view.
      Returns:
      the field of view of this Camera
    • getParent

      public Scene getParent()
      Returns the parent Scene.
      Returns:
      the parent Scene of this Camera
    • getVertRotMatrix

      protected Matrix getVertRotMatrix()
    • getHorRotMatrix

      protected Matrix getHorRotMatrix()
    • getPosOffsetMatrix

      protected Matrix getPosOffsetMatrix()
    • getOrthoMatrix

      protected Matrix getOrthoMatrix()
    • getPosMatrix

      protected Matrix getPosMatrix()
    • setPhi

      public void setPhi(double phi)
      Sets the vertical rotation. (In radians)
      Parameters:
      phi - the vertical rotation to set, in radians
    • setTheta

      public void setTheta(double theta)
      Sets the horizontal rotation. (In radians)
      Parameters:
      theta - the horizontal rotation to set, in radians
    • setParent

      public void setParent(Scene parent)
      Sets the parent Scene.
      Parameters:
      parent - the scene to set
    • setFOV

      public void setFOV(double fov)
      Sets the field of view.
      Parameters:
      fov - the field of view to set
    • setPos

      public void setPos(Point3d pos)
      Sets the position.
      Parameters:
      pos - the position to set
    • lineOfSight

      public Vector3d lineOfSight()
      Returns the direction the Camera is looking as a Vector3d.
      Returns:
      the direction the Camera is looking
    • updateLineOfSight

      protected void updateLineOfSight()
    • updateOrthoMatrix

      protected void updateOrthoMatrix(double l, double r, double b, double t, double n, double f)
    • tick

      protected void tick()
    • lookAtWithLineOfSight

      protected Matrix lookAtWithLineOfSight()
    • lookAtMatrixToOrigin

      protected Matrix lookAtMatrixToOrigin()
    • inputTick

      public void inputTick()
    • translate

      public void translate(double x, double y, double z)
      Description copied from interface: Translatable
      Shifts this object's X, Y, and Z position by the given values.
      Specified by:
      translate in interface Translatable
      Parameters:
      x - how far the object should be translated along the X axis
      y - how far the object should be translated along the Y axis
      z - how far the object should be translated along the Z axis
    • rotate

      public void rotate(int axis, double theta, Point3d point)
      Description copied from interface: Rotatable
      Rotates this object about a given point on a specified axis. 0 corresponds to the X axis, 1 corresponds to the Y axis, and 2 corresponds to the Z axis.
      Specified by:
      rotate in interface Rotatable
      Parameters:
      axis - the axis to rotate around
      theta - the radians to rotate by
      point - the center point to rotate around
    • scale

      public void scale(double size, Point3d point)
      Description copied from interface: Scalable
      Scales this object by a given amount from a point.
      Specified by:
      scale in interface Scalable
      Parameters:
      size - the scale multiplier
      point - the point that this object should be scaled from