de.javagl.swogl.geometry
Class GeometryUtils

java.lang.Object
  extended by de.javagl.swogl.geometry.GeometryUtils

public class GeometryUtils
extends java.lang.Object

A class offering utility methods for Geometries


Method Summary
static Box computeBoundingBox(Geometry geometry)
          Computes the bounding box of the given Geometry
static Box computeBoundingBox(Geometry geometry, javax.vecmath.Matrix4f matrix)
          Computes the bounding box of the given Geometry when it is transformed with the given matrix.
static void getNormals(Geometry geometry, int triangleIndex, javax.vecmath.Tuple3f n0, javax.vecmath.Tuple3f n1, javax.vecmath.Tuple3f n2)
          Write the normals of the vertices of the specified triangle of the given geometry into the given tuples
static void getTexCoords(Geometry geometry, int triangleIndex, javax.vecmath.Tuple2f t0, javax.vecmath.Tuple2f t1, javax.vecmath.Tuple2f t2)
          Write the texture coordinates of the vertices of the specified triangle of the given geometry into the given tuples
static void getVertex(Geometry geometry, int triangleIndex, int vertexNumber, javax.vecmath.Tuple3f vertex, javax.vecmath.Tuple3f normal, javax.vecmath.Tuple2f texCoord)
          Obtain the position, normal and texture coordinates of the specified vertex from the given geometry.
static void getVertices(Geometry geometry, int triangleIndex, javax.vecmath.Tuple3f v0, javax.vecmath.Tuple3f v1, javax.vecmath.Tuple3f v2)
          Write the positions of the vertices of the specified triangle of the given geometry into the given tuples
static void transform(Geometry geometry, javax.vecmath.Matrix4f matrix)
          Transform the given geometry with the given matrix
static void updateNormals(Geometry geometry)
          Update the vertex normals of the given geometry by computing the average of the normals of the triangles that are adjacent to the respective vertex.
static void writeIndicesToBuffer(Geometry geometry, java.nio.IntBuffer buffer)
          Writes the indices of the given geometry into the given buffer.
static void writeNormalsToBuffer(Geometry geometry, java.nio.FloatBuffer buffer)
          Writes the normals of the given geometry into the given buffer.
static void writeTexCoordsToBuffer(Geometry geometry, java.nio.FloatBuffer buffer)
          Writes the texture coordinates of the given geometry into the given buffer.
static void writeVerticesToBuffer(Geometry geometry, java.nio.FloatBuffer buffer)
          Writes the vertices of the given geometry into the given buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

writeIndicesToBuffer

public static void writeIndicesToBuffer(Geometry geometry,
                                        java.nio.IntBuffer buffer)
Writes the indices of the given geometry into the given buffer.

The data will be written into the buffer using absolute put methods. Thus, the position of the buffer will remain unaffected.

The buffer must be large enough to hold the data. That means, for a geometry with n triangles, it must at least have a size of n*3.

Parameters:
geometry - The geometry
buffer - The target buffer

writeVerticesToBuffer

public static void writeVerticesToBuffer(Geometry geometry,
                                         java.nio.FloatBuffer buffer)
Writes the vertices of the given geometry into the given buffer.

The data will be written into the buffer using absolute put methods. Thus, the position of the buffer will remain unaffected.

The buffer must be large enough to hold the data. That means, for a geometry with n vertices, it must at least have a size of n*3.

Parameters:
geometry - The geometry
buffer - The target buffer

writeNormalsToBuffer

public static void writeNormalsToBuffer(Geometry geometry,
                                        java.nio.FloatBuffer buffer)
Writes the normals of the given geometry into the given buffer.

The data will be written into the buffer using absolute put methods. Thus, the position of the buffer will remain unaffected.

The buffer must be large enough to hold the data. That means, for a geometry with n vertices, it must at least have a size of n*3.

Parameters:
geometry - The geometry
buffer - The target buffer

writeTexCoordsToBuffer

public static void writeTexCoordsToBuffer(Geometry geometry,
                                          java.nio.FloatBuffer buffer)
Writes the texture coordinates of the given geometry into the given buffer.

The data will be written into the buffer using absolute put methods. Thus, the position of the buffer will remain unaffected.

The buffer must be large enough to hold the data. That means, for a geometry with n vertices, it must at least have a size of n*2.

Parameters:
geometry - The geometry
buffer - The target buffer

getVertex

public static void getVertex(Geometry geometry,
                             int triangleIndex,
                             int vertexNumber,
                             javax.vecmath.Tuple3f vertex,
                             javax.vecmath.Tuple3f normal,
                             javax.vecmath.Tuple2f texCoord)
Obtain the position, normal and texture coordinates of the specified vertex from the given geometry.

Parameters:
geometry - The geometry
triangleIndex - The triangle index
vertexNumber - The number of the vertex inside the triangle
vertex - Will store the vertex position
normal - Will store the vertex normal
texCoord - Will store the vertex texture coordinates

getVertices

public static void getVertices(Geometry geometry,
                               int triangleIndex,
                               javax.vecmath.Tuple3f v0,
                               javax.vecmath.Tuple3f v1,
                               javax.vecmath.Tuple3f v2)
Write the positions of the vertices of the specified triangle of the given geometry into the given tuples

Parameters:
geometry - The geometry
triangleIndex - The triangle index
v0 - The first vertex
v1 - The second vertex
v2 - The third vertex

getTexCoords

public static void getTexCoords(Geometry geometry,
                                int triangleIndex,
                                javax.vecmath.Tuple2f t0,
                                javax.vecmath.Tuple2f t1,
                                javax.vecmath.Tuple2f t2)
Write the texture coordinates of the vertices of the specified triangle of the given geometry into the given tuples

Parameters:
geometry - The geometry
triangleIndex - The triangle index
t0 - The first texture coordinate
t1 - The second texture coordinate
t2 - The third texture coordinate

getNormals

public static void getNormals(Geometry geometry,
                              int triangleIndex,
                              javax.vecmath.Tuple3f n0,
                              javax.vecmath.Tuple3f n1,
                              javax.vecmath.Tuple3f n2)
Write the normals of the vertices of the specified triangle of the given geometry into the given tuples

Parameters:
geometry - The geometry
triangleIndex - The triangle index
n0 - The first normal
n1 - The second normal
n2 - The third normal

updateNormals

public static void updateNormals(Geometry geometry)
Update the vertex normals of the given geometry by computing the average of the normals of the triangles that are adjacent to the respective vertex.

Parameters:
geometry - The geometry

computeBoundingBox

public static Box computeBoundingBox(Geometry geometry)
Computes the bounding box of the given Geometry

Parameters:
geometry - The geometry
Returns:
The bounding box

computeBoundingBox

public static Box computeBoundingBox(Geometry geometry,
                                     javax.vecmath.Matrix4f matrix)
Computes the bounding box of the given Geometry when it is transformed with the given matrix.

Parameters:
geometry - The geometry
matrix - The matrix
Returns:
The bounding box

transform

public static void transform(Geometry geometry,
                             javax.vecmath.Matrix4f matrix)
Transform the given geometry with the given matrix

Parameters:
geometry - The geometry
matrix - The matrix