Package org.bzdev.p3d

Class Model3D.Image

java.lang.Object
org.bzdev.p3d.Model3D.Image
All Implemented Interfaces:
GraphicsCreator, Model3D.ImageData
Enclosing class:
Model3D

public static class Model3D.Image extends Object implements GraphicsCreator, Model3D.ImageData
Image for a 3D model. While the p3d package can create images of 3D models, these images are intended primarily for debugging. For example, it can show the interior of a surface in a different color than the exterior, which is useful in finding errors in a model. For high quality images, one should consider creating an STL or X3D file and importing it into programs designed to display 3D models—these can take advantage of graphics processors. and will produce more realistic images.

The constructors are the same as those for the BufferedImage class, with there additional constructors that can use a GraphCreator, Graph or OSGraphicsOps instead of an internal buffered image. The class Animation2D implements GraphCreator, whereas the classes OutputStreamGraphics and PanelGraphics implement OSGraphicsOps.

After creating an instance of this class, one will configure parameters for rendering: please see Model3D.ImageData for details. For the simplest case, one will use Model3D.ImageData.setCoordRotation(double,double,double) and one of the Model3D methods Model3D.setImageParameters(Model3D.ImageData), Model3D.setImageParameters(Model3D.ImageData,double), Model3D.setImageParameters(Model3D.ImageData,double,double), Model3D.setImageParameters(Model3D.ImageData,double,double,double), Model3D.setImageParameters(Model3D.ImageData,double,double,double,double), or Model3D.setImageParameters(Model3D.ImageData,double,double,double,double,boolean) to complete the configuration.

To render the image, one will use the Model3D method Model3D.render(Model3D.Image) (several variants of this method are available for more complex cases such as rendering images from multiple models).

Finally, to write the image to a file or stream, one will use the method write(String,String), write(String, File), write(String, FileAccessor), write(String, OutputStream), or write().

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Image(int width, int height, int imageType)
    Constructor.
    Image(int width, int height, int imageType, IndexColorModel cm)
    Constructor given an index color model.
    Image(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties)
    Constructor given a color model.
    ` Constructor specifying an OSGraphicsOps.
    Image(Graph graph)
    Constructor given a Graph.
    Constructor given a graph creator.
  • Method Summary

    Modifier and Type
    Method
    Description
    Create a graphics context.
    Get the color for the the side of a triangle that should not be visible due to being on the inside of a closed manifold.
    double
    Get the color factor.
    Get the default backside color to use for line segments associated with triangles added for rendering.
    Get the color to use for line segments explicitly added or associated with triangles added for rendering.
    double
    Get the minimum triangle size for rendering.
    Get the color used to indicate the edges of a triangle
    float
    Get the height of an image.
    float
    Get the width of an image .
    int
    Get the height of an image as an integer.
    Get the corresponding ImageDataImpl.
    double
    Get the light-source parameter phi.
    double
    Get the light-source parameter theta.
    double
    Get the normal factor After a coordinate transformation, the normal factor is used to reduce the color factor towards 0.0 when a surface segment' is not aligned with the Z axis.
    double
    Get the Eulerian angle phi for a coordinate rotation.
    double
    Get the Eulerian angle psi for a coordinate rotation.
    double
    Get the X coordinate of the origin/target point for a coordinate rotation.
    double
    Get the Y coordinate of the origin/target point for a coordinate rotation.
    double
    Get the Z coordinate of the origin/target point for a coordinate rotation.
    double
    Set the scale factor.
    double
    Get the Eulerian angle theta for a coordinate rotation.
    int
    Get the width of an image as an integer.
    float
    Get the X coordinate of the origin.
    double
    Get the coordinate translation in the X direction that will be applied after other coordinate transformations are completed.
    float
    Get the Y coordinate of the origin Note that user space follows the standard Java convention in which increasing X values go 'right' on an image and increasing Y values do 'down'.
    double
    Get the coordinate translation in the Y direction that will be applied after other coordinate transformations are completed.
    boolean
    Determine if the transformed origin for (0,0,0) will be moved to the coordinate origin after the rotation is completed.
    void
    Reset to default values.
    void
    Set the color for the side of a triangle that should not be visible due to being on the inside of a closed manifold.
    void
    setColorFactor(double factor)
    Set the color factor.
    void
    setCoordRotation(double phi, double theta, double psi)
    Rotate the Model3D coordinates.
    void
    Set the default backside color to use for line segments associated with triangles added for rendering.
    void
    Set the color to use for line segments explicitly added or associated with triangles added for rendering.
    void
    setDelta(double delta)
    Set the minimum triangle size for rendering.
    void
    Set the color to use to use to draw the edges of triangles.
    void
    setLightSource(double phi, double theta)
    Sets the direction to a light source.
    void
    setNormalFactor(double factor)
    Set the normal factor.
    void
    Set the origin to a default value.
    void
    setOrigin(double offset)
    Set the origin given a double-precision offset.
    void
    setOrigin(double x, double y)
    Set the origin give double-precision coordinates The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0.
    void
    setOrigin(float offset)
    Set the origin given an offset.
    void
    setOrigin(float x, float y)
    Set the origin given floating-point coordinates.
    void
    setOrigin(int offset)
    Set the origin given an integer offset.
    void
    setOrigin(int x, int y)
    Set the origin given integer coordinates.
    void
    setOriginByFraction(double offset)
    Set the origin given a double-precision fractional offset.
    void
    setOriginByFraction(float offset)
    Set the origin given a single-precision fractional offset.
    void
    setRotationOrigin(double x, double y, double z)
    Move the rotation origin for a coordinate rotation.
    void
    setRotationOrigin(double x, double y, double z, boolean move)
    Move the rotation origin for a coordinate rotation with options.
    void
    setScaleFactor(double scaleFactor)
    Set the scale factor.
    void
    setTranslation(double x, double y)
    Specify translation after coordinate changes.
    void
    Write the image to its OutputStreamGraphics.
    void
    write(String type, File file)
    Write the image to a file.
    void
    Write the image to an output stream.
    void
    write(String type, String name)
    Write the image to a file given a file name.
    void
    Write the image to a file provided by a file accessor.

    Methods inherited from class java.lang.Object

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

    • Image

      public Image(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties)
      Constructor given a color model.
      Parameters:
      cm - the color model for the image
      raster - the Raster for the data representing the image
      isRasterPremultiplied - if true, the data in the raster has been premultiplied with alpha
      properties - a Hashtable of String/Object pairs
      See Also:
    • Image

      public Image(int width, int height, int imageType)
      Constructor. The predefined image types are the same as for BufferedImage
      Parameters:
      width - the width of the image
      height - the height of the image
      imageType - the image type
      See Also:
    • Image

      public Image(int width, int height, int imageType, IndexColorModel cm)
      Constructor given an index color model.
      Parameters:
      width - the width of the image
      height - the height of the image
      imageType - the image type, restricted to either TYPE_BYTE_BINARY or TYPE_BYTE_INDEXED
      cm - the IndexColorModel to use
      See Also:
    • Image

      public Image(OSGraphicsOps osg)
      ` Constructor specifying an OSGraphicsOps.
      Parameters:
      osg - the OSGraphicsOps to be used to create an image
    • Image

      public Image(GraphCreator gc2d)
      Constructor given a graph creator. The interface GraphCreator is implemented by Animation2D, which may construct its graph after this Constructor is called.
      Parameters:
      gc2d - the object that will create a graph used by this object to provide a buffered image or graphics output stream
    • Image

      public Image(Graph graph)
      Constructor given a Graph. The image created will share the graph's buffered image or output-stream graphics.
      Parameters:
      graph - an instance of Graph
  • Method Details

    • createGraphics

      public Graphics2D createGraphics()
      Description copied from interface: GraphicsCreator
      Create a graphics context.
      Specified by:
      createGraphics in interface GraphicsCreator
      Returns:
      the graphics context
    • getImageData

      public Model3D.ImageDataImpl getImageData()
      Description copied from interface: Model3D.ImageData
      Get the corresponding ImageDataImpl.
      Specified by:
      getImageData in interface Model3D.ImageData
      Returns:
      the corresponding ImageDataImpl
    • getWidth

      public int getWidth()
      Description copied from interface: Model3D.ImageData
      Get the width of an image as an integer.
      Specified by:
      getWidth in interface Model3D.ImageData
      Returns:
      the width of the image
    • getHeight

      public int getHeight()
      Description copied from interface: Model3D.ImageData
      Get the height of an image as an integer.
      Specified by:
      getHeight in interface Model3D.ImageData
      Returns:
      the height of the image
    • getFloatWidth

      public float getFloatWidth()
      Description copied from interface: Model3D.ImageData
      Get the width of an image .
      Specified by:
      getFloatWidth in interface Model3D.ImageData
      Returns:
      the width in image user-space coordinates
    • getFloatHeight

      public float getFloatHeight()
      Description copied from interface: Model3D.ImageData
      Get the height of an image.
      Specified by:
      getFloatHeight in interface Model3D.ImageData
      Returns:
      the height in user-space coordinates
    • getScaleFactor

      public double getScaleFactor()
      Description copied from interface: Model3D.ImageData
      Set the scale factor. A rendered model will be scaled by this amount. When the scale factor is 1.0, a unit distance in the model is a unit distance in the image's user space (e.g. 1/72 of an inch on a display). The scale factor is applied after any rotation or translation. The coordinate whose post-rotation and post-translation value is (0.0, 0.0, 0.0) will appear at the image's origin after scaling.
      Specified by:
      getScaleFactor in interface Model3D.ImageData
      Returns:
      the scale factor
    • setScaleFactor

      public void setScaleFactor(double scaleFactor)
      Description copied from interface: Model3D.ImageData
      Set the scale factor. A rendered model will be scaled by this amount. When the scale factor is 1.0, a unit distance in the model is a unit distance in the image's user space (e.g. 1/72 of an inch on a display). The scale factor is applied after any rotation or translation. The coordinate whose post-rotation and post-translation value is (0.0, 0.0, 0.0) will appear at the image's origin after scaling.
      Specified by:
      setScaleFactor in interface Model3D.ImageData
      Parameters:
      scaleFactor - the scale factor
    • getXOrigin

      public float getXOrigin()
      Description copied from interface: Model3D.ImageData
      Get the X coordinate of the origin. The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. Note that user space follows the standard Java convention in which increasing X values go 'right' on an image and increasing Y values do 'down'.
      Specified by:
      getXOrigin in interface Model3D.ImageData
      Returns:
      the X coordinate of the origin in the image's user space
    • getYOrigin

      public float getYOrigin()
      Description copied from interface: Model3D.ImageData
      Get the Y coordinate of the origin Note that user space follows the standard Java convention in which increasing X values go 'right' on an image and increasing Y values do 'down'.
      Specified by:
      getYOrigin in interface Model3D.ImageData
      Returns:
      the Y coordinate of the origin in the image's user space
    • setOrigin

      public void setOrigin(int x, int y)
      Description copied from interface: Model3D.ImageData
      Set the origin given integer coordinates. The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. Note that user space follows the standard Java convention in which increasing X values go 'right' on an image and increasing Y values do 'down'.
      Specified by:
      setOrigin in interface Model3D.ImageData
      Parameters:
      x - the X coordinate in the image's user space
      y - the Y coordinate in the image's user space
    • setOrigin

      public void setOrigin(double x, double y)
      Description copied from interface: Model3D.ImageData
      Set the origin give double-precision coordinates The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. Note that user space follows the standard Java convention in which increasing X values go 'right' on an image and increasing Y values do 'down'.
      Specified by:
      setOrigin in interface Model3D.ImageData
      Parameters:
      x - the X coordinate in the image's user space
      y - the Y coordinate in the image's user space
    • setOrigin

      public void setOrigin(float x, float y)
      Description copied from interface: Model3D.ImageData
      Set the origin given floating-point coordinates. The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. Note that user space follows the standard Java convention in which increasing X values go 'right' on an image and increasing Y values do 'down'.
      Specified by:
      setOrigin in interface Model3D.ImageData
      Parameters:
      x - the user-space x-coordinate of the origin
      y - the user-space y-coordinate of the origin
    • setOrigin

      public void setOrigin(int offset)
      Description copied from interface: Model3D.ImageData
      Set the origin given an integer offset. The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. When the offset is non-negative, the offset gives the distance in user-space coordinates, for both the x coordinate and the y coordinate, from the lower left corner of the image to the position of the origin. When negative, the absolute value gives the distances from the upper right corner of the image.
      Specified by:
      setOrigin in interface Model3D.ImageData
      Parameters:
      offset - the offset
    • setOrigin

      public void setOrigin(double offset)
      Description copied from interface: Model3D.ImageData
      Set the origin given a double-precision offset. The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. When the offset is non-negative, the offset gives the distance in user-space coordinates, for both the x coordinate and the y coordinate, from the lower left corner of the image to the position of the origin. When negative, the absolute value gives the distances from the upper right corner of the image.
      Specified by:
      setOrigin in interface Model3D.ImageData
      Parameters:
      offset - the offset
    • setOrigin

      public void setOrigin(float offset)
      Description copied from interface: Model3D.ImageData
      Set the origin given an offset. The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. When the offset is non-negative, the offset gives the distance in user-space coordinates, for both the x coordinate and the y coordinate, from the lower left corner of the image to the position of the origin. When negative, the absolute value gives the distances from the upper right corner of the image.
      Specified by:
      setOrigin in interface Model3D.ImageData
      Parameters:
      offset - the offset
    • setOriginByFraction

      public void setOriginByFraction(double offset)
      Description copied from interface: Model3D.ImageData
      Set the origin given a double-precision fractional offset. The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. The fractional offset sets the offset to the value of offset multiplied by the width and height for the x coordinate and y coordinate respectively. If the offset is positive, the offset is from the lower-left corner of an image. If negative, the offset is from the upper right corner.
      Specified by:
      setOriginByFraction in interface Model3D.ImageData
      Parameters:
      offset - the fractional offset in the range (-1.0, 1.0)
    • setOriginByFraction

      public void setOriginByFraction(float offset)
      Description copied from interface: Model3D.ImageData
      Set the origin given a single-precision fractional offset. The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. The fractional offset sets the offset to the value of offset multiplied by the width and height for the x coordinate and y coordinate respectively. If the offset is positive, the offset is from the lower-left corner of an image. If negative, the offset is from the upper right corner.
      Specified by:
      setOriginByFraction in interface Model3D.ImageData
      Parameters:
      offset - the fractional offset in the range (-1.0, 1.0)
    • setOrigin

      public void setOrigin()
      Description copied from interface: Model3D.ImageData
      Set the origin to a default value. The origin is the point on the image that will correspond to points in the model for which x = 0.0 and y = 0.0. The default will place the origin in the center of an image.
      Specified by:
      setOrigin in interface Model3D.ImageData
    • getPhi

      public double getPhi()
      Description copied from interface: Model3D.ImageData
      Get the Eulerian angle phi for a coordinate rotation. A coordinate rotation and translation refers to a new position and orientation of the coordinate system assuming the model is held stationary. The model will appear to rotate and translate in the opposite direction from that specified by these Eulerian angles.
      Specified by:
      getPhi in interface Model3D.ImageData
      Returns:
      the value of phi in radians
      See Also:
    • getTheta

      public double getTheta()
      Description copied from interface: Model3D.ImageData
      Get the Eulerian angle theta for a coordinate rotation. A coordinate rotation and translation refers to a new position and orientation of the coordinate system assuming the model is held stationary. The model will appear to rotate and translate in the opposite direction from that specified by these Eulerian angles.
      Specified by:
      getTheta in interface Model3D.ImageData
      Returns:
      the value of theta in radians
      See Also:
    • getPsi

      public double getPsi()
      Description copied from interface: Model3D.ImageData
      Get the Eulerian angle psi for a coordinate rotation. A coordinate rotation and translation refers to a new position and orientation of the coordinate system assuming the model is held stationary. The model will appear to rotate and translate in the opposite direction from that specified by these Eulerian angles.
      Specified by:
      getPsi in interface Model3D.ImageData
      Returns:
      the value of psi in radians
      See Also:
    • setCoordRotation

      public void setCoordRotation(double phi, double theta, double psi)
      Description copied from interface: Model3D.ImageData
      Rotate the Model3D coordinates. When all values are zero, the original z axis is perpendicular to an image, the original x axis is horizontal, and the original y axis is vertical, all following the standard mathematical convention that the x axis goes from left to right, the y axis goes from bottom to top. The z axis points towards the viewer.

      The Eulerian angles follow the convention used in Goldstein, "Classical Mechanics": phi is the angle the x-axis rotates with positive values of phi indicating a counter-clockwise rotation when viewed from positive values of z towards the plane in which z=0. Theta then indicates a rotation about the new x axis, and psi indicates a rotation about the final z axis.

      Note that the coordinate system is being rotated, not the object being displayed, and that the rotation applies from the original axes, as opposed to being applied incrementally.

      Specified by:
      setCoordRotation in interface Model3D.ImageData
      Parameters:
      phi - the Eulerian angle phi in radians
      theta - the Eulerian angle theta in radians
      psi - the Eulerian angle psi in radians
    • getRotationXOrigin

      public double getRotationXOrigin()
      Description copied from interface: Model3D.ImageData
      Get the X coordinate of the origin/target point for a coordinate rotation. This is the first argument to the most recent call to Model3D.ImageData.setRotationOrigin(double,double,double) or Model3D.ImageData.setRotationOrigin(double,double,double,boolean).
      Specified by:
      getRotationXOrigin in interface Model3D.ImageData
      Returns:
      the X coordinate in the model's coordinate system
    • getRotationYOrigin

      public double getRotationYOrigin()
      Description copied from interface: Model3D.ImageData
      Get the Y coordinate of the origin/target point for a coordinate rotation. This is the first argument to the most recent call to Model3D.ImageData.setRotationOrigin(double,double,double) or Model3D.ImageData.setRotationOrigin(double,double,double,boolean).
      Specified by:
      getRotationYOrigin in interface Model3D.ImageData
      Returns:
      the Y coordinate in the model's coordinate system
    • getRotationZOrigin

      public double getRotationZOrigin()
      Description copied from interface: Model3D.ImageData
      Get the Z coordinate of the origin/target point for a coordinate rotation. This is the second argument to the most recent call to Model3D.ImageData.setRotationOrigin(double,double,double) or Model3D.ImageData.setRotationOrigin(double,double,double,boolean).
      Specified by:
      getRotationZOrigin in interface Model3D.ImageData
      Returns:
      the Z coordinate in the model's coordinate system
    • moveOriginAfterRotation

      public boolean moveOriginAfterRotation()
      Description copied from interface: Model3D.ImageData
      Determine if the transformed origin for (0,0,0) will be moved to the coordinate origin after the rotation is completed. This is the value of the last argument to the most recent call to Model3D.ImageData.setRotationOrigin(double,double,double,boolean), which is also called by the three-argument method Model3D.ImageData.setRotationOrigin(double,double,double) with a final argument of false. When false, the rotation occurs about a specified point. When true, the rotation in effect occurs around (0, 0, 0) and then (0, 0, 0) is moved to the rotation origin.
      Specified by:
      moveOriginAfterRotation in interface Model3D.ImageData
      Returns:
      true if it will be moved; false if not
      See Also:
    • setRotationOrigin

      public void setRotationOrigin(double x, double y, double z)
      Description copied from interface: Model3D.ImageData
      Move the rotation origin for a coordinate rotation. The default performs a coordinate rotation about the point (0,0,0). For another value, the point (x, y, z) before the rotation will have the same value in the new coordinate system: (x,y,z) = (x',y',z'). The x, y, and z arguments refer to the model's coordinate system.
      Specified by:
      setRotationOrigin in interface Model3D.ImageData
      Parameters:
      x - the x coordinate about which to perform the rotation
      y - the y coordinate about which to perform the rotation
      z - the z coordinate about which to perform the rotation
    • setRotationOrigin

      public void setRotationOrigin(double x, double y, double z, boolean move)
      Description copied from interface: Model3D.ImageData
      Move the rotation origin for a coordinate rotation with options. Setting the 'move' argument to true is useful when you want to rotate an object and place the previous origin at a specific location. The x, y, and z arguments refer to the model's coordinate system.
      Specified by:
      setRotationOrigin in interface Model3D.ImageData
      Parameters:
      x - the x coordinate about which to perform the rotation
      y - the y coordinate about which to perform the rotation
      z - the z coordinate about which to perform the rotation
      move - false if (x,y,z) will have the same value after the rotation; true if the point (0,0,0) in the old coordinate system will be mapped to the point (x,y,z) in the new coordinate system after the rotation is complete.
      See Also:
    • getXTranslation

      public double getXTranslation()
      Description copied from interface: Model3D.ImageData
      Get the coordinate translation in the X direction that will be applied after other coordinate transformations are completed. (Note: because the coordinate system is being translated, objects will appear to move in the opposite direction).
      Specified by:
      getXTranslation in interface Model3D.ImageData
      Returns:
      the translation in the X direction
    • getYTranslation

      public double getYTranslation()
      Description copied from interface: Model3D.ImageData
      Get the coordinate translation in the Y direction that will be applied after other coordinate transformations are completed. (Note: because the coordinate system is being translated, objects will appear to move in the opposite direction).
      Specified by:
      getYTranslation in interface Model3D.ImageData
      Returns:
      the translation in the Y direction
    • setTranslation

      public void setTranslation(double x, double y)
      Description copied from interface: Model3D.ImageData
      Specify translation after coordinate changes. After other coordinate transformations are complete, the coordinate system in which a Model3D object is shown may be translated by an amount x in the x direction and an amount y in the y direction. The object displayed will appear to move in the opposite direction.
      Specified by:
      setTranslation in interface Model3D.ImageData
      Parameters:
      x - the x-axis translation
      y - the y-axis translation
    • getDelta

      public double getDelta()
      Description copied from interface: Model3D.ImageData
      Get the minimum triangle size for rendering. The size is measured in the x, y, and z directions. Larger triangles will be split into some number of smaller ones. Triangles will not be split if the value is zero.
      Specified by:
      getDelta in interface Model3D.ImageData
      Returns:
      the minimum size
      See Also:
    • setDelta

      public void setDelta(double delta)
      Description copied from interface: Model3D.ImageData
      Set the minimum triangle size for rendering. The value of this parameter, if nonzero, specifies the maximum dimensions of a triangle that is to be rendered in the x, y, and z directions. If a triangle is larger, it is partitioned into a smaller set of triangles. This partitioning applies only during rendering. Setting the minimum size to a small, nonzero value can improve rendering by making the calculation of which triangle is in front of others more reliable. Too small a value, however, may slow rendering considerably. Units are those used for a triangle's X, Y, and Z coordinates.
      Specified by:
      setDelta in interface Model3D.ImageData
      Parameters:
      delta - the triangle dimension limit; zero to indicate that triangles should not be split
    • getLightSourcePhi

      public double getLightSourcePhi()
      Description copied from interface: Model3D.ImageData
      Get the light-source parameter phi. The parameter partially determines the direction of the light source as described in the documentation for setLightSource.
      Specified by:
      getLightSourcePhi in interface Model3D.ImageData
      Returns:
      the light-source parameter phi in radians
      See Also:
    • getLightSourceTheta

      public double getLightSourceTheta()
      Description copied from interface: Model3D.ImageData
      Get the light-source parameter theta. The parameter partially determines the direction of the light source as described in the documentation for setLightSource.
      Specified by:
      getLightSourceTheta in interface Model3D.ImageData
      Returns:
      the light-source parameter theta in radians
      See Also:
    • setLightSource

      public void setLightSource(double phi, double theta)
      Description copied from interface: Model3D.ImageData
      Sets the direction to a light source. The default direction, in which theta=0, corresponds to a light source at infinity aimed vertically downwards towards the x-y plane. The brightness used for a triangle varies as the cosine of the angle between a vector pointing in the direction of the light source and a vector perpendicular to the plane of the triangle.
      Specified by:
      setLightSource in interface Model3D.ImageData
      Parameters:
      phi - the angle in radians about the z axis of the plane containing the z axis and a unit vector pointing towards the light source. If phi is zero, this plane includes the x axis and for non-zero theta, the unit vector will have a positive x component.
      theta - the angle in radians between a unit vector pointing towards the light source makes and with a vector parallel to the z axis.
    • getColorFactor

      public double getColorFactor()
      Description copied from interface: Model3D.ImageData
      Get the color factor. After coordinate transformations, the red, blue, and green components of the color of an object will be scaled depending on its height so that, for the same orientation, triangles at with the lowest values of 'z' will be dimmer than those with the maximum value of 'z' by this factor. A value of zero indicates that the color factor will be ignored. A value larger than 1.0 will result in the multiple Z values being rendered in black, but with more color separation for higher Z values.
      Specified by:
      getColorFactor in interface Model3D.ImageData
      Returns:
      the color factor
      See Also:
    • setColorFactor

      public void setColorFactor(double factor)
      Description copied from interface: Model3D.ImageData
      Set the color factor. After coordinate transformations, the red, blue, and green components of the color of an object will be scaled depending on its height so that, for the same orientation, triangles at with the lowest values of 'z' will be dimmer than those with the maximum value of 'z' by this factor. If the value is 1.0, the smallest z value of the object will be rendered as black. A value of 0.0 indicates that the color factor will be ignored. A value larger than 1.0 will result in the multiple Z values being rendered in black, but with more color separation for higher Z values.

      This is intended to help emphasize differences along the 'z' axis that would normally be hard to discern visually.

      Specified by:
      setColorFactor in interface Model3D.ImageData
      Parameters:
      factor - the color factor given as a non-negative number
    • getNormalFactor

      public double getNormalFactor()
      Description copied from interface: Model3D.ImageData
      Get the normal factor After a coordinate transformation, the normal factor is used to reduce the color factor towards 0.0 when a surface segment' is not aligned with the Z axis. If the Z component of the segment's normal vector is nz and the normal factor is larger than 0.0, the color factor is multiplied by exp(-(1.0-nz)/normalFactor). Since the normal vector has a length of 1.0, when the normal vector does not point in the positive Z direction, nz will be less than 1.0 and the color factor will be reduced.
      Specified by:
      getNormalFactor in interface Model3D.ImageData
      Returns:
      the normal factor; 0.0 if there is none
    • setNormalFactor

      public void setNormalFactor(double factor)
      Description copied from interface: Model3D.ImageData
      Set the normal factor. After a coordinate transformation, the normal factor is used to reduce the color factor towards 0.0 when a surface segment' is not aligned with the Z axis. If the Z component of the segment's normal vector is nz and the normal factor is larger than 0.0, the color factor is multiplied by exp(-(1.0-nz)/normalFactor). Since the normal vector has a length of 1.0, when the normal vector does not point in the positive Z direction, nz will be less than 1.0 and the color factor will be reduced.
      Specified by:
      setNormalFactor in interface Model3D.ImageData
      Parameters:
      factor - the normal factor; 0.0 or negative if there is none
    • getBacksideColor

      public Color getBacksideColor()
      Description copied from interface: Model3D.ImageData
      Get the color for the the side of a triangle that should not be visible due to being on the inside of a closed manifold.
      Specified by:
      getBacksideColor in interface Model3D.ImageData
      Returns:
      the color
    • setBacksideColor

      public void setBacksideColor(Color c)
      Description copied from interface: Model3D.ImageData
      Set the color for the side of a triangle that should not be visible due to being on the inside of a closed manifold. This is useful for debugging a model: one class of errors results in a triangle having the wrong orientation, and setting this parameter can help indicate where the problem is in the model.
      Specified by:
      setBacksideColor in interface Model3D.ImageData
      Parameters:
      c - the color; null if a color is not set
    • getEdgeColor

      public Color getEdgeColor()
      Description copied from interface: Model3D.ImageData
      Get the color used to indicate the edges of a triangle
      Specified by:
      getEdgeColor in interface Model3D.ImageData
      Returns:
      the color or null to indicate that edges will not be shown
    • setEdgeColor

      public void setEdgeColor(Color c)
      Description copied from interface: Model3D.ImageData
      Set the color to use to use to draw the edges of triangles.
      Specified by:
      setEdgeColor in interface Model3D.ImageData
      Parameters:
      c - the color; null if edges should not be displayed
    • getDefaultSegmentColor

      public Color getDefaultSegmentColor()
      Description copied from interface: Model3D.ImageData
      Get the color to use for line segments explicitly added or associated with triangles added for rendering. The phrase "[line segments] associated with triangles" refers to the additional edges of triangles that were added during the rendering process to minimize z-order issues that can occur when at least one edge of a triangle is abnormally large. Such triangles may be added when Model3D.ImageData.setDelta(double) is called with a non-zero argument.
      Specified by:
      getDefaultSegmentColor in interface Model3D.ImageData
      Returns:
      the color; null if the line segments should not be shown
    • setDefaultSegmentColor

      public void setDefaultSegmentColor(Color c)
      Description copied from interface: Model3D.ImageData
      Set the color to use for line segments explicitly added or associated with triangles added for rendering. The phrase "[line segments] associated with triangles" refers to the additional edges of triangles that were added during the rendering process to minimize z-order issues that can occur when at least one edge of a triangle is abnormally large. Such triangles may be added when Model3D.ImageData.setDelta(double) is called with a non-zero argument.
      Specified by:
      setDefaultSegmentColor in interface Model3D.ImageData
      Parameters:
      c - the color; null if line segments should not be displayed
    • getDefaultBacksideSegmentColor

      public Color getDefaultBacksideSegmentColor()
      Description copied from interface: Model3D.ImageData
      Get the default backside color to use for line segments associated with triangles added for rendering. The phrase "[line segments] associated with triangles" refers to the additional edges of triangles that were added during the rendering process to minimize z-order issues that can occur when at least one edge of a triangle is abnormally large. Such triangles may be added when Model3D.ImageData.setDelta(double) is called with a non-zero argument.
      Specified by:
      getDefaultBacksideSegmentColor in interface Model3D.ImageData
      Returns:
      the color; null if the line segments should not be shown
    • setDefaultBacksideSegmentColor

      public void setDefaultBacksideSegmentColor(Color c)
      Description copied from interface: Model3D.ImageData
      Set the default backside color to use for line segments associated with triangles added for rendering. The phrase "[line segments] associated with triangles" refers to the additional edges of triangles that were added during the rendering process to minimize z-order issues that can occur when at least one edge of a triangle is abnormally large. Such triangles may be added when Model3D.ImageData.setDelta(double) is called with a non-zero argument.
      Specified by:
      setDefaultBacksideSegmentColor in interface Model3D.ImageData
      Parameters:
      c - the color; null if these line segments should not be displayed
    • reset

      public void reset()
      Description copied from interface: Model3D.ImageData
      Reset to default values.
      Specified by:
      reset in interface Model3D.ImageData
    • write

      public void write(String type, String name) throws IOException
      Write the image to a file given a file name. The type parameters are strings naming the file format as used by the class javax.imageio.ImageIO
      Parameters:
      type - the file type
      name - the file name
      Throws:
      IOException - an error occurred during writing
    • write

      public void write(String type, File file) throws IOException
      Write the image to a file. The type parameters are strings naming the file format as used by the class javax.imageio.ImageIO
      Parameters:
      type - the file type
      file - the file to write
      Throws:
      IOException - an error occurred during writing
    • write

      public void write(String type, FileAccessor fa) throws IOException
      Write the image to a file provided by a file accessor. The type parameters are strings naming the file format as used by the class javax.imageio.ImageIO
      Parameters:
      type - the file type
      fa - the file accessor to use
      Throws:
      IOException - an error occurred during writing
    • write

      public void write(String type, OutputStream os) throws IOException
      Write the image to an output stream. The type parameters are strings naming the file format as used by the class javax.imageio.ImageIO
      Parameters:
      type - the file type
      os - the output stream to which to write the image
      Throws:
      IOException - an error occurred during writing
    • write

      public void write() throws IOException
      Write the image to its OutputStreamGraphics.
      Throws:
      IOException - an IO error occurred.