Module imp3d

Class VertexArray

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

public abstract class VertexArray extends Object
This abstract base class contains a list of vertex coordinates.
Author:
Ole Kniemeyer
  • Field Details

    • vertices

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

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

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

    • VertexArray

      public VertexArray()
  • Method Details

    • init

      public void init(int dimension)
      Clears this vertex array and initializes the dimension-value.
      Parameters:
      dimension - the new value for dimension
    • freeArrays

      public void freeArrays()
    • 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
    • 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
    • addVertex

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

      public int addVertex(Tuple3f v)
    • addVertex

      public int addVertex(Tuple3d v)