Package limn.render3d

Class Camera

java.lang.Object
limn.render3d.Camera

public final class Camera extends Object
A perspective camera positioned by eye/target/up. Mutable so controllers (orbit/fly) can move it; the aspect ratio is supplied at render time from the target's dimensions.

Right-handed, looking down −Z in view space. Distances are in scene units and angles in radians. The setters chain and mutate in place; a camera handed to a controller is the same object the renderer reads.

  • Constructor Details

    • Camera

      public Camera()
  • Method Details

    • eye

      public Vec3 eye()
      Where the camera is.
    • eye

      public Camera eye(Vec3 eye)
      Moves the camera without changing what it looks at.
    • target

      public Vec3 target()
      The point the camera looks at.
    • target

      public Camera target(Vec3 target)
      Aims the camera at a point, keeping its position.
    • up

      public Vec3 up()
      The world-space up hint that fixes roll.
    • up

      public Camera up(Vec3 up)
      Sets the up hint. Must not be parallel to the eye-to-target direction, which would leave the view basis degenerate.
    • fovyRadians

      public float fovyRadians()
      Vertical field of view, in radians.
    • fovy

      public Camera fovy(float radians)
      Sets the vertical field of view in radians; the horizontal one follows the aspect.
    • near

      public float near()
      Near clip distance, in scene units.
    • far

      public float far()
      Far clip distance, in scene units.
    • clip

      public Camera clip(float near, float far)
      Sets the clip range. Depth precision comes from the ratio far/near, so a near plane far smaller than the scene needs is what causes z-fighting, not a large far plane.
    • view

      public Mat4 view()
      The world-to-view matrix for the current eye, target and up.
    • projection

      public Mat4 projection(float aspect)
      The projection matrix for a viewport of the given width/height ratio.
    • viewProjection

      public Mat4 viewProjection(float aspect)
      projection(float) times view(), which is what a shader usually wants.