glmodel
Class GLMaterialLib

java.lang.Object
  extended by glmodel.GLMaterialLib

public class GLMaterialLib
extends java.lang.Object

Loads a library of materials from a .mtl file into an array of GLMaterial objects.


Field Summary
 java.lang.String filename
           
 java.lang.String filepath
           
 
Constructor Summary
GLMaterialLib(java.lang.String mtlFilename)
           
 
Method Summary
 GLMaterial find(java.lang.String materialName)
          find a material by name in an array of GLMaterial objects
 int findID(java.lang.String materialName)
          find a material by name in an array of GLMaterial objects return the array index of the material
 GLMaterial getClone(GLMaterial mtl)
          return a duplicate of this material.
 GLMaterial[] loadMaterials(java.io.BufferedReader br)
          MTL file format in a nutshell:
 GLMaterial[] loadMaterials(java.lang.String mtlFilename)
           
 void write(java.io.PrintWriter out, GLMaterial mtl)
          Write one material.
 void writeLibe(GLMaterial[] mtls, java.io.PrintWriter out)
           
 void writeLibe(GLMaterial[] mtls, java.lang.String filename)
          Write an array of GLMaterial objects to a .mtl file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filepath

public java.lang.String filepath

filename

public java.lang.String filename
Constructor Detail

GLMaterialLib

public GLMaterialLib(java.lang.String mtlFilename)
Method Detail

loadMaterials

public GLMaterial[] loadMaterials(java.lang.String mtlFilename)

loadMaterials

public GLMaterial[] loadMaterials(java.io.BufferedReader br)
MTL file format in a nutshell:
                newmtl white          // begin material and specify name
                Kd 1.0 1.0 1.0        // diffuse rgb
                Ka 0.2 0.2 0.2        // ambient rgb
                Ks 0.6 0.6 0.6        // specular rgb
                Ns 300                // shininess 0-1000
      d 0.5                 // alpha 0-1
      map_Kd texture.jpg    // texture file
                            // blank line ends material definition
 


writeLibe

public void writeLibe(GLMaterial[] mtls,
                      java.lang.String filename)
Write an array of GLMaterial objects to a .mtl file.

Parameters:
mtls - array of materials to write to file
filename - name of .mtl file

writeLibe

public void writeLibe(GLMaterial[] mtls,
                      java.io.PrintWriter out)

write

public void write(java.io.PrintWriter out,
                  GLMaterial mtl)
Write one material.


getClone

public GLMaterial getClone(GLMaterial mtl)
return a duplicate of this material. all values are duplicated except the texture, which is passed by reference to the clone (to prevent multiple copies of the same texture).

Returns:
the cloned material

find

public GLMaterial find(java.lang.String materialName)
find a material by name in an array of GLMaterial objects


findID

public int findID(java.lang.String materialName)
find a material by name in an array of GLMaterial objects return the array index of the material