net.jinx.video.model
Class MeshElement

java.lang.Object
  extended by net.jinx.video.model.MeshElement
Direct Known Subclasses:
LineElement, Polygon, Quads, QuadStrip, TriangleFan, Triangles, TriangleStrip

public abstract class MeshElement
extends java.lang.Object

MeshElement is the abstract super-class of all classes that contain vertices for Models.

API Stability: Stable.


Method Summary
abstract  int draw(Context opt, float[][] normals, float[][] texCoord, Coloration coloration, int offset)
          Draws the mesh, using the given array of Materials.
abstract  Face[] getFaces()
          Provides an array of all the Faces formed by this MeshElement.
 float[][] getVertices()
          Provides an array of vertices.
 LineElement toLineElement(float width)
          Converts this MeshElement into a line-based MeshElement.
 int vertexCount()
          Provides a count of the vertices contained within this MeshElement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getVertices

public float[][] getVertices()
Provides an array of vertices. Each vertex is a length three array of floats. These are returned as an array of float arrays.


vertexCount

public int vertexCount()
Provides a count of the vertices contained within this MeshElement.

Returns:
the number of vertices contained within this MeshElement.

draw

public abstract int draw(Context opt,
                         float[][] normals,
                         float[][] texCoord,
                         Coloration coloration,
                         int offset)
Draws the mesh, using the given array of Materials. One Material will be used per vertex, unless there is only one, in which case the same color will be used for each vertex. The offset into the array will be incremented with each vertex and then returned once the Mesh has finished drawing.

Parameters:
opt - the rendering options to use.
normals - vectors in a vertex array for per-vertex normals. If null, this indicates that per-face normals should be used instead.
coloration - the Coloration object to use to color the vertices.
offset - the index into normal array to start at. This is also the current vertex number.
Returns:
the index of the next normal to use, once this method has completed. This is also the number of the next vertex.

getFaces

public abstract Face[] getFaces()
Provides an array of all the Faces formed by this MeshElement. This is used to calculate per-vertex normals for lighting.

Returns:
the array of Face objects.

toLineElement

public LineElement toLineElement(float width)
Converts this MeshElement into a line-based MeshElement. If this is already a LineElement, then it is returned without anything being done.

Returns:
this MeshElement itself (if it's already a LineElement) or a Lines version of this MeshElement (if this is based on polygons).