Class Renderer
- Direct Known Subclasses:
RayCastRenderer,ShearWarpRenderer
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
FieldsModifier and TypeFieldDescriptionprotected int[]Final rendered image (24-bit RGB stored in int). 2D: m_iRBound-by-m_iRBound imageprotected javax.vecmath.Vector3f[]For track ball rotation.protected javax.vecmath.Vector3f[]unit-length normal vectors at the voxels.protected booleanLeft-handed camera coordinate system that is initially set up to view the z=0 slice of the 3D image.(package private) booleanFor indicating that the volume input data should be reloaded.protected floatDOCUMENT ME!protected floatDOCUMENT ME!protected floatDOCUMENT ME!protected floatDOCUMENT ME!protected floatDOCUMENT ME!protected floatDOCUMENT ME!protected floatDOCUMENT ME!protected floatFor zooming and panning.protected floatFor zooming and panning.protected floatFor zooming and panning.protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected intDOCUMENT ME!protected ColorBackground color of rendered image.protected javax.vecmath.Point3fDOCUMENT ME!protected javax.vecmath.Point3feye point in world and model space.protected ModelImageInput volume.protected SoftwareLightSetused for lighting-based rendering.protected SoftwareMaterialDOCUMENT ME!protected javax.vecmath.Matrix3fDOCUMENT ME! -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRenderer(ModelImage kImage, int iRBound, int[] aiRImage) The constructor for the renderer. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 final voidconvertWorldToModel(javax.vecmath.Tuple3f kWorld, javax.vecmath.Tuple3f kModel) Convert coordinates from world space to model space.voidDisposes 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!Read the background color used for rendering images.floatRead the view port extreme value e.floatRead the z value of the eye point (0,0,z).javax.vecmath.Point3fReturn the world space coordinates for the eye point.floatgetGamma()Get the gamma correction.intThe maximum of the x-, y-, and z-dimensions of the image.intThe minimum of the x-, y-, and z-dimensions of the image.floatgetNear()Read the distance from the eye point to the view plane.booleanRead the current camera model.intThe x-dimension of the image.floatGet the x translation.intThe y-dimension of the image.floatGet the y translation.intThe z-dimension of the image.floatgetZoom()Get the zoom factor.abstract booleanReturn indication as to whether or not the input image data has been specified yet.booleanReturn 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.booleanAccessor 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(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 voidCalled at the beginning of the trace methods.abstract booleanReturn indication as to whether or not the particular renderer uses normal vectors as part of its implementation.
-
Field Details
-
m_aiRImage
protected int[] m_aiRImageFinal rendered image (24-bit RGB stored in int). 2D: m_iRBound-by-m_iRBound image -
m_akAxis
protected javax.vecmath.Vector3f[] m_akAxisFor track ball rotation. -
m_akNormal
protected javax.vecmath.Vector3f[] m_akNormalunit-length normal vectors at the voxels. -
m_bParallel
protected boolean m_bParallelLeft-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_fGammaDOCUMENT ME! -
m_fFMult
protected float m_fFMultDOCUMENT ME! -
m_fNear
protected float m_fNearDOCUMENT ME! -
m_fAngle
protected float m_fAngleDOCUMENT ME! -
m_fExtreme
protected float m_fExtremeDOCUMENT ME! -
m_fRScaleX
protected float m_fRScaleXDOCUMENT ME! -
m_fRScaleY
protected float m_fRScaleYDOCUMENT ME! -
m_fZoom
protected float m_fZoomFor zooming and panning. -
m_fXTrn
protected float m_fXTrnFor zooming and panning. -
m_fYTrn
protected float m_fYTrnFor zooming and panning. -
m_iMinBound
protected int m_iMinBoundDOCUMENT ME! -
m_iMaxBound
protected int m_iMaxBoundDOCUMENT ME! -
m_iRBound
protected int m_iRBoundDOCUMENT ME! -
m_iXBound
protected int m_iXBoundDOCUMENT ME! -
m_iYBound
protected int m_iYBoundDOCUMENT ME! -
m_iZBound
protected int m_iZBoundDOCUMENT ME! -
m_iXBoundM1
protected int m_iXBoundM1DOCUMENT ME! -
m_iYBoundM1
protected int m_iYBoundM1DOCUMENT ME! -
m_iZBoundM1
protected int m_iZBoundM1DOCUMENT ME! -
m_iXBoundM2
protected int m_iXBoundM2DOCUMENT ME! -
m_iYBoundM2
protected int m_iYBoundM2DOCUMENT ME! -
m_iZBoundM2
protected int m_iZBoundM2DOCUMENT ME! -
m_iXYProduct
protected int m_iXYProductDOCUMENT ME! -
m_iXYZProduct
protected int m_iXYZProductDOCUMENT ME! -
m_kBackgroundColor
Background color of rendered image. -
m_kEyeModel
protected javax.vecmath.Point3f m_kEyeModelDOCUMENT ME! -
m_kEyeWorld
protected javax.vecmath.Point3f m_kEyeWorldeye point in world and model space. -
m_kImage
Input volume. -
m_kLightSet
used for lighting-based rendering. -
m_kMaterial
DOCUMENT ME! -
m_kRotate
protected javax.vecmath.Matrix3f m_kRotateDOCUMENT ME! -
m_bReloadInput
boolean m_bReloadInputFor indicating that the volume input data should be reloaded.
-
-
Constructor Details
-
Renderer
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 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
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
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
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 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 coordinateskModel- Tuple3f output world space coordinates
-
finalize
Calls dispose. -
traceInit
protected void traceInit()Called at the beginning of the trace methods.
-