java.lang.Object
de.grogra.imp3d.VertexArray
- Direct Known Subclasses:
LineArray
,PolygonArray
This abstract base class contains a list of vertex coordinates.
- Author:
- Ole Kniemeyer
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
addVertex
(float x, float y, float z) int
int
void
computeNormal
(float[] out, int v1, int v2, int v3) Computes the (unnormalized) normal vector for the triangle(v1, v2, v3)
.void
void
init
(int dimension) Clears this vertex array and initializes thedimension
-value.boolean
Tests whether this list was cleared previously.
-
Field Details
-
vertices
This list contains the vertex coordinates. The coordinates are contained contiguously, withdimension
float
-values for each vertex. -
dimension
public int dimensionThe number offloat
-values per vertex invertices
. -
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 thedimension
-value.- Parameters:
dimension
- the new value fordimension
-
freeArrays
public void freeArrays() -
wasCleared
public boolean wasCleared()Tests whether this list was cleared previously. This method returnstrue
iff theinit
-method has been invoked between the last invocation ofwasCleared
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 indicesv1, v2, v3
(which this method multiplies bydimension
to obtain indices in the listvertices
). The cross product of the vector fromv1
tov2
with the vector fromv1
tov3
is computed and place inout
.- Parameters:
out
- the resulting normal vector is placed in herev1
- the vertex index of the first cornerv2
- the vertex index of the second cornerv3
- the vertex index of the third corner
-
addVertex
public int addVertex(float x, float y, float z) -
addVertex
-
addVertex
-