edu.ohiou.cs456_badabing.sceneapi.basic
Class ModelFile

java.lang.Object
  extended by edu.ohiou.cs456_badabing.sceneapi.basic.ModelFile

public class ModelFile
extends java.lang.Object

Container for data loaded from OBJ and MTL files. It prepares it for use in ModelNode.

Description: Container for data loaded from OBJ and MTL files. It prepares it for use in ModelNode.

Copyright: Lev A Neiman 2008

Company: Ohio University EECS


Field Summary
 java.util.Vector<Coordinate> coordinates
          vertices in this model.
 java.util.Hashtable<java.lang.String,Material> materials
          different material properties in this model.
 java.util.Hashtable<java.lang.String,java.util.Vector<Triangle>> mtl_groups
          Hashtable which associates a material name with a group of triangles.
private  java.lang.String name
          unique name for this model.
 boolean no_mtl
           
static java.lang.String separator
          system specific file path separator.
 java.util.Vector<Coordinate> texture_coordinates
          array of texture coordinates.
 java.util.Vector<Triangle> triangles
          triangles that make up this model.
private  double x_max
           
private  double x_min
           
private  double y_max
           
private  double y_min
           
private  double z_max
           
private  double z_min
           
 
Constructor Summary
ModelFile(java.lang.String name)
           
 
Method Summary
static java.util.Vector<java.lang.String> expand(java.lang.String string, char delimeter)
          This method takes string and breaks it into a Vector of strings based on a given delimeter
 double getXMax()
          greatest value of x in all coordinates.
 double getXMin()
          least value of x in all coordiantes.
 double getYMax()
          greatest value of y in all coordinates.
 double getYMin()
          least value of y in all coordinates.
 double getZMax()
          greatest value of z in all coordinates.
 double getZMin()
          least value of z in all all coordinates.
private  void init()
          function that loads the data files.
private  void readMTL(java.util.Scanner s)
          this method loads materials from the MTL file.
private  void readOBJ(java.util.Scanner input)
          method to read OBJ file.
private  void sortMaterials()
          this method associates Material names to Vector's of triangles that belong to that material group.
static java.lang.String stripExtension(java.lang.String a)
          Removes extension from the string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private java.lang.String name
unique name for this model.


separator

public static final java.lang.String separator
system specific file path separator.


coordinates

public java.util.Vector<Coordinate> coordinates
vertices in this model.


triangles

public java.util.Vector<Triangle> triangles
triangles that make up this model.


materials

public java.util.Hashtable<java.lang.String,Material> materials
different material properties in this model.


texture_coordinates

public java.util.Vector<Coordinate> texture_coordinates
array of texture coordinates.


mtl_groups

public java.util.Hashtable<java.lang.String,java.util.Vector<Triangle>> mtl_groups
Hashtable which associates a material name with a group of triangles.


x_max

private double x_max

x_min

private double x_min

y_max

private double y_max

y_min

private double y_min

z_max

private double z_max

z_min

private double z_min

no_mtl

public boolean no_mtl
Constructor Detail

ModelFile

public ModelFile(java.lang.String name)
Parameters:
name - String name of the model to load
Method Detail

getXMax

public double getXMax()
greatest value of x in all coordinates.

Returns:
double

getXMin

public double getXMin()
least value of x in all coordiantes.

Returns:
double

getYMax

public double getYMax()
greatest value of y in all coordinates.

Returns:
double

getYMin

public double getYMin()
least value of y in all coordinates.

Returns:
double

getZMax

public double getZMax()
greatest value of z in all coordinates.

Returns:
double

getZMin

public double getZMin()
least value of z in all all coordinates.

Returns:
double

expand

public static java.util.Vector<java.lang.String> expand(java.lang.String string,
                                                        char delimeter)
This method takes string and breaks it into a Vector of strings based on a given delimeter

Parameters:
string - String
delimiter - char
Returns:
Vector

stripExtension

public static java.lang.String stripExtension(java.lang.String a)
Removes extension from the string.

Parameters:
a - String - input string.
Returns:
String - substring that is from begining of input to the last occurrence of '.'

init

private void init()
function that loads the data files.


sortMaterials

private void sortMaterials()
this method associates Material names to Vector's of triangles that belong to that material group.


readMTL

private void readMTL(java.util.Scanner s)
              throws ModelFile_ReadError
this method loads materials from the MTL file.

Parameters:
s - Scanner
Throws:
ModelFile_ReadError

readOBJ

private void readOBJ(java.util.Scanner input)
              throws ModelFile_ReadError
method to read OBJ file.

Parameters:
input - Scanner
Throws:
ModelFile_ReadError - if any excpetion is caught