com.jme.util.geom
Class NonIndexedNormalGenerator

java.lang.Object
  extended by com.jme.util.geom.NonIndexedNormalGenerator

public class NonIndexedNormalGenerator
extends java.lang.Object

A utility class to generate normals for a set of vertices. The triangles must be defined by just the vertices, so that every 3 consecutive vertices define one triangle. However, an index array must be specified to identify identical vertices properly (see method generateNormals(float[], int[], float). If the index aray is not specified, the vertex normals are currently simply taken from the faces they belong to (this might be changed in the future, so that vertices are compared by their values).

Version:
2008-03-11
Author:
Michael Sattler

Constructor Summary
NonIndexedNormalGenerator()
           
 
Method Summary
 float[] generateNormals(float[] vertices, int[] indices, float creaseAngle)
          Calculates the normals for a set of faces determined by the specified vertices.
 void generateNormals(TriMesh mesh)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NonIndexedNormalGenerator

public NonIndexedNormalGenerator()
Method Detail

generateNormals

public float[] generateNormals(float[] vertices,
                               int[] indices,
                               float creaseAngle)
Calculates the normals for a set of faces determined by the specified vertices. Every 3 consecutive vertices define one triangle.
Please note: This method uses class fields and is not synchronized! Therefore it should only be called from a single thread, unless synchronization is taken care of externally.

Parameters:
vertices - The vertex coordinates. Every three values define one vertex
indices - An array containing int values. Each value belongs to one vertex in the vertices array, the values are stored in the same order as the vertices. For equal vertices in the vertices array, the indices are also equal.
creaseAngle - The maximum angle in radians between faces to which normals between the faces are interpolated to create a smooth transition
Returns:
An array containing the generated normals for the geometry

generateNormals

public void generateNormals(TriMesh mesh)