Interface DepthGraphics

  • All Known Implementing Classes:
    RasterDepthGraphics

    public interface DepthGraphics
    This is a simple 3D graphics library, without texture mapping, which used to run on Java version 1.0.

    The z parameters in methods on this interface are meant to distinguish objects that are in front from objects that are in back (i.e. "hidden feature removal"). However, the graphics context which this interface renders into must be thought of as a 2D canvas, where all x and y parameters in methods represent locations on that 2D canvas, regarless of the values of any z parameters. In a sense, the x, y, and z parameters can be thought of as points in 3D space, and when objects are rendered onto the imaginary 2D canvas (which is a plane perpendicular to the z axis), these 3D points undergo a parallel projection onto the 2D canvas, where the axis of projection is the z axis. The z values only serve to define what is in front and what is in back. Larger z values mean closer; a smaller z value is in back of a larger one. If an obect B lies completely behind an object A and if both A and B are drawn, then only object A will be visible after both are drawn regardless of the order in which A and B were drawn.

    For drawing points, drawing lines, and filling polygons, how non-opaque colors are handled is up to the implementation of this interface.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void clear​(FloatColor color)
      Paints the current clip area.
      void drawLine​(double x0, double y0, double z0, double x1, double y1, double z1, FloatColor color)
      Draws a line of constant color.
      void drawLine​(double x0, double y0, double z0, FloatColor color0, double x1, double y1, double z1, FloatColor color1)
      Draws a line of varying color.
      void drawPoint​(double x, double y, double z, FloatColor color, double[] normal)
      The normal, which is a vector in 3-space, defines the surface on which the point is located, for purposes of computing the correct z value at exactly the sampling point, so that drawing a point after a polygon (for example) would cause the point to appear.
      void fillPolygon​(double[] xPts, double[] yPts, double[] zPts, int offset, int numPts, FloatColor color)
      Fills a polygon of constant color.
      void fillPolygon​(double[] xPts, double[] yPts, double[] zPts, FloatColor[] colors, int offset, int numPts)
      Fills a polygon of varying color.
      ClipRectangle getClip()
      The return value is intended to convey information and should not be modified as part of an attempt to adjust the clipping area.
      void setClip​(ClipRectangle clip)
      The clip determines how much of an object [to be rendered] is visible.
    • Method Detail

      • drawPoint

        void drawPoint​(double x,
                       double y,
                       double z,
                       FloatColor color,
                       double[] normal)
        The normal, which is a vector in 3-space, defines the surface on which the point is located, for purposes of computing the correct z value at exactly the sampling point, so that drawing a point after a polygon (for example) would cause the point to appear. This array may be null, in which case normal is implied to be the unit vector pointing in the positive z direction.
      • drawLine

        void drawLine​(double x0,
                      double y0,
                      double z0,
                      FloatColor color0,
                      double x1,
                      double y1,
                      double z1,
                      FloatColor color1)
        Draws a line of varying color. The color of a point on the line will be determined by interpolating the colors of the line's endpoints in some reasonable manner.
      • drawLine

        void drawLine​(double x0,
                      double y0,
                      double z0,
                      double x1,
                      double y1,
                      double z1,
                      FloatColor color)
        Draws a line of constant color.
      • fillPolygon

        void fillPolygon​(double[] xPts,
                         double[] yPts,
                         double[] zPts,
                         FloatColor[] colors,
                         int offset,
                         int numPts)
        Fills a polygon of varying color. The color of a point on the polygon will be determined by interpolating the colors of the polygon's vertices.

        If a polygon contains more than three vertices, then those vertices should lie on the same physical plane and on the same color plane. If this isn't the case then the definition of color and distance from camera may not be uniquely defined.

        The interior of a polygon may be defined in different ways for self-intersecting polygons; for example, an even-odd rule or a non-zero-winding-number rule may be used to define the interior of a self-intersecting polygon.

      • fillPolygon

        void fillPolygon​(double[] xPts,
                         double[] yPts,
                         double[] zPts,
                         int offset,
                         int numPts,
                         FloatColor color)
        Fills a polygon of constant color.
      • setClip

        void setClip​(ClipRectangle clip)
        The clip determines how much of an object [to be rendered] is visible. The clip does not necessarily force objects to be clipped against it before they are rendered; rather, you can think of objects being rendered onto an infinite [blank] canvas, and then the clip would be applied to the canvas to determine how much of the object is visible; the visible portion would then be actually painted. This principle is important for objects such as lines, for example, which are represented by an infinitely thin line but may, when rendered, have some thickness.
      • getClip

        ClipRectangle getClip()
        The return value is intended to convey information and should not be modified as part of an attempt to adjust the clipping area.
      • clear

        void clear​(FloatColor color)
        Paints the current clip area. All z-information for objects previously rendered within this clip area will be reset. clear() is required to clobber all visual information in the current clip; transparent or translucent colors should not be handled in a special way.