Class Renderer
- java.lang.Object
-
- gov.nih.mipav.view.renderer.J3D.volumeview.Renderer
-
- Direct Known Subclasses:
RayCastRenderer,ShearWarpRenderer
public abstract class Renderer extends java.lang.ObjectA 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[]m_aiRImageFinal rendered image (24-bit RGB stored in int). 2D: m_iRBound-by-m_iRBound imageprotected javax.vecmath.Vector3f[]m_akAxisFor track ball rotation.protected javax.vecmath.Vector3f[]m_akNormalunit-length normal vectors at the voxels.protected booleanm_bParallelLeft-handed camera coordinate system that is initially set up to view the z=0 slice of the 3D image.(package private) booleanm_bReloadInputFor indicating that the volume input data should be reloaded.protected floatm_fAngleDOCUMENT ME!protected floatm_fExtremeDOCUMENT ME!protected floatm_fFMultDOCUMENT ME!protected floatm_fGammaDOCUMENT ME!protected floatm_fNearDOCUMENT ME!protected floatm_fRScaleXDOCUMENT ME!protected floatm_fRScaleYDOCUMENT ME!protected floatm_fXTrnFor zooming and panning.protected floatm_fYTrnFor zooming and panning.protected floatm_fZoomFor zooming and panning.protected intm_iMaxBoundDOCUMENT ME!protected intm_iMinBoundDOCUMENT ME!protected intm_iRBoundDOCUMENT ME!protected intm_iXBoundDOCUMENT ME!protected intm_iXBoundM1DOCUMENT ME!protected intm_iXBoundM2DOCUMENT ME!protected intm_iXYProductDOCUMENT ME!protected intm_iXYZProductDOCUMENT ME!protected intm_iYBoundDOCUMENT ME!protected intm_iYBoundM1DOCUMENT ME!protected intm_iYBoundM2DOCUMENT ME!protected intm_iZBoundDOCUMENT ME!protected intm_iZBoundM1DOCUMENT ME!protected intm_iZBoundM2DOCUMENT ME!protected java.awt.Colorm_kBackgroundColorBackground color of rendered image.protected javax.vecmath.Point3fm_kEyeModelDOCUMENT ME!protected javax.vecmath.Point3fm_kEyeWorldeye point in world and model space.protected ModelImagem_kImageInput volume.protected SoftwareLightSetm_kLightSetused for lighting-based rendering.protected SoftwareMaterialm_kMaterialDOCUMENT ME!protected javax.vecmath.Matrix3fm_kRotateDOCUMENT ME!
-
Constructor Summary
Constructors Modifier Constructor Description protectedRenderer(ModelImage kImage, int iRBound, int[] aiRImage)The constructor for the renderer.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected floatcomputeIntegralNormalizationFactor(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].protected voidconvertWorldToModel(javax.vecmath.Tuple3f kWorld, javax.vecmath.Tuple3f kModel)Convert coordinates from world space to model space.voiddisposeLocal()Disposes of image memory and associated objects.protected voidfinalize()Calls dispose.floatgetAngle()Read the field of view angle.abstract javax.vecmath.Vector3fgetAxis(int i)DOCUMENT ME!java.awt.ColorgetBackgroundColor()Read the background color used for rendering images.floatgetExtreme()Read the view port extreme value e.floatgetEyeDist()Read the z value of the eye point (0,0,z).javax.vecmath.Point3fgetEyePoint()Return the world space coordinates for the eye point.floatgetGamma()Get the gamma correction.intgetMaxBound()The maximum of the x-, y-, and z-dimensions of the image.intgetMinBound()The minimum of the x-, y-, and z-dimensions of the image.floatgetNear()Read the distance from the eye point to the view plane.booleangetParallel()Read the current camera model.intgetXBound()The x-dimension of the image.floatgetXTranslate()Get the x translation.intgetYBound()The y-dimension of the image.floatgetYTranslate()Get the y translation.intgetZBound()The z-dimension of the image.floatgetZoom()Get the zoom factor.abstract booleanhasInputData()Return indication as to whether or not the input image data has been specified yet.booleanhasNormals()Return indication as to whether or not the normal vectors for each voxel in the volume has been specified.protected static voidorthonormalize(javax.vecmath.Vector3f[] akVector)The axis vectors for the oriented bounding box are rotated in place.booleanreloadInputData()Accessor that returns whether or not to reload the volume data.voidreloadInputData(boolean bReload)set the m_bReloadInput member variable. this is used to force the renderer to use new volume data.abstract voidrotateBy(javax.vecmath.AxisAngle4f kAxisAngle)DOCUMENT ME!abstract voidrotateFrameBy(javax.media.j3d.Transform3D transform)DOCUMENT ME!voidsetAngle(float fAngle)Change the field of view angle.voidsetBackgroundColor(java.awt.Color color)Set the background color for the rendered image.voidsetExtreme(float fExtreme)Change the view port extreme value e.voidsetEyeDist(float fDist)Change the z value of the eye point (0,0,z).voidsetGamma(float fGamma)Set the gamma correction.voidsetLighting(SoftwareLightSet kLightSet, SoftwareMaterial kMaterial)Setup the specified set of lights to use for rendering.voidsetMaterialShininess(float value)Set the texture material shininess value.voidsetNear(float fNear)Change the distance from the eye point to the view plane.voidsetNearAndAngle(float fNear, float fAngle)Change the near distance and the field of view angle.voidsetNormals(javax.vecmath.Vector3f[] akNormal)Specify the array of normal vectors for each voxel in the volume.voidsetParallel(boolean bParallel)Change the camera model.abstract voidsetXBoundNeg(float value)Setup the X Negative clipping plane position.abstract voidsetXBoundPos(float value)Setup the X positive clipping plane position.voidsetXTranslate(float fXTrn)Set the x translation.abstract voidsetYBoundNeg(float value)Setup the Y Negative clipping plane position.abstract voidsetYBoundPos(float value)Setup the Y positive clipping plane position.voidsetYTranslate(float fYTrn)Set the y translation.abstract voidsetZBoundNeg(float value)Setup the Z negative clipping plane position.abstract voidsetZBoundPos(float value)Setup the Z positive clipping plane position.voidsetZoom(float fZoom)Set the zoom factor.protected voidtraceInit()Called at the beginning of the trace methods.abstract booleanusesNormals()Return indication as to whether or not the particular renderer uses normal vectors as part of its implementation.
-
-
-
Field Detail
-
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 < 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 java.awt.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 Detail
-
Renderer
protected Renderer(ModelImage kImage, int iRBound, int[] aiRImage)
The constructor for the renderer.- Parameters:
kImage- the 3D imageiRBound- the dimension of the square 2D renderer imageaiRImage- The rendered image data stored in row-major order. Each integer pixel represents an RGB color in the format B | (G << 8) | (R << 16).
-
-
Method Detail
-
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 java.awt.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 < A < pi
-
setBackgroundColor
public void setBackgroundColor(java.awt.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 > 0fAngle- the new field of view angle, a number A satisfying the constraints 0 < A < 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 coordinateskModel- Tuple3f output world space coordinates
-
finalize
protected void finalize() throws java.lang.ThrowableCalls dispose.- Overrides:
finalizein classjava.lang.Object- Throws:
java.lang.Throwable- DOCUMENT ME!
-
traceInit
protected void traceInit()
Called at the beginning of the trace methods.
-
-