java.lang.Object
gov.nih.mipav.view.renderer.J3D.volumeview.Renderer
Direct Known Subclasses:
RayCastRenderer, ShearWarpRenderer

public abstract class Renderer extends Object
A ray tracer for 3D images. Either a parallel or perspective camera model can be selected to form the rays. In the parallel case, zooming is accomplished by changing the size of the viewport. In the perspective case, zooming is accomplished by moving the eye point. The line segment of intersection (if it exists) of a ray with the bounding box of the image is computed. The image is trilinearly interpolated to allow subvoxel evaluations.

The camera coordinate system has eye point is E = (0,0,z). The direction vector is D = (0,0,1), the up vector is U = (0,1,0), and the right vector is R = (1,0,0). Only the eye point is allowed to change. Since the 3D image can be arbitrarily rotated (via a virtual trackball), any portion of the image can be viewed either close up or far away.

The view plane has normal D and origin at E+n*D (n=near). The view frustum is orthogonal and has no far plane. For a perspective camera, the field of view is given as an angle A subtended at the eye point. In camera coordinates, the view port is the square [-e,e]^2 where e = n*tan(A/2). In world coordinates, the corners of the square are E+n*D+s*e*U+t*e*R where |s| = |t| = 1 (four choices on sign). For a parallel camera, there is no field of view.

The mapping between the viewport [-e,e]^2 and the B-by-B render image is the following. If (i,j) is a pixel in the image, then the corresponding viewport point is (r,u) = (-e+2*e*i/(B-1),-e+2*e*j/(B-1)).

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int[]
    Final rendered image (24-bit RGB stored in int). 2D: m_iRBound-by-m_iRBound image
    protected javax.vecmath.Vector3f[]
    For track ball rotation.
    protected javax.vecmath.Vector3f[]
    unit-length normal vectors at the voxels.
    protected boolean
    Left-handed camera coordinate system that is initially set up to view the z=0 slice of the 3D image.
    (package private) boolean
    For indicating that the volume input data should be reloaded.
    protected float
    DOCUMENT ME!
    protected float
    DOCUMENT ME!
    protected float
    DOCUMENT ME!
    protected float
    DOCUMENT ME!
    protected float
    DOCUMENT ME!
    protected float
    DOCUMENT ME!
    protected float
    DOCUMENT ME!
    protected float
    For zooming and panning.
    protected float
    For zooming and panning.
    protected float
    For zooming and panning.
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected int
    DOCUMENT ME!
    protected Color
    Background color of rendered image.
    protected javax.vecmath.Point3f
    DOCUMENT ME!
    protected javax.vecmath.Point3f
    eye point in world and model space.
    protected ModelImage
    Input volume.
    used for lighting-based rendering.
    DOCUMENT ME!
    protected javax.vecmath.Matrix3f
    DOCUMENT ME!
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Renderer(ModelImage kImage, int iRBound, int[] aiRImage)
    The constructor for the renderer.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected float
    In order to map line integrals of image intensity to RGB colors where each color channel is 8 bits, it is necessary to make sure that the integrals are in [0,255].
    protected final void
    convertWorldToModel(javax.vecmath.Tuple3f kWorld, javax.vecmath.Tuple3f kModel)
    Convert coordinates from world space to model space.
    void
    Disposes of image memory and associated objects.
    protected void
    Calls dispose.
    float
    Read the field of view angle.
    abstract javax.vecmath.Vector3f
    getAxis(int i)
    DOCUMENT ME!
    Read the background color used for rendering images.
    float
    Read the view port extreme value e.
    float
    Read the z value of the eye point (0,0,z).
    javax.vecmath.Point3f
    Return the world space coordinates for the eye point.
    float
    Get the gamma correction.
    int
    The maximum of the x-, y-, and z-dimensions of the image.
    int
    The minimum of the x-, y-, and z-dimensions of the image.
    float
    Read the distance from the eye point to the view plane.
    boolean
    Read the current camera model.
    int
    The x-dimension of the image.
    float
    Get the x translation.
    int
    The y-dimension of the image.
    float
    Get the y translation.
    int
    The z-dimension of the image.
    float
    Get the zoom factor.
    abstract boolean
    Return indication as to whether or not the input image data has been specified yet.
    boolean
    Return indication as to whether or not the normal vectors for each voxel in the volume has been specified.
    protected static void
    orthonormalize(javax.vecmath.Vector3f[] akVector)
    The axis vectors for the oriented bounding box are rotated in place.
    boolean
    Accessor that returns whether or not to reload the volume data.
    void
    reloadInputData(boolean bReload)
    set the m_bReloadInput member variable. this is used to force the renderer to use new volume data.
    abstract void
    rotateBy(javax.vecmath.AxisAngle4f kAxisAngle)
    DOCUMENT ME!
    abstract void
    rotateFrameBy(javax.media.j3d.Transform3D transform)
    DOCUMENT ME!
    void
    setAngle(float fAngle)
    Change the field of view angle.
    void
    Set the background color for the rendered image.
    void
    setExtreme(float fExtreme)
    Change the view port extreme value e.
    void
    setEyeDist(float fDist)
    Change the z value of the eye point (0,0,z).
    void
    setGamma(float fGamma)
    Set the gamma correction.
    void
    Setup the specified set of lights to use for rendering.
    void
    setMaterialShininess(float value)
    Set the texture material shininess value.
    void
    setNear(float fNear)
    Change the distance from the eye point to the view plane.
    void
    setNearAndAngle(float fNear, float fAngle)
    Change the near distance and the field of view angle.
    void
    setNormals(javax.vecmath.Vector3f[] akNormal)
    Specify the array of normal vectors for each voxel in the volume.
    void
    setParallel(boolean bParallel)
    Change the camera model.
    abstract void
    setXBoundNeg(float value)
    Setup the X Negative clipping plane position.
    abstract void
    setXBoundPos(float value)
    Setup the X positive clipping plane position.
    void
    setXTranslate(float fXTrn)
    Set the x translation.
    abstract void
    setYBoundNeg(float value)
    Setup the Y Negative clipping plane position.
    abstract void
    setYBoundPos(float value)
    Setup the Y positive clipping plane position.
    void
    setYTranslate(float fYTrn)
    Set the y translation.
    abstract void
    setZBoundNeg(float value)
    Setup the Z negative clipping plane position.
    abstract void
    setZBoundPos(float value)
    Setup the Z positive clipping plane position.
    void
    setZoom(float fZoom)
    Set the zoom factor.
    protected void
    Called at the beginning of the trace methods.
    abstract boolean
    Return indication as to whether or not the particular renderer uses normal vectors as part of its implementation.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • m_aiRImage

      protected int[] m_aiRImage
      Final rendered image (24-bit RGB stored in int). 2D: m_iRBound-by-m_iRBound image
    • m_akAxis

      protected javax.vecmath.Vector3f[] m_akAxis
      For track ball rotation.
    • m_akNormal

      protected javax.vecmath.Vector3f[] m_akNormal
      unit-length normal vectors at the voxels.
    • m_bParallel

      protected boolean m_bParallel
      Left-handed camera coordinate system that is initially set up to view the z=0 slice of the 3D image. E = (0,0,eye), initially eye invalid input: '<' 0 D = (0,0,1) = direction U = (0,1,0) = up R = (1,0,0) = right. The camera can be parallel or perspective. The view plane has normal D and origin at E+n*D (n=near). The view frustum is orthogonal and has no far plane. The field of view is given as an angle A subtended at the eye point. The view port is the square [-e,e]^2 where e = n*tan(A/2).
    • m_fGamma

      protected float m_fGamma
      DOCUMENT ME!
    • m_fFMult

      protected float m_fFMult
      DOCUMENT ME!
    • m_fNear

      protected float m_fNear
      DOCUMENT ME!
    • m_fAngle

      protected float m_fAngle
      DOCUMENT ME!
    • m_fExtreme

      protected float m_fExtreme
      DOCUMENT ME!
    • m_fRScaleX

      protected float m_fRScaleX
      DOCUMENT ME!
    • m_fRScaleY

      protected float m_fRScaleY
      DOCUMENT ME!
    • m_fZoom

      protected float m_fZoom
      For zooming and panning.
    • m_fXTrn

      protected float m_fXTrn
      For zooming and panning.
    • m_fYTrn

      protected float m_fYTrn
      For zooming and panning.
    • m_iMinBound

      protected int m_iMinBound
      DOCUMENT ME!
    • m_iMaxBound

      protected int m_iMaxBound
      DOCUMENT ME!
    • m_iRBound

      protected int m_iRBound
      DOCUMENT ME!
    • m_iXBound

      protected int m_iXBound
      DOCUMENT ME!
    • m_iYBound

      protected int m_iYBound
      DOCUMENT ME!
    • m_iZBound

      protected int m_iZBound
      DOCUMENT ME!
    • m_iXBoundM1

      protected int m_iXBoundM1
      DOCUMENT ME!
    • m_iYBoundM1

      protected int m_iYBoundM1
      DOCUMENT ME!
    • m_iZBoundM1

      protected int m_iZBoundM1
      DOCUMENT ME!
    • m_iXBoundM2

      protected int m_iXBoundM2
      DOCUMENT ME!
    • m_iYBoundM2

      protected int m_iYBoundM2
      DOCUMENT ME!
    • m_iZBoundM2

      protected int m_iZBoundM2
      DOCUMENT ME!
    • m_iXYProduct

      protected int m_iXYProduct
      DOCUMENT ME!
    • m_iXYZProduct

      protected int m_iXYZProduct
      DOCUMENT ME!
    • m_kBackgroundColor

      protected Color m_kBackgroundColor
      Background color of rendered image.
    • m_kEyeModel

      protected javax.vecmath.Point3f m_kEyeModel
      DOCUMENT ME!
    • m_kEyeWorld

      protected javax.vecmath.Point3f m_kEyeWorld
      eye point in world and model space.
    • m_kImage

      protected ModelImage m_kImage
      Input volume.
    • m_kLightSet

      protected SoftwareLightSet m_kLightSet
      used for lighting-based rendering.
    • m_kMaterial

      protected SoftwareMaterial m_kMaterial
      DOCUMENT ME!
    • m_kRotate

      protected javax.vecmath.Matrix3f m_kRotate
      DOCUMENT ME!
    • m_bReloadInput

      boolean m_bReloadInput
      For indicating that the volume input data should be reloaded.
  • Constructor Details

    • Renderer

      protected Renderer(ModelImage kImage, int iRBound, int[] aiRImage)
      The constructor for the renderer.
      Parameters:
      kImage - the 3D image
      iRBound - the dimension of the square 2D renderer image
      aiRImage - The rendered image data stored in row-major order. Each integer pixel represents an RGB color in the format B | (G invalid input: '<'invalid input: '<' 8) | (R invalid input: '<'invalid input: '<' 16).
  • Method Details

    • getAxis

      public abstract javax.vecmath.Vector3f getAxis(int i)
      DOCUMENT ME!
      Parameters:
      i - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • hasInputData

      public abstract boolean hasInputData()
      Return indication as to whether or not the input image data has been specified yet.
      Returns:
      boolean True if the input image data has been specified.
    • rotateBy

      public abstract void rotateBy(javax.vecmath.AxisAngle4f kAxisAngle)
      DOCUMENT ME!
      Parameters:
      kAxisAngle - DOCUMENT ME!
    • rotateFrameBy

      public abstract void rotateFrameBy(javax.media.j3d.Transform3D transform)
      DOCUMENT ME!
      Parameters:
      transform - DOCUMENT ME!
    • setXBoundNeg

      public abstract void setXBoundNeg(float value)
      Setup the X Negative clipping plane position.
      Parameters:
      value - position of the X negative clip slider.
    • setXBoundPos

      public abstract void setXBoundPos(float value)
      Setup the X positive clipping plane position.
      Parameters:
      value - position of the X positive clip slider.
    • setYBoundNeg

      public abstract void setYBoundNeg(float value)
      Setup the Y Negative clipping plane position.
      Parameters:
      value - position of the Y negative clip slider.
    • setYBoundPos

      public abstract void setYBoundPos(float value)
      Setup the Y positive clipping plane position.
      Parameters:
      value - positin of the Y positve clip slider.
    • setZBoundNeg

      public abstract void setZBoundNeg(float value)
      Setup the Z negative clipping plane position.
      Parameters:
      value - position of the Z negative clip slider.
    • setZBoundPos

      public abstract void setZBoundPos(float value)
      Setup the Z positive clipping plane position.
      Parameters:
      value - position of the Z positive clip slider.
    • usesNormals

      public abstract boolean usesNormals()
      Return indication as to whether or not the particular renderer uses normal vectors as part of its implementation.
      Returns:
      boolean True if the implementation uses normals.
    • disposeLocal

      public void disposeLocal()
      Disposes of image memory and associated objects.
    • getAngle

      public float getAngle()
      Read the field of view angle.
      Returns:
      m_fAngle the current field of view angle
    • getBackgroundColor

      public Color getBackgroundColor()
      Read the background color used for rendering images.
      Returns:
      Color RGBA color in use for the image background.
    • getExtreme

      public float getExtreme()
      Read the view port extreme value e. VolumeRenderer uses this to zoom the image for a parallel camera.
      Returns:
      the current view port extreme
    • getEyeDist

      public float getEyeDist()
      Read the z value of the eye point (0,0,z). VolumeRenderer uses this to zoom the image for a perspective camera.
      Returns:
      the current z component of the eye point
    • getEyePoint

      public javax.vecmath.Point3f getEyePoint()
      Return the world space coordinates for the eye point.
      Returns:
      Point3f world space coordinates of the eye point.
    • getGamma

      public float getGamma()
      Get the gamma correction.
      Returns:
      the gamma correction
    • getMaxBound

      public int getMaxBound()
      The maximum of the x-, y-, and z-dimensions of the image.
      Returns:
      the maximuim dimension
    • getMinBound

      public int getMinBound()
      The minimum of the x-, y-, and z-dimensions of the image.
      Returns:
      the minimuim dimension
    • getNear

      public float getNear()
      Read the distance from the eye point to the view plane.
      Returns:
      the current distance
    • getParallel

      public boolean getParallel()
      Read the current camera model.
      Returns:
      true for a parallel camera, false for a perspective camera
    • getXBound

      public int getXBound()
      The x-dimension of the image.
      Returns:
      the x-dimension
    • getXTranslate

      public float getXTranslate()
      Get the x translation.
      Returns:
      the x translation
    • getYBound

      public int getYBound()
      The y-dimension of the image.
      Returns:
      the y-dimension
    • getYTranslate

      public float getYTranslate()
      Get the y translation.
      Returns:
      the y translation
    • getZBound

      public int getZBound()
      The z-dimension of the image.
      Returns:
      the z-dimension
    • getZoom

      public float getZoom()
      Get the zoom factor.
      Returns:
      the zoom factor
    • hasNormals

      public boolean hasNormals()
      Return indication as to whether or not the normal vectors for each voxel in the volume has been specified.
      Returns:
      boolean True if such an array of normal vectors has been defined.
    • reloadInputData

      public boolean reloadInputData()
      Accessor that returns whether or not to reload the volume data.
      Returns:
      DOCUMENT ME!
    • reloadInputData

      public void reloadInputData(boolean bReload)
      set the m_bReloadInput member variable. this is used to force the renderer to use new volume data.
      Parameters:
      bReload - boolean bReload = true will cause the data to be reloaded.
    • setAngle

      public void setAngle(float fAngle)
      Change the field of view angle. For a perspective camera, the current near value and the new angle are used to compute the new extreme value.
      Parameters:
      fAngle - the new field of view angle, a number A satisfying the constraints 0 invalid input: '<' A invalid input: '<' pi
    • setBackgroundColor

      public void setBackgroundColor(Color color)
      Set the background color for the rendered image.
      Parameters:
      color - Color RGBA color to use for the image background.
    • setExtreme

      public void setExtreme(float fExtreme)
      Change the view port extreme value e. VolumeRenderer uses this to zoom the image for a parallel camera. The method does not allow a change to e for perspective cameras. This should be done indirectly via calls to setNear, setAngle, or setNearAndAngle.
      Parameters:
      fExtreme - the new view port extreme
    • setEyeDist

      public void setEyeDist(float fDist)
      Change the z value of the eye point (0,0,z). VolumeRenderer uses this to zoom the image for a perspective camera.
      Parameters:
      fDist - the new z component of the eye point
    • setGamma

      public void setGamma(float fGamma)
      Set the gamma correction. The value must be nonnegative. A color C0 in [0,255] is normalized to C1 in [0,1], replaced by C2 = pow(C1,gamma), then remapped to C3 in [0,255]. The calculations are done in the construction of the final rendered image from the computed color channels.
      Parameters:
      fGamma - the gamma correction
    • setLighting

      public void setLighting(SoftwareLightSet kLightSet, SoftwareMaterial kMaterial)
      Setup the specified set of lights to use for rendering.
      Parameters:
      kLightSet - SoftwareLightSet Set of world/model lights.
      kMaterial - SoftwareMaterial Set of default material properties to use when applying the lighting.
    • setMaterialShininess

      public void setMaterialShininess(float value)
      Set the texture material shininess value.
      Parameters:
      value - shininess value.
    • setNear

      public void setNear(float fNear)
      Change the distance from the eye point to the view plane. For a perspective camera, the current field of view angle and the new near value are used to compute the new extreme value.
      Parameters:
      fNear - the new distance, a number N satisfying the constraint N > 0
    • setNearAndAngle

      public void setNearAndAngle(float fNear, float fAngle)
      Change the near distance and the field of view angle. For a perspective camera, the new values are used to compute the new extreme value.
      Parameters:
      fNear - the new distance N, a number satisfying the constraint N > 0
      fAngle - the new field of view angle, a number A satisfying the constraints 0 invalid input: '<' A invalid input: '<' pi
    • setNormals

      public void setNormals(javax.vecmath.Vector3f[] akNormal)
      Specify the array of normal vectors for each voxel in the volume.
      Parameters:
      akNormal - Vector3f[] Array of normal vectors.
    • setParallel

      public void setParallel(boolean bParallel)
      Change the camera model.
      Parameters:
      bParallel - true for a parallel camera, false for a perspective camera
    • setXTranslate

      public void setXTranslate(float fXTrn)
      Set the x translation. The (x,y) vector is used to translate the cener of the rendered image on the screen.
      Parameters:
      fXTrn - the x translation
    • setYTranslate

      public void setYTranslate(float fYTrn)
      Set the y translation. The (x,y) vector is used to translate the cener of the rendered image on the screen.
      Parameters:
      fYTrn - the y translation
    • setZoom

      public void setZoom(float fZoom)
      Set the zoom factor. The value must be positive. The smaller the value, the closer the volume data appears to the viewer.
      Parameters:
      fZoom - the zoom factor
    • orthonormalize

      protected static void orthonormalize(javax.vecmath.Vector3f[] akVector)
      The axis vectors for the oriented bounding box are rotated in place. After many rotations, numerical errors can cause the axes to be signicantly skewed so that they are no longer a good approximation to a right-handed orthonormal coordinate system. This method uses Gram-Schmidt orthonormalization to avoid the accumulative errors and is called after each rotation is applied to the axes.
      Parameters:
      akVector - DOCUMENT ME!
    • computeIntegralNormalizationFactor

      protected float computeIntegralNormalizationFactor(byte[] acImage)
      In order to map line integrals of image intensity to RGB colors where each color channel is 8 bits, it is necessary to make sure that the integrals are in [0,255]. Producing a theoretical maximum value of a line integral is not tractable in an application. This method constructs an approximate maximum by integrating along each line of voxels in the image with line directions parallel to the coordinate axes. The 'processRay' call adjusts the line integrals using the estimate, but still clamps the integrals to 255 since the estimate might not be the true maximum.
      Parameters:
      acImage - byte[] Input volume to use in computing the integral normalization factor.
      Returns:
      float Integral normalization factor.
    • convertWorldToModel

      protected final void convertWorldToModel(javax.vecmath.Tuple3f kWorld, javax.vecmath.Tuple3f kModel)
      Convert coordinates from world space to model space.
      Parameters:
      kWorld - Tuple3f input world space coordinates
      kModel - Tuple3f output world space coordinates
    • finalize

      protected void finalize() throws Throwable
      Calls dispose.
      Overrides:
      finalize in class Object
      Throws:
      Throwable - DOCUMENT ME!
    • traceInit

      protected void traceInit()
      Called at the beginning of the trace methods.