com.brackeen.javagamebook.math3D
Class ObjectLoader

java.lang.Object
  extended bycom.brackeen.javagamebook.math3D.ObjectLoader
Direct Known Subclasses:
MapLoader

public class ObjectLoader
extends java.lang.Object

The ObjectLoader class loads a subset of the Alias|Wavefront OBJ file specification. Lines that begin with '#' are comments. OBJ file keywords:

    mtllib [filename]    - Load materials from an external .mtl
                           file.
    v [x] [y] [z]        - Define a vertex with floating-point
                           coords (x,y,z).
    f [v1] [v2] [v3] ... - Define a new face. a face is a flat,
                           convex polygon with vertices in
                           counter-clockwise order. Positive
                           numbers indicate the index of the
                           vertex that is defined in the file.
                           Negative numbers indicate the vertex
                           defined relative to last vertex read.
                           For example, 1 indicates the first
                           vertex in the file, -1 means the last
                           vertex read, and -2 is the vertex
                           before that.
    g [name]             - Define a new group by name. The faces
                           following are added to this group.
    usemtl [name]        - Use the named material (loaded from a
                           .mtl file) for the faces in this group.
    
MTL file keywords:
    newmtl [name]        - Define a new material by name.
    map_Kd [filename]    - Give the material a texture map.
    


Nested Class Summary
static class ObjectLoader.Material
          The Material class wraps a ShadedTexture.
 
Constructor Summary
ObjectLoader()
          Creates a new ObjectLoader.
 
Method Summary
 PolygonGroup loadObject(java.lang.String filename)
          Loads an OBJ file as a PolygonGroup.
 void setLights(java.util.List lights, float ambientLightIntensity)
          Sets the lights used for the polygons in the parsed objects.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectLoader

public ObjectLoader()
Creates a new ObjectLoader.

Method Detail

setLights

public void setLights(java.util.List lights,
                      float ambientLightIntensity)
Sets the lights used for the polygons in the parsed objects. After calling this method calls to loadObject use these lights.


loadObject

public PolygonGroup loadObject(java.lang.String filename)
                        throws java.io.IOException
Loads an OBJ file as a PolygonGroup.

Throws:
java.io.IOException