Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.grogra.imp3d
Class PolygonArray

    java.lang.Object
      de.grogra.imp3d.VertexArray
          de.grogra.imp3d.PolygonArray

All Implemented Interfaces:
  Mesh

    public class PolygonArray

extends VertexArray
implements Mesh

This class represents a list of polygons.

Author:
  Ole Kniemeyer

Field Summary
`boolean` | `closed` Indicates whether this polygon is a closed surface or not.
`int` | `edgeCount` Defines the number of edges of the polygons in this list.
`ByteList` | `normals` This list contains the (unnormalized) normal vectors.
`boolean` | `planar` Flag indicating whether the polygons are `planar`.
`IntList` | `polygonNormals` Specifies the normal indices of polygons if `usePolygonNormals` is `true`.
`IntList` | `polygons` Specifies the polygons.
`boolean` | `usePolygonNormals` Indicates whether normal indices are specified separately by `polygonNormals` or just like the other indices by `polygons`.
`FloatList` | `uv` This list contains the uv coordinates.
`int` | `visibleSides` Enumeration value indicating the visible polygon sides.

Fields inherited from class de.grogra.imp3d.VertexArray
`dimension, userObject, vertices`

Constructor Summary
`PolygonArray()`

Method Summary
`void` | `computeNormals()` Compute normal vector for every vertex.
`void` | `copyNormal(int from, int to)` Copies a vector in the list of normal vectors.
`void` | `freeArrays()`
`int` | `getMaxEdgeCount()` 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 at `index` and places it in `out`.
`void` | `getNormal(int index, Tuple3d out)` Gets the normal vector of normal `index`.
`int` | `getNormalCount()` Returns the number of normals of the mesh.
`int` | `getPolygon(int index, int[] indicesOut, int[] normalsOut)` Writes the vertex indices of polygon `index` to `indicesOut` and the normal indices to `normalsOut` and returns the number of vertices of the polygon.
`int` | `getPolygonCount()` Returns the number of polygons of the mesh.
`void` | `getUV(int index, Tuple2d out)` Gets the uv coordinates of vertex `index`.
`void` | `getVertex(int index, Tuple3d out)` Gets the spatial vertex coordinates of vertex `index`.
`int` | `getVertexCount()` Returns the number of vertices of the mesh.
`boolean` | `isClosed()` Indicates whether this mesh is a closed surface or not.
`boolean` | `isPolygonPlanar(int index)` Returns `true` iff the polygon number `index` 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`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### closed

    public boolean closed

  Indicates whether this polygon is a closed surface or not. If it is closed, normal vectors have to point to the exterior.

### edgeCount

    public int edgeCount

  Defines 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).

### normals

    public ByteList normals

  This list contains the (unnormalized) normal vectors. The components are contained contiguously, with three `byte`-values for each vertex. Each `byte`-value c is to be interpreted as a floating-point vector component f in the range [-1, 1] using the formula
  f = (2 c + 1) / 255

### planar

    public boolean planar

  Flag indicating whether the polygons are `planar`. 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) if `planar` is `true`.

### polygonNormals

    public IntList polygonNormals

  Specifies the normal indices of polygons if `usePolygonNormals` is `true`. For each entry in `polygons`, i.e., a vertex, a corresponding entry has to be present which defines the index into `normals`.

### polygons

    public IntList polygons

  Specifies the polygons. Each polygon is represented by a contiguous sequence of `edgeCount` indices into the other arrays (however note that if `usePolygonNormals` is `true`, normal indices are specified by `polygonNormals`). The polygons are placed one after another without space inbetween.

### usePolygonNormals

    public boolean usePolygonNormals

  Indicates whether normal indices are specified separately by `polygonNormals` or just like the other indices by `polygons`.

### uv

    public FloatList uv

  This list contains the uv coordinates. The coordinates are contained contiguously, with two `float`-values for each vertex.

### visibleSides

    public int visibleSides

  Enumeration value indicating the visible polygon sides. If this value is `Attributes.VISIBLE_SIDES_FRONT`, only front sides (as defined by the counter-clockwise order of vertices) are visible. If this is `Attributes.VISIBLE_SIDES_BACK`, only back sides are visible. For `Attributes.VISIBLE_SIDES_BOTH`, both sides are visible.

Constructor Detail

### PolygonArray

    public PolygonArray()

Method Detail

### computeNormals

    public void computeNormals()

  Compute normal vector for every vertex.

### copyNormal

    public void copyNormal(int from,
                           int to)

  Copies a vector in the list of normal vectors.

  Parameters:
    `from` - the source index
    `to` - the target index

### freeArrays

    public void freeArrays()

  Overrides:
    `freeArrays` in class `VertexArray`

### 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 interface `Mesh`
  Returns:
    maximum number of edges

### getNormal

    public void getNormal(float[] out,
                          int index)

  Reads the value of the normal vector at `index` and places it in `out`.

  Parameters:
    `out` - the result will be placed in here
    `index` - the index of the normal vector (note that the actual index into `normals` is `3 * index`)

### getNormal

    public void getNormal(int index,
                          Tuple3d out)

  Description copied from interface: `Mesh`
  Gets the normal vector of normal `index`. The normal vector is not necessarily normalized.

  Specified by:
    `getNormal` in interface `Mesh`
  Parameters:
    `index` - normal number
    `out` - normal vector will be placed in here

### getNormalCount

    public int getNormalCount()

  Description copied from interface: `Mesh`
  Returns the number of normals of the mesh.

  Specified by:
    `getNormalCount` in interface `Mesh`
  Returns:
    number of normals

### getPolygon

    public int getPolygon(int index,
                          int[] indicesOut,
                          int[] normalsOut)

  Description copied from interface: `Mesh`
  Writes the vertex indices of polygon `index` to `indicesOut` and the normal indices to `normalsOut` and returns the number of vertices of the polygon. If the mesh is closed (see `Mesh.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 interface `Mesh`
  Parameters:
    `index` - polygon number
    `indicesOut` - the vertex indices will be placed in here
    `normalsOut` - the normal indices will be placed in here
  Returns:
    number of vertex indices of polygon

### getPolygonCount

    public int getPolygonCount()

  Description copied from interface: `Mesh`
  Returns the number of polygons of the mesh.

  Specified by:
    `getPolygonCount` in interface `Mesh`
  Returns:
    number of polygons

### getUV

    public void getUV(int index,
                      Tuple2d out)

  Description copied from interface: `Mesh`
  Gets the uv coordinates of vertex `index`.

  Specified by:
    `getUV` in interface `Mesh`
  Parameters:
    `index` - vertex number
    `out` - uv coordinates will be placed in here

### getVertex

    public void getVertex(int index,
                          Tuple3d out)

  Description copied from interface: `Mesh`
  Gets the spatial vertex coordinates of vertex `index`.

  Specified by:
    `getVertex` in interface `Mesh`
  Parameters:
    `index` - vertex number
    `out` - vertex coordinates will be placed in here

### getVertexCount

    public int getVertexCount()

  Description copied from interface: `Mesh`
  Returns the number of vertices of the mesh.

  Specified by:
    `getVertexCount` in interface `Mesh`
  Returns:
    number of vertices

### 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.

  Specified by:
    `isClosed` in interface `Mesh`
  Returns:
    is surface closed?

### isPolygonPlanar

    public boolean isPolygonPlanar(int index)

  Description copied from interface: `Mesh`
  Returns `true` iff the polygon number `index` is planar.

  Specified by:
    `isPolygonPlanar` in interface `Mesh`
  Parameters:
    `index` - polygon number
  Returns:
    is polygon planar?

### 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 into `normals` is `3 * index`)
    `x` - the x-component
    `y` - the y-component
    `z` - the z-component

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD