001/*
002
003*/
004
005package renderer.scene;
006
007/**
008   This {@code Camera} data structure represents a camera
009   located at the origin, looking down the negative z-axis.
010<p>
011   This camera has associated to it a "view volume" that
012   determines what part of space the camera "sees" when
013   we use the camera to take a picture (that is, when we
014   render a {@link Scene}).
015<p>
016   This camera can "take a picture" two ways, using a
017   perspective projection or a parallel (orthographic)
018   projection. Each way of taking a picture has a different
019   shape for its view volume.
020<p>
021   For the perspective projection, the view volume is an
022   infinitely long pyramid that is formed by the pyramid
023   with its apex at the origin and its base in the plane
024   {@code z = -1} with edges {@code x = -1}, {@code x = +1},
025   {@code y = -1}, and {@code y = +1}.
026<p>
027   For the orthographic projection, the view volume is an
028   infinitely long rectangular cylinder parallel to the
029   z-axis and with sides {@code x = -1}, {@code x = +1},
030   {@code y = -1}, and {@code y = +1} (an infinite parallelepiped).
031<p>
032   When the graphics rendering {@link renderer.pipeline.Pipeline} uses
033   this Camera to render a Scene, the renderer "sees" the geometry from
034   the scene that is contained in this camera's view volume. (Notice
035   that this means the orthographic camera will see geometry that
036   is behind the camera. In fact, the perspective camera also sees
037   geometry that is behind the camera.) The renderer's
038   {@link renderer.pipeline.Clip} pipeline stage is responsible for
039   making sure that the scene's geometry that is outside of this
040   camera's view volume is not visible.
041<p>
042   The plane {@code z = -1} is the camera's image plane. The
043   rectangle in the image plane with corners {@code (-1, -1, -1)}
044   and {@code (+1, +1, -1)} is the camera's view rectangle. The
045   view rectangle is like the film in a real camera, it is where
046   the camera's image appears when you take a picture. The contents
047   of the camera's view rectangle is what gets rasterized, by the
048   renderer's {@link renderer.pipeline.Viewport} and
049   {@link renderer.pipeline.Rasterize}
050   pipeline stages, into a {@link renderer.framebuffer.FrameBuffer}.
051*/
052public class Camera
053{
054   // Choose either perspective or parallel projection.
055   public boolean perspective;
056
057   /**
058      The default {@code Camera} uses perspective projection.
059   */
060   public Camera()
061   {
062      this.perspective = true;
063   }
064
065
066   /**
067      Set up this camera's view volume as a perspective projection
068      of an infinite view pyramid extending along the negative z-axis.
069   */
070   public void projPerspective()
071   {
072      this.perspective = true;
073   }
074
075
076   /**
077      Set up this {@code Camera}'s view volume as a parallel (orthographic)
078      projection of an infinite view parallelepiped.
079   */
080   public void projOrtho()
081   {
082      this.perspective = false;
083   }
084
085
086   /**
087      For debugging.
088
089      @return {@link String} representation of this {@code Camera} object
090   */
091   @Override
092   public String toString()
093   {
094      String result = "";
095      result += "Camera: \n";
096      result += "perspective = " + perspective + "\n";
097      return result;
098   }
099}