saito.objloader
Class Face

java.lang.Object
  extended by saito.objloader.Face
All Implemented Interfaces:
java.lang.Comparable

public class Face
extends java.lang.Object
implements java.lang.Comparable

Author:
tatsuyas, Matt Ditton, Ekene Ijeoma Each model element contains the indexes to the vertices, normals and UV's needed to make a face

Field Summary
static java.util.Comparator<Face> FaceXComparator
           
static java.util.Comparator<Face> FaceYComparator
           
static java.util.Comparator<Face> FaceZComparator
           
 int indexType
           
 java.util.ArrayList<java.lang.Integer> normalIndices
           
 java.util.ArrayList<PVector> normals
           
 java.util.ArrayList<java.lang.Integer> uvIndices
           
 java.util.ArrayList<PVector> uvs
           
 java.util.ArrayList<java.lang.Integer> vertexIndices
           
 java.util.ArrayList<PVector> vertices
           
 
Constructor Summary
Face()
          Constructor for the Face.
 
Method Summary
 int compareTo(java.lang.Object f2)
           
 PVector getCenter()
          Get's the center position of the face.
 float getFacingAmount(PVector position)
          Returns a float value from 0 - 1.
 PVector getNormal()
          Returns the face normal.
 int getNormalCount()
           
 int getNormalIndex(int i)
           
 int[] getNormalIndices()
           
 PVector[] getNormals()
          Returns an array of normals that make up this face
 int getNormIndexCount()
           
 int getTextureIndex(int i)
           
 int[] getTextureIndices()
           
 int getUVCount()
           
 int getUVIndexCount()
           
 PVector[] getUvs()
          Returns an array of uvs that make up this face
 int getVertexCount()
           
 int getVertexIndex(int i)
           
 int[] getVertexIndices()
           
 PVector[] getVertices()
          Returns an array of PVectors that make up this face
 int getVertIndexCount()
           
 boolean isFacingPosition(PVector position)
          Used for knowing if a face is pointing in the direction of the supplied PVector.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

indexType

public int indexType

vertexIndices

public java.util.ArrayList<java.lang.Integer> vertexIndices

uvIndices

public java.util.ArrayList<java.lang.Integer> uvIndices

normalIndices

public java.util.ArrayList<java.lang.Integer> normalIndices

vertices

public java.util.ArrayList<PVector> vertices

normals

public java.util.ArrayList<PVector> normals

uvs

public java.util.ArrayList<PVector> uvs

FaceXComparator

public static java.util.Comparator<Face> FaceXComparator

FaceYComparator

public static java.util.Comparator<Face> FaceYComparator

FaceZComparator

public static java.util.Comparator<Face> FaceZComparator
Constructor Detail

Face

public Face()
Constructor for the Face. The Face class contains an a collection of arrays for the vert, normal and uv indexes. For convenience there are PVector Arrays that hold the verts, normals and uv's of the face. These arrays are only references back to the main Arrays that live in OBJModel.

Method Detail

getVertIndexCount

public int getVertIndexCount()

getNormIndexCount

public int getNormIndexCount()

getUVIndexCount

public int getUVIndexCount()

getVertexCount

public int getVertexCount()

getNormalCount

public int getNormalCount()

getUVCount

public int getUVCount()

getVertexIndices

public int[] getVertexIndices()

getNormalIndices

public int[] getNormalIndices()

getTextureIndices

public int[] getTextureIndices()

getVertices

public PVector[] getVertices()
Returns an array of PVectors that make up this face

Returns:
PVector []

getNormals

public PVector[] getNormals()
Returns an array of normals that make up this face

Returns:
PVector []

getUvs

public PVector[] getUvs()
Returns an array of uvs that make up this face

Returns:
PVector []

getCenter

public PVector getCenter()
Get's the center position of the face.

Returns:
PVector []

getNormal

public PVector getNormal()
Returns the face normal. The face normal is calculated from the face center using the cross product of the first and last vert. An alternate method would be to get the average of all vert normals. But that one you can do yourself, because in certain situations it's not reliable..

Returns:
PVector

getVertexIndex

public int getVertexIndex(int i)

getTextureIndex

public int getTextureIndex(int i)

getNormalIndex

public int getNormalIndex(int i)

isFacingPosition

public boolean isFacingPosition(PVector position)
Used for knowing if a face is pointing in the direction of the supplied PVector. In a dense mesh it can be faster to check to see if the face should be draw before drawing it. Also it can look cool.

Parameters:
position -
Returns:
True if the angle made between the face normal and position from the face center is less than 90.

getFacingAmount

public float getFacingAmount(PVector position)
Returns a float value from 0 - 1. With 1 occurring if the position is in direct line with the face normal. Likewise 0 is facing completely away from the face normal. And you guessed it. A value of 0.5 comes is from perpendicular faces.

Parameters:
position -
Returns:

compareTo

public int compareTo(java.lang.Object f2)
              throws java.lang.ClassCastException
Specified by:
compareTo in interface java.lang.Comparable
Throws:
java.lang.ClassCastException


processing library OBJLoader by Saito, Matt Ditton, Ekene Ijeoma. (c) 2010