com.brackeen.javagamebook.bsp2D
Class MapLoader

java.lang.Object
  extended bycom.brackeen.javagamebook.math3D.ObjectLoader
      extended bycom.brackeen.javagamebook.bsp2D.MapLoader

public class MapLoader
extends ObjectLoader

The MapLoader class loads maps from a text file based on the Alias|Wavefront OBJ file specification. MAP file commands:

    v [x] [y] [z]        - Define a vertex with floating-point
                           coords (x,y,z).
    mtllib [filename]    - Load materials from an external .mtl
                           file.
    usemtl [name]        - Use the named material (loaded from a
                           .mtl file) for the next floor, ceiling,
                           or wall.
    ambientLightIntensity
        [value]          - Defines the ambient light intensity
                           for the next room, from 0 to 1.
    pointlight [v]       - Defines a point light located at the
        [intensity]        specfied vector. Optionally, light
        [falloff]          intesity and falloff distance can
                           be specified.
    player [v] [angle]   - Specifies the starting location of the
                           player and optionally a starting
                           angle, in radians, around the y-axis.
    obj [uniqueName]     - Defines an object from an external
        [filename] [v]     OBJ file. The unique name allows this
        [angle]            object to be uniquely identfied, but
                           can be "null" if no unique name is
                           needed. The filename is an external
                           OBJ file. Optionally, the starting
                           angle, in radians, around the y-axis
                           can be specified.
    room [name]          - Defines a new room, optionally giving
                           the room a name. A room consists of
                           vertical walls, a horizontal floor
                           and a horizontal ceiling. Concave rooms
                           are currently not supported, but can be
                           simulated by adjacent convex rooms.
    floor [height]       - Defines the height of the floor of
                           the current room, using the current
                           material. The current material can
                           be null, in which case no floor
                           polygon is created. The floor can be
                           above the ceiling, in which case a
                           "pillar" or "block" structure is
                           created, rather than a "room".
    ceil [height]        - Defines the height of the ceiling of
                           the current room, using the current
                           material. The current material can
                           be null, in which case no ceiling
                           polygon is created. The ceiling can be
                           below the floor, in which case a
                           "pillar" or "block" structure is
                           created, rather than a "room".
    wall [x] [z]         - Defines a wall vertex in a room using
         [bottom] [top]    the specified x and z coordinates.
                           Walls should be defined in clockwise
                           order. If "bottom" and "top" is not
                           defined, the floor and ceiling height
                           are used. If the current material is
                           null, or bottom is equal to top, no
                           wall polygon is created.
    


Nested Class Summary
 
Nested classes inherited from class com.brackeen.javagamebook.math3D.ObjectLoader
ObjectLoader.Material
 
Constructor Summary
MapLoader()
          Creates a new MapLoader using the default BSPTreeBuilder.
MapLoader(BSPTreeBuilder builder)
          Creates a new MapLoader using the specified BSPTreeBuilder.
 
Method Summary
 java.util.List getObjectsInMap()
          Gets a list of all objects degined in the map file.
 Transform3D getPlayerStartLocation()
          Gets the player start location defined in the map file.
 BSPTree loadMap(java.lang.String filename)
          Loads a map file and creates a BSP tree.
 void setObjectLights(java.util.List lights, float ambientLightIntensity)
          Sets the lights used for OBJ objects.
 
Methods inherited from class com.brackeen.javagamebook.math3D.ObjectLoader
loadObject, setLights
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapLoader

public MapLoader()
Creates a new MapLoader using the default BSPTreeBuilder.


MapLoader

public MapLoader(BSPTreeBuilder builder)
Creates a new MapLoader using the specified BSPTreeBuilder. If the builder is null, a default BSPTreeBuilder is created.

Method Detail

loadMap

public BSPTree loadMap(java.lang.String filename)
                throws java.io.IOException
Loads a map file and creates a BSP tree. Objects created can be retrieved from the getObjectsInMap() method.

Throws:
java.io.IOException

getObjectsInMap

public java.util.List getObjectsInMap()
Gets a list of all objects degined in the map file.


getPlayerStartLocation

public Transform3D getPlayerStartLocation()
Gets the player start location defined in the map file.


setObjectLights

public void setObjectLights(java.util.List lights,
                            float ambientLightIntensity)
Sets the lights used for OBJ objects.