de.javagl.utils.obj.impl
Class DefaultObj

java.lang.Object
  extended by de.javagl.utils.obj.impl.DefaultObj
All Implemented Interfaces:
Obj, ObjTarget

public class DefaultObj
extends Object
implements Obj, ObjTarget

Default implementation of an Obj and an ObjTarget.


Constructor Summary
DefaultObj()
          Creates a new, empty DefaultObj.
 
Method Summary
 void addFace(ObjFace face)
          Add the given face to this ObjTarget
 void addGroup(ObjGroup group)
          Add the given group to this ObjTarget
 void addMaterialGroup(ObjGroup group)
          Add the given material group to this ObjTarget
 void addNormal(FloatTuple normal)
          Add the given normal to this ObjTarget
 void addTexCoord(FloatTuple texCoord)
          Add the given texture coordinate to this ObjTarget
 void addVertex(FloatTuple vertex)
          Add the given vertex to this ObjTarget
 boolean equals(Object obj)
           
 ObjFace getFace(int index)
          Returns the face with the given index.
 ObjGroup getGroup(int index)
          Returns the group with the given index.
 ObjGroup getGroup(String name)
          Returns the group with the given name.
 ObjGroup getMaterialGroup(int index)
          Returns the material group with the given index.
 ObjGroup getMaterialGroup(String name)
          Returns the material group with the given name.
 String getMtlFileName()
          Returns the name of the MTL file that is associated with this Obj.
 FloatTuple getNormal(int index)
          Returns the normal with the given index.
 int getNumFaces()
          Returns the number of faces in the Obj.
 int getNumGroups()
          Returns the number of groups in this Obj.
 int getNumMaterialGroups()
          Returns the number of material groups in this Obj.
 int getNumNormals()
          Returns the number of normals in the Obj.
 int getNumTexCoords()
          Returns the number of texture coordinates in the Obj.
 int getNumVertices()
          Returns the number of vertices in the Obj.
 FloatTuple getTexCoord(int index)
          Returns the texture coordinate with the given index.
 FloatTuple getVertex(int index)
          Returns the vertex with the given index.
 int hashCode()
           
 void printInfo()
          Debug method: Prints some information about the contents of this Obj.
 void setMtlFileName(String mtlFileName)
          Set the given MTL file name that was read from the 'mtllib' line of the OBJ file.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultObj

public DefaultObj()
Creates a new, empty DefaultObj.

Method Detail

getNumVertices

public int getNumVertices()
Description copied from interface: Obj
Returns the number of vertices in the Obj.

Specified by:
getNumVertices in interface Obj
Returns:
The number of vertices in the Obj.

getVertex

public FloatTuple getVertex(int index)
Description copied from interface: Obj
Returns the vertex with the given index. Note that the index is ZERO-based, in contrast to the ONE-based indices of the actual OBJ file.

Specified by:
getVertex in interface Obj
Parameters:
index - The index of the vertex
Returns:
The vertex with the given index

getNumTexCoords

public int getNumTexCoords()
Description copied from interface: Obj
Returns the number of texture coordinates in the Obj.

Specified by:
getNumTexCoords in interface Obj
Returns:
The number of texture coodrinates in the Obj.

getTexCoord

public FloatTuple getTexCoord(int index)
Description copied from interface: Obj
Returns the texture coordinate with the given index. Note that the index is ZERO-based, in contrast to the ONE-based indices of the actual OBJ file.

Specified by:
getTexCoord in interface Obj
Parameters:
index - The index of the texture coordinate
Returns:
The texture coordinate with the given index

getNumNormals

public int getNumNormals()
Description copied from interface: Obj
Returns the number of normals in the Obj.

Specified by:
getNumNormals in interface Obj
Returns:
The number of normals in the Obj.

getNormal

public FloatTuple getNormal(int index)
Description copied from interface: Obj
Returns the normal with the given index. Note that the index is ZERO-based, in contrast to the ONE-based indices of the actual OBJ file.

Specified by:
getNormal in interface Obj
Parameters:
index - The index of the normal
Returns:
The normal with the given index

getNumFaces

public int getNumFaces()
Description copied from interface: Obj
Returns the number of faces in the Obj.

Specified by:
getNumFaces in interface Obj
Returns:
The number of faces in the Obj.

getFace

public ObjFace getFace(int index)
Description copied from interface: Obj
Returns the face with the given index.

Specified by:
getFace in interface Obj
Parameters:
index - The index of the face.
Returns:
The face with the given index

getNumGroups

public int getNumGroups()
Description copied from interface: Obj
Returns the number of groups in this Obj.

Specified by:
getNumGroups in interface Obj
Returns:
The number of groups in this Obj.

getGroup

public ObjGroup getGroup(int index)
Description copied from interface: Obj
Returns the group with the given index.

Specified by:
getGroup in interface Obj
Parameters:
index - The index of the group.
Returns:
The group with the given index.

getGroup

public ObjGroup getGroup(String name)
Description copied from interface: Obj
Returns the group with the given name.

Specified by:
getGroup in interface Obj
Parameters:
name - The name of the group.
Returns:
The group with the given name.

getNumMaterialGroups

public int getNumMaterialGroups()
Description copied from interface: Obj
Returns the number of material groups in this Obj.

Specified by:
getNumMaterialGroups in interface Obj
Returns:
The number of material groups in this Obj.

getMaterialGroup

public ObjGroup getMaterialGroup(int index)
Description copied from interface: Obj
Returns the material group with the given index.

Specified by:
getMaterialGroup in interface Obj
Parameters:
index - The index of the material group.
Returns:
The material group with the given index.

getMaterialGroup

public ObjGroup getMaterialGroup(String name)
Description copied from interface: Obj
Returns the material group with the given name.

Specified by:
getMaterialGroup in interface Obj
Parameters:
name - The name of the material group.
Returns:
The material group with the given name.

getMtlFileName

public String getMtlFileName()
Description copied from interface: Obj
Returns the name of the MTL file that is associated with this Obj.

Specified by:
getMtlFileName in interface Obj
Returns:
The name of the MTL file.

addFace

public void addFace(ObjFace face)
Description copied from interface: ObjTarget
Add the given face to this ObjTarget

Specified by:
addFace in interface ObjTarget
Parameters:
face - The face to add.

addGroup

public void addGroup(ObjGroup group)
Description copied from interface: ObjTarget
Add the given group to this ObjTarget

Specified by:
addGroup in interface ObjTarget
Parameters:
group - The group to add.

addMaterialGroup

public void addMaterialGroup(ObjGroup group)
Description copied from interface: ObjTarget
Add the given material group to this ObjTarget

Specified by:
addMaterialGroup in interface ObjTarget
Parameters:
group - The material group to add.

addVertex

public void addVertex(FloatTuple vertex)
Description copied from interface: ObjTarget
Add the given vertex to this ObjTarget

Specified by:
addVertex in interface ObjTarget
Parameters:
vertex - The vertex to add.

addTexCoord

public void addTexCoord(FloatTuple texCoord)
Description copied from interface: ObjTarget
Add the given texture coordinate to this ObjTarget

Specified by:
addTexCoord in interface ObjTarget
Parameters:
texCoord - The texture coordinate to add.

addNormal

public void addNormal(FloatTuple normal)
Description copied from interface: ObjTarget
Add the given normal to this ObjTarget

Specified by:
addNormal in interface ObjTarget
Parameters:
normal - The normal to add.

setMtlFileName

public void setMtlFileName(String mtlFileName)
Description copied from interface: ObjTarget
Set the given MTL file name that was read from the 'mtllib' line of the OBJ file.

Specified by:
setMtlFileName in interface ObjTarget
Parameters:
mtlFileName - The name of the MTL file

printInfo

public void printInfo()
Debug method: Prints some information about the contents of this Obj. Not a real part of the public API.


toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object