java.lang.Object
de.grogra.imp3d.VertexArray
de.grogra.imp3d.PolygonArray
- All Implemented Interfaces:
Mesh
This class represents a list of polygons.
- Author:
- Ole Kniemeyer
-
Field Summary
FieldsModifier and TypeFieldDescriptionboolean
Indicates whether this polygon is a closed surface or not.int
Defines the number of edges of the polygons in this list.This list contains the (unnormalized) normal vectors.boolean
Flag indicating whether the polygons areplanar
.Specifies the normal indices of polygons ifusePolygonNormals
istrue
.Specifies the polygons.boolean
Indicates whether normal indices are specified separately bypolygonNormals
or just like the other indices bypolygons
.This list contains the uv coordinates.int
Enumeration value indicating the visible polygon sides.Fields inherited from class de.grogra.imp3d.VertexArray
dimension, userObject, vertices
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Compute normal vector for every vertex.void
copyNormal
(int from, int to) Copies a vector in the list of normal vectors.void
int
Returns the maximum number of edges of a single polygon of the mesh.void
getNormal
(float[] out, int index) Reads the value of the normal vector atindex
and places it inout
.void
Gets the normal vector of normalindex
.int
Returns the number of normals of the mesh.int
getPolygon
(int index, int[] indicesOut, int[] normalsOut) Writes the vertex indices of polygonindex
toindicesOut
and the normal indices tonormalsOut
and returns the number of vertices of the polygon.int
Returns the number of polygons of the mesh.void
Gets the uv coordinates of vertexindex
.void
Gets the spatial vertex coordinates of vertexindex
.int
Returns the number of vertices of the mesh.boolean
isClosed()
Indicates whether this mesh is a closed surface or not.boolean
isPolygonPlanar
(int index) Returnstrue
iff the polygon numberindex
is planar.void
setNormal
(int index, float x, float y, float z) Sets a normal vector.Methods inherited from class de.grogra.imp3d.VertexArray
addVertex, addVertex, addVertex, computeNormal, init, wasCleared
-
Field Details
-
uv
This list contains the uv coordinates. The coordinates are contained contiguously, with twofloat
-values for each vertex. -
normals
This list contains the (unnormalized) normal vectors. The components are contained contiguously, with threebyte
-values for each vertex. Eachbyte
-value c is to be interpreted as a floating-point vector component f in the range [-1, 1] using the formulaf = (2 c + 1) / 255 -
polygons
Specifies the polygons. Each polygon is represented by a contiguous sequence ofedgeCount
indices into the other arrays (however note that ifusePolygonNormals
istrue
, normal indices are specified bypolygonNormals
). The polygons are placed one after another without space inbetween. -
polygonNormals
Specifies the normal indices of polygons ifusePolygonNormals
istrue
. For each entry inpolygons
, i.e., a vertex, a corresponding entry has to be present which defines the index intonormals
. -
usePolygonNormals
public boolean usePolygonNormalsIndicates whether normal indices are specified separately bypolygonNormals
or just like the other indices bypolygons
. -
edgeCount
public int edgeCountDefines the number of edges of the polygons in this list. All polygons have the same number of edges.edgeCount
may only be 3 (triangles) or 4 (quadrilaterals). -
planar
public boolean planarFlag indicating whether the polygons areplanar
. In the case of triangles, this is always the case. In the case of quadrilaterals, it is guaranteed that each quadrilateral will be planar (all vertices lie on a plane) ifplanar
istrue
. -
visibleSides
public int visibleSidesEnumeration value indicating the visible polygon sides. If this value isAttributes.VISIBLE_SIDES_FRONT
, only front sides (as defined by the counter-clockwise order of vertices) are visible. If this isAttributes.VISIBLE_SIDES_BACK
, only back sides are visible. ForAttributes.VISIBLE_SIDES_BOTH
, both sides are visible. -
closed
public boolean closedIndicates whether this polygon is a closed surface or not. If it is closed, normal vectors have to point to the exterior.
-
-
Constructor Details
-
PolygonArray
public PolygonArray()
-
-
Method Details
-
freeArrays
public void freeArrays()- Overrides:
freeArrays
in classVertexArray
-
copyNormal
public void copyNormal(int from, int to) Copies a vector in the list of normal vectors.- Parameters:
from
- the source indexto
- the target index
-
setNormal
public void setNormal(int index, float x, float y, float z) Sets a normal vector. The vector is rescaled so that the maximum of the absolute values of its components is one.- Parameters:
index
- the index of the normal vector (note that the actual index intonormals
is3 * index
)x
- the x-componenty
- the y-componentz
- the z-component
-
getNormal
public void getNormal(float[] out, int index) Reads the value of the normal vector atindex
and places it inout
.- Parameters:
out
- the result will be placed in hereindex
- the index of the normal vector (note that the actual index intonormals
is3 * index
)
-
getPolygonCount
public int getPolygonCount()Description copied from interface:Mesh
Returns the number of polygons of the mesh.- Specified by:
getPolygonCount
in interfaceMesh
- Returns:
- number of polygons
-
getMaxEdgeCount
public int getMaxEdgeCount()Description copied from interface:Mesh
Returns the maximum number of edges of a single polygon of the mesh.- Specified by:
getMaxEdgeCount
in interfaceMesh
- Returns:
- maximum number of edges
-
getVertexCount
public int getVertexCount()Description copied from interface:Mesh
Returns the number of vertices of the mesh.- Specified by:
getVertexCount
in interfaceMesh
- Returns:
- number of vertices
-
getNormalCount
public int getNormalCount()Description copied from interface:Mesh
Returns the number of normals of the mesh.- Specified by:
getNormalCount
in interfaceMesh
- Returns:
- number of normals
-
isPolygonPlanar
public boolean isPolygonPlanar(int index) Description copied from interface:Mesh
Returnstrue
iff the polygon numberindex
is planar.- Specified by:
isPolygonPlanar
in interfaceMesh
- Parameters:
index
- polygon number- Returns:
- is polygon planar?
-
getPolygon
public int getPolygon(int index, int[] indicesOut, int[] normalsOut) Description copied from interface:Mesh
Writes the vertex indices of polygonindex
toindicesOut
and the normal indices tonormalsOut
and returns the number of vertices of the polygon. If the mesh is closed (seeMesh.isClosed()
), inside and outside are determined by the ordering of the vertices: when seen from the outside, vertices have to be oriented in a counter-clockwise manner. Then also the normal vectors have to point to the outside.- Specified by:
getPolygon
in interfaceMesh
- Parameters:
index
- polygon numberindicesOut
- the vertex indices will be placed in herenormalsOut
- the normal indices will be placed in here- Returns:
- number of vertex indices of polygon
-
getVertex
Description copied from interface:Mesh
Gets the spatial vertex coordinates of vertexindex
. -
getNormal
Description copied from interface:Mesh
Gets the normal vector of normalindex
. The normal vector is not necessarily normalized. -
getUV
Description copied from interface:Mesh
Gets the uv coordinates of vertexindex
. -
isClosed
public boolean isClosed()Description copied from interface:Mesh
Indicates whether this mesh is a closed surface or not. If it is closed, normal vectors have to point to the exterior. -
computeNormals
public void computeNormals()Compute normal vector for every vertex.
-