unc.cdva.graphics.models
Class Face

java.lang.Object
  extended by unc.cdva.graphics.models.Face

public class Face
extends java.lang.Object

Correspond to a polygon. Stores the vertices, the normal vector, the material id, and the UV

Author:
Guillaume Conte

Constructor Summary
Face(int verticesNumber, int materialId)
          Init a Face with the id of its material, and the number of vertices
 
Method Summary
 void addPoint(javax.vecmath.Vector3f vertex, javax.vecmath.Vector2f texture, javax.vecmath.Vector3f normal)
          Add a vertex to the face, with its texture coordinate and it's normal
 int getMaterialId()
           
 javax.vecmath.Vector3f getNormal(int i)
          Get the normal of the vertex of index i
 javax.vecmath.Vector2f getTextureCoordinates(int i)
          Get the texture coordinates of the vertex of index i
 javax.vecmath.Vector3f getVertex(int i)
          Get a vertex of the face using its index
 int getVerticesNumber()
          Total number of vertices of the face
 void removePoint(javax.vecmath.Vector3f vertex)
          Remove a vertex from the face
 void setMaterialId(int materialId)
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Face

public Face(int verticesNumber,
            int materialId)
Init a Face with the id of its material, and the number of vertices

Parameters:
verticesNumber - number of vertices of the face
materialId - id of the material
Method Detail

addPoint

public void addPoint(javax.vecmath.Vector3f vertex,
                     javax.vecmath.Vector2f texture,
                     javax.vecmath.Vector3f normal)
Add a vertex to the face, with its texture coordinate and it's normal

Parameters:
vertex - coordinate of the point
texture - texture coordinate of the point
normal - normal at the point

removePoint

public void removePoint(javax.vecmath.Vector3f vertex)
Remove a vertex from the face

Parameters:
vertex - vertex to remove

size

public int size()
Returns:
number of vertices actually stored in the face

getVertex

public javax.vecmath.Vector3f getVertex(int i)
Get a vertex of the face using its index

Parameters:
i - index of the vertex
Returns:
the corresponding vertex

getTextureCoordinates

public javax.vecmath.Vector2f getTextureCoordinates(int i)
Get the texture coordinates of the vertex of index i

Parameters:
i - index of the vertex
Returns:
texture coordinates of the vertex

getNormal

public javax.vecmath.Vector3f getNormal(int i)
Get the normal of the vertex of index i

Parameters:
i - index of the vertex
Returns:
normal of the vertex

getVerticesNumber

public int getVerticesNumber()
Total number of vertices of the face

Returns:
number of vertices of the face

getMaterialId

public int getMaterialId()
Returns:
Returns the material id.

setMaterialId

public void setMaterialId(int materialId)
Parameters:
materialId - The material id to set.