|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object vmm.core3D.Grid3D
public class Grid3D
A Grid3D represents a surface in three-space as an array of vectors. The first index of the array represents the "u" direction on the surface, while the second index represents the "v" directions. Methods are provided for drawing the surface a View3D or View3DLit. The surface is considered to be made up of "patches" which can be further divided into "subpatches". The surface can be drawn in wireframe form, by drawing each sub-patch, or just by drawing the large patches. When drawn in patch form, the lighting of the surface is derived from the View in which it is drawn. The intrinsic color of each individual patch can be set as part of the surface data. Drawing of the Grid3D will normally be done by calling methods in View3D and View3DLit, which will make sure that the data needed to complete the drawing correctly is done correctly.
It is possible to construct a surface from several copies of a basic grid, where each copy is
obtained by applying a TransformMatrix to the basic grid. These transforms are specified by
the method addGridTransform(GridTransformMatrix)
. See also setUseIdentityTransform(boolean)
.
Constructor Summary | |
---|---|
Grid3D(int uPatchCount,
int vPatchCount)
Creates a surface grid with the specified numbers of patches in the U and V directions and with 6 subpatches per patch (in each direction). |
|
Grid3D(int uPatchCount,
int vPatchCount,
int subPatchesPerPatch)
Creates a surface grid with the specified numbers of patches in the U and V directions and with a specified number of subpatches per patch (in each direction). |
Method Summary | |
---|---|
void |
addGridTransform(GridTransformMatrix transform)
Adds a transformed copy of the basic grid to the surface. |
void |
applyTransform(Transform3D transform,
View3D view3D)
Applies a transform the all vertices of the surface, to produce a set of transformed vertices. |
void |
clearNormals()
Removes all normal vectors that were set using setNormal(int, int, Vector3D) . |
void |
clearPatchColors()
Resets all individual patch colors, as set by setPatchColor(int, int, Color) , to
the default value. |
void |
discardGridTransforms()
Discards any grid transforms that have been added by addGridTransform(GridTransformMatrix) . |
void |
drawCurves(View3D view,
java.awt.Graphics2D g)
Draws a wireframe rendering of the surface by drawing some or all of the grid lines in the U and V directions. |
void |
drawMajorPatches(View3DLit view,
java.awt.Graphics2D g)
Draws a "rough" version of the surface by drawing the (major) patches rather than the subpatches. |
void |
drawSubPatches(View3DLit view,
java.awt.Graphics2D g,
double startPercent,
double endPercent)
Draws some or all of the subpatches that make up the surface as shaded, lighted color patches. |
java.awt.Color |
getDefaultBackColor()
Get the default color for the back face of a patch. |
java.awt.Color |
getDefaultPatchColor()
Get the default patch color. |
Vector3D |
getNormal(int uIndex,
int vIndex)
Returns a normal vector (not assumed to be a unit vector) at a specified vertex of the basic grid. |
java.awt.Color |
getPatchColor(int uIndex,
int vIndex,
boolean frontFace)
Gets the intrinsic color of a subpatch. |
int |
getPatchCountInGrid()
Gets the total number of (major) patches in the basic grid. |
int |
getPatchCountInSurface()
Gets the total number of (major) patches in the surface, which might consist of several copies of the baic grid. |
int |
getSubPatchCountInGrid()
Gets the total number of subpatches in the basic grid. |
int |
getSubPatchCountInSurface()
Gets the total number of subpatches in the surface, which might consist of several copies of the baic grid. |
int |
getSubpatchesPerPatch()
Gets the number of subpatches that lie along each edge of a (major) patch, as specified in the constructor. |
int |
getUCount()
Gets the number of vertices along the U direction of the basic grid. |
int |
getUCurveIncrement()
Gets the U increment value, which is used to decide which grid lines to draw. |
Vector3D |
getUnitNormal(int uIndex,
int vIndex)
Returns a unit normal vector at a specified vertex in the basic grid. |
int |
getUPatchCount()
Gets the number of (major) patches in the U direction, as specfied in the contructor or in setPatchCount(int, int) . |
boolean |
getUseIdentityTransform()
Gets the value of the useIdentityTransform property. |
int |
getVCount()
Gets the number of vertices along the V direction of the basic grid. |
int |
getVCurveIncrement()
Gets the V increment value, which is used to decide which grid lines to draw. |
Vector3D |
getVertex(int uIndex,
int vIndex)
Get one of the points in the basic grid. |
int |
getVPatchCount()
Gets the number of (major) patches in the V direction, as specfied in the contructor or in setPatchCount(int, int) . |
void |
setDefaultBackColor(java.awt.Color defaultBackColor)
Set the default color for the back face of a patch. |
void |
setDefaultPatchColor(java.awt.Color c)
Set the default color that is used as the intrinsic color of a patch for which no other color has been set. |
void |
setNormal(int uIndex,
int vIndex,
Vector3D normalVector)
Set a normal vector at one of the vertices in the basic grid. |
void |
setPatchColor(int uIndex,
int vIndex,
java.awt.Color c)
Sets the intrinsic color of a subpatch. |
void |
setUCurveIncrement(int curveIncrement)
Sets the U increment value, which is used to decide which grid lines to draw. |
void |
setUseIdentityTransform(boolean useIdentityTransform)
Sets the value of the useIdentityTransform property. |
void |
setVCurveIncrement(int curveIncrement)
Sets the V increment value, which is used to decide which grid lines to draw. |
void |
setVertex(int uIndex,
int vIndex,
Vector3D v)
Assign one of the points in the basic grid. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Grid3D(int uPatchCount, int vPatchCount)
setVertex(int, int, Vector3D)
.
uPatchCount
- the number of major patches in the U direction. The number of subpatches is 6*uPatchCount. Must be positive.vPatchCount
- the number of major patches in the V direction. The number of subpatches is 6*vPatchCount. Must be positive.public Grid3D(int uPatchCount, int vPatchCount, int subPatchesPerPatch)
setVertex(int, int, Vector3D)
.
uPatchCount
- the number of major patches in the U direction. The number of subpatches is subPatchesPerPatch*uPatchCount. Must be positive.vPatchCount
- the number of major patches in the V direction. The number of subpatches is subPatchesPerPatch*vPatchCount. Must be positive.subPatchesPerPatch
- the number of sub-patches that lie along each side of a patch. Note that the actual number of
subpatches in a patch is the square of this number.Method Detail |
---|
public void addGridTransform(GridTransformMatrix transform)
transform
- A transform matrix that is applied to the basic grid to produce a transformed copy.
This should be non-null (but null values are simply ignored).public void discardGridTransforms()
addGridTransform(GridTransformMatrix)
.
public boolean getUseIdentityTransform()
setUseIdentityTransform(boolean)
public void setUseIdentityTransform(boolean useIdentityTransform)
addGridTransform(GridTransformMatrix)
method. If the value of this property is set to
false, then the basic grid is NOT part of the data -- that is, the surface represented by this
Grid3D object consists ONLY of the transformed copies of the basic grid.
public final void setVertex(int uIndex, int vIndex, Vector3D v)
uIndex
- The first index of the array position that is being set.
This index ranges from 0 to the value of getUCount()
minus 1.vIndex
- The second index of the array position that is being set.
This index ranges from 0 to the value of getVCount()
minus 1.v
- The vector the gives the coordinates of the point on the surface. A pointer to this vector, not a copy
of the vector, is stored. This parameter can be null, indicating a missing point on the surface. In that case,
any grid line or patch that has the point as a vertex is not drawn.public final Vector3D getVertex(int uIndex, int vIndex)
setVertex(int, int, Vector3D)
public int getUCount()
getUCount()-1
while subpatches are numbered from 0 to getUCount()-2
in the U direction.
public int getUPatchCount()
setPatchCount(int, int)
.
The number of vertices in the U direction is this value multiplied by subPatchesPerPatch.
public int getVCount()
getVCount()-1
while subpatches are numbered from 0 to getVCount()-2
in the U direction.
public int getVPatchCount()
setPatchCount(int, int)
.
The number of subpatches in the V direction is this value multiplied by subPatchesPerPatch.
public int getSubPatchCountInGrid()
(getUCount()-1)*(getVCount()-1)
.
It is also the same as getPatchCount()*subPatchesPerPatch*subPatchesPerPatch
public int getPatchCountInGrid()
getUPatchCount()*getVPatchCount()
public int getSubPatchCountInSurface()
(getUCount()-1)*(getVCount()-1)
.
public int getPatchCountInSurface()
getUPatchCount()*getVPatchCount()
public int getSubpatchesPerPatch()
public int getUCurveIncrement()
setUCurveIncrement(int)
public void setUCurveIncrement(int curveIncrement)
curveIncrement
- the U increment value. Any value less than zero is changed to zero.public int getVCurveIncrement()
setUCurveIncrement(int)
public void setVCurveIncrement(int curveIncrement)
curveIncrement
- the V increment value. Any value less than zero is changed to zero.public void setPatchColor(int uIndex, int vIndex, java.awt.Color c)
uIndex
- The u index of the subpatch, in the range 0 to getUCount()-2
vIndex
- The v index of the subpatch, in the range 0 to getVCount()-2
c
- The new color of the patch, or zero to use the default color.setDefaultPatchColor(Color)
public java.awt.Color getPatchColor(int uIndex, int vIndex, boolean frontFace)
uIndex
- The u index of the subpatch, in the range 0 to getUCount()-2
vIndex
- The v index of the subpatch, in the range 0 to getVCount()-2
frontFace
- Tells whether this is a front or back facesetPatchColor(int, int, Color)
public void clearPatchColors()
setPatchColor(int, int, Color)
, to
the default value.
public void setNormal(int uIndex, int vIndex, Vector3D normalVector)
uIndex
- the u index of the vertex, in the range 0 to getUCount()
, inclusivevIndex
- the v index of the vertex, in the range 0 to getVCount()
, inclusivenormalVector
- the vector at vertex at position (uIndex,vIndex). This can be null; in that
case, an approximate normal vector is computed using vectors to neighboring points on the surface.getNormal(int, int)
,
getUnitNormal(int, int)
public Vector3D getNormal(int uIndex, int vIndex)
setNormal(int, int, Vector3D)
,
then that vector is returned. Otherwise, an approximate normal vector is computed vectors from
the specified vertex to two neighboring vertices on the surface.
uIndex
- the u index of the vertex, in the range 0 to getUCount()
, inclusivevIndex
- the v index of the vertex, in the range 0 to getVCount()
, inclusivepublic Vector3D getUnitNormal(int uIndex, int vIndex)
getNormal(int, int)
.
However, if this yields an undefined result, a default value of (1,0,0)
is returned.
uIndex
- the u index of the vertex, in the range 0 to getUCount()
, inclusivevIndex
- the v index of the vertex, in the range 0 to getVCount()
, inclusivepublic void clearNormals()
setNormal(int, int, Vector3D)
.
public void setDefaultPatchColor(java.awt.Color c)
setPatchColor(int, int, Color)
.
c
- the default patch color; if null, white is used as the default colorpublic java.awt.Color getDefaultPatchColor()
setDefaultPatchColor(Color)
public java.awt.Color getDefaultBackColor()
setDefaultBackColor(Color)
public void setDefaultBackColor(java.awt.Color defaultBackColor)
setPatchColor(int, int, Color)
method.
defaultBackColor
- The default backface color; if null, the back color is the same as the front color.public void applyTransform(Transform3D transform, View3D view3D)
view3D
- used for clippingpublic void drawCurves(View3D view, java.awt.Graphics2D g)
applyTransform(Transform3D, View3D)
has been called.
setUCurveIncrement(int)
,
setVCurveIncrement(int)
public void drawSubPatches(View3DLit view, java.awt.Graphics2D g, double startPercent, double endPercent)
View3DLit.drawSurface(Grid3D, double, double)
and will probably not
be used directly. If it is, it is essential that applyTransform(Transform3D, View3D)
be called
before this method is called. The startPercent and endPercent are in the range 0 to 1, and they
specify the subset of patches that are to be drawn.
Lighting settings from the View3DLit are applied to the patches that are drawn.
This method must be called after applyTransform(Transform3D, View3D)
.
public void drawMajorPatches(View3DLit view, java.awt.Graphics2D g)
View3DLit.drawSurface(Grid3D, double, double)
and will probably not
be used directly. If it is, it is essential that applyTransform(Transform3D, View3D)
be called
before this method is called.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |