j3d.org Code

org.j3d.util
Class TriangleUtils

java.lang.Object
  extended by org.j3d.util.TriangleUtils

public class TriangleUtils
extends java.lang.Object

An set of utility functions for taking basic triangle information and returning derived information that is useful for rendering.

The tangent generation code is derived from Eric Lengyel's Computing Tangent Space Basis Vectors for an Arbitrary Mesh http://www.terathon.com/code/tangent.html

Internationalisation Resource Names

Version:
$Revision: 1.3 $
Author:
Justin Couch

Constructor Summary
TriangleUtils()
           
 
Method Summary
static void createTangents(int numTriangles, float[] coords, float[] normals, float[] texCoords, float[] tangents)
          Generate tangent space vectors and Binormals (Bitangents).
static void createTangents(int numTriangles, int[] indices, float[] coords, float[] normals, float[] texCoords, float[] tangents)
          Generate tangent space vectors and Binormals (Bitangents).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TriangleUtils

public TriangleUtils()
Method Detail

createTangents

public static void createTangents(int numTriangles,
                                  int[] indices,
                                  float[] coords,
                                  float[] normals,
                                  float[] texCoords,
                                  float[] tangents)
Generate tangent space vectors and Binormals (Bitangents). Assumes that per-vertex normals are provided and it is index triangles.

Parameters:
numTriangles - The number of triangles to process from the index list - assuming indexed triangles and nothing more fancy like strips or fans
indices - The list of vertex indices where each i is the index, not multiplying in the 3x for flattened coords
coords - The list of coordinates to process as a flat list
normals - The list of normals, one per vertex, flattened
texCoords - The list of 2D texture coordinates, one per vertex, flattened
tangents - The array to put the returned tangents in, must be 4x the number of coordinates as it is provided in x,y,z,w form
Throws:
java.lang.NullPointerException - One of the arrays provided was null. Message contains the details of which one

createTangents

public static void createTangents(int numTriangles,
                                  float[] coords,
                                  float[] normals,
                                  float[] texCoords,
                                  float[] tangents)
Generate tangent space vectors and Binormals (Bitangents). Assumes that per-vertex normals are provided and it is a triangle array.

Parameters:
numTriangles - The number of triangles to process - assuming a triangle array
coords - The list of coordinates to process as a flat list
normals - The list of normals, one per vertex, flattened
texCoords - The list of 2D texture coordinates, one per vertex, flattened
tangents - The array to put the returned tangents in, must be 4x the number of coordinates as it is provided in x,y,z,w form
Throws:
java.lang.NullPointerException - One of the arrays provided was null. Message contains the details of which one

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org