de.grogra.imp3d
Class VertexArray

java.lang.Object
  extended by de.grogra.imp3d.VertexArray
Direct Known Subclasses:
LineArray, PolygonArray

public abstract class VertexArray
extends java.lang.Object

This abstract base class contains a list of vertex coordinates.

Author:
Ole Kniemeyer

Field Summary
 int dimension
          The number of float-values per vertex in vertices.
 java.lang.Object userObject
          This field may be used freely by user code.
 FloatList vertices
          This list contains the vertex coordinates.
 
Constructor Summary
VertexArray()
           
 
Method Summary
 int addVertex(float x, float y, float z)
           
 int addVertex(Tuple3d v)
           
 int addVertex(Tuple3f v)
           
 void computeNormal(float[] out, int v1, int v2, int v3)
          Computes the (unnormalized) normal vector for the triangle (v1, v2, v3).
 void freeArrays()
           
 void init(int dimension)
          Clears this vertex array and initializes the dimension-value.
 boolean wasCleared()
          Tests whether this list was cleared previously.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dimension

public int dimension
The number of float-values per vertex in vertices.


userObject

public java.lang.Object userObject
This field may be used freely by user code. It is not modified by methods of this class and its subclasses.


vertices

public FloatList vertices
This list contains the vertex coordinates. The coordinates are contained contiguously, with dimension float-values for each vertex.

Constructor Detail

VertexArray

public VertexArray()
Method Detail

addVertex

public int addVertex(float x,
                     float y,
                     float z)

addVertex

public int addVertex(Tuple3d v)

addVertex

public int addVertex(Tuple3f v)

computeNormal

public void computeNormal(float[] out,
                          int v1,
                          int v2,
                          int v3)
Computes the (unnormalized) normal vector for the triangle (v1, v2, v3). The corners are specified by the vertex indices v1, v2, v3 (which this method multiplies by dimension to obtain indices in the list vertices). The cross product of the vector from v1 to v2 with the vector from v1 to v3 is computed and place in out.

Parameters:
out - the resulting normal vector is placed in here
v1 - the vertex index of the first corner
v2 - the vertex index of the second corner
v3 - the vertex index of the third corner

freeArrays

public void freeArrays()

init

public void init(int dimension)
Clears this vertex array and initializes the dimension-value.

Parameters:
dimension - the new value for dimension

wasCleared

public boolean wasCleared()
Tests whether this list was cleared previously. This method returns true iff the init-method has been invoked between the last invocation of wasCleared and this invocation.

Returns:
true if this list was cleared