public class Face extends java.lang.Object
Object3D, defined in terms of vertex
indices. It is expected (but not enforced) that all the vertices for
the face lie within a single plane. The face will be visible from the
"front" side only, which is a function of the order in which the vertices
are specified. A special subclass, DoubleSidedFace, is visible
from both front and back.| Constructor and Description |
|---|
Face(Object3D owner,
int[] vertices)
Creates a new face with the specified vertices that is part of the 3D
owner object. |
| Modifier and Type | Method and Description |
|---|---|
float |
calculateAverageZValue(Point3D[] points)
Returns the average z-value.
|
double[] |
calculateNormal(Point3D[] points)
Calculates the normal vector for this face.
|
java.awt.geom.Path2D |
createPath(java.awt.geom.Point2D[] pts)
Creates and returns a path for the outline of this face.
|
java.awt.Color |
getColor()
A convenience method that looks up and returns the color for this face
(obtained by querying the object that owns the face).
|
int |
getOffset()
Returns the offset to add to the vertex indices.
|
boolean |
getOutline()
Returns
true if an outline should be drawn for this face,
and false otherwise. |
Object3D |
getOwner()
Returns the object that this face belongs too (as passed to the
constructor).
|
java.lang.String |
getTag()
Returns the tag for this face (always
null for this class,
subclasses may override). |
int |
getVertexCount()
Returns the number of vertices in this face.
|
int |
getVertexIndex(int i)
Returns the index for the specified vertex.
|
boolean |
isFrontFacing(java.awt.geom.Point2D[] projPts)
Returns
true if this face is front facing, and
false otherwise. |
void |
setOffset(int offset)
Sets the offset to add to the vertex indices.
|
java.lang.String |
toString()
Returns a string representation of this instance, primarily for
debugging purposes.
|
public Face(Object3D owner, int[] vertices)
owner object. Most faces will have at least three vertices,
but a special case with just two vertices (representing a line) is
permitted.owner - the object that owns the face (null not
permitted).vertices - the indices of the vertices (array length >= 2).public Object3D getOwner()
null).public int getOffset()
public void setOffset(int offset)
offset - the offset.public int getVertexCount()
public int getVertexIndex(int i)
i - the vertex index.public java.awt.Color getColor()
null).public boolean getOutline()
true if an outline should be drawn for this face,
and false otherwise. The value is obtained by querying
the object that owns the face.public java.lang.String getTag()
null for this class,
subclasses may override). The TaggedFace class overrides
this method.null.public double[] calculateNormal(Point3D[] points)
points - the vertices of the object that this face belongs to
(these can be in world or eye coordinates).public float calculateAverageZValue(Point3D[] points)
points - the points.public boolean isFrontFacing(java.awt.geom.Point2D[] projPts)
true if this face is front facing, and
false otherwise.projPts - the projection points.public java.awt.geom.Path2D createPath(java.awt.geom.Point2D[] pts)
pts - the projected points for the world (null not
permitted).public java.lang.String toString()
toString in class java.lang.Object