org.xith3d.loaders.models
Class ModelLoader

java.lang.Object
  extended by org.xith3d.loaders.models.ModelLoader
Direct Known Subclasses:
Cal3dLoader, DaeLoader, MetaLoader

public class ModelLoader
extends java.lang.Object

The abstract Loader class is used to specify the location and elements of a file format to load. The class is used to give loaders of various file formats a common public interface. Ideally the Scene and Model classes will be extended to give the user a consistent interface to extract the data.

See Also:
org.xith3d.loaders.models.base.LoadedGraph, org.xith3d.loaders.models.base.Scene, Model

Nested Class Summary
protected static class ModelLoader.SourceModelType
           
protected static class ModelLoader.SpecialItemsHandlerImpl
           
 
Field Summary
static int ALWAYS_CONVERT_Z_UP_TO_Y_UP
          This flag forces the conversion from Z-up to Y-up for all model types.
static int CONVERT_Z_UP_TO_Y_UP_IF_EXPECTED
          This flag makes the loader to convert the model from z-up to y-up if the source model format is known to use z-up by default (like 3DS, MD2, MD3, MD5 and BSP).
static int DEFAULT_FLAGS
           
static int LOAD_CAMERAS
          This flag enables the loading of camera (view) objects into the scene.
static int LOAD_FOG_NODES
          This flag enables the loading of fog objects into the scene.
static int LOAD_LIGHT_NODES
          This flag enables the loading of light objects into the scene.
static int LOAD_SOUND_NODES
          This flag enables the loading of sound objects into the scene.
static int LOAD_SUB_MODELS
          This flag enables the loading of camera (view) objects into the scene.
static float SCALE
           
 
Constructor Summary
protected ModelLoader()
          Constructs a ModelLoader with default flags.
protected ModelLoader(int flags)
          Constructs a ModelLoader with the specified flags word.
 
Method Summary
protected  ModelLoader.SourceModelType extractModelType(java.lang.String filename)
           
protected  ModelLoader.SourceModelType extractModelType(java.net.URL url)
           
protected  ModelLoader.SourceModelType extractModelType(java.net.URL url, java.lang.String filename)
           
 boolean getFlag(int flag)
           
 int getFlags()
           
static ModelLoader getInstance()
          If you decide to use the Loader as a singleton, here is the method to get the instance from.
 Model loadModel(java.lang.String filename)
          This method loads the Model from a URL.
 Model loadModel(java.lang.String filename, float scale)
          This method loads the Model from a URL.
 Model loadModel(java.lang.String filename, float scale, int flags)
          This method loads the Model from a URL.
 Model loadModel(java.lang.String filename, java.lang.String skin)
          This method loads the Model from a URL.
 Model loadModel(java.lang.String filename, java.lang.String skin, float scale)
          This method loads the Model from a URL.
 Model loadModel(java.lang.String filename, java.lang.String skin, float scale, int flags)
          This method loads the Model from a URL.
 Model loadModel(java.net.URL url)
          This method loads the Model from a URL.
 Model loadModel(java.net.URL url, float scale)
          This method loads the Model from a URL.
 Model loadModel(java.net.URL url, float scale, int flags)
          This method loads the Model from a URL.
 Model loadModel(java.net.URL url, java.lang.String skin)
          This method loads the Model from a URL.
 Model loadModel(java.net.URL url, java.lang.String skin, float scale)
          This method loads the Model from a URL.
 Model loadModel(java.net.URL url, java.lang.String skin, float scale, int flags)
          This method loads the Model from a URL.
protected  Model loadModel(java.net.URL url, java.lang.String filenameBase, ModelLoader.SourceModelType modelType, java.net.URL baseURL, java.lang.String skin, float scale, int flags, org.jagatoo.loaders.models._util.AppearanceFactory appFactory, org.jagatoo.loaders.models._util.GeometryFactory geomFactory, org.jagatoo.loaders.models._util.NodeFactory nodeFactory, org.jagatoo.loaders.models._util.AnimationFactory animFactory, org.jagatoo.loaders.models._util.SpecialItemsHandler siHandler, Model model)
           
 Model loadModel(java.net.URL url, java.lang.String filenameBase, java.net.URL baseURL, java.lang.String skin, float scale, int flags)
           
 void setFlag(int flag, boolean enable)
          This method sets the specified load flag for the file.
 void setFlags(int flags)
          This method sets the load flags for the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCALE

public static final float SCALE
See Also:
Constant Field Values

LOAD_LIGHT_NODES

public static final int LOAD_LIGHT_NODES
This flag enables the loading of light objects into the scene.

See Also:
Constant Field Values

LOAD_FOG_NODES

public static final int LOAD_FOG_NODES
This flag enables the loading of fog objects into the scene.

See Also:
Constant Field Values

LOAD_SOUND_NODES

public static final int LOAD_SOUND_NODES
This flag enables the loading of sound objects into the scene.

See Also:
Constant Field Values

LOAD_CAMERAS

public static final int LOAD_CAMERAS
This flag enables the loading of camera (view) objects into the scene.

See Also:
Constant Field Values

LOAD_SUB_MODELS

public static final int LOAD_SUB_MODELS
This flag enables the loading of camera (view) objects into the scene.

See Also:
Constant Field Values

CONVERT_Z_UP_TO_Y_UP_IF_EXPECTED

public static final int CONVERT_Z_UP_TO_Y_UP_IF_EXPECTED
This flag makes the loader to convert the model from z-up to y-up if the source model format is known to use z-up by default (like 3DS, MD2, MD3, MD5 and BSP).

See Also:
Constant Field Values

ALWAYS_CONVERT_Z_UP_TO_Y_UP

public static final int ALWAYS_CONVERT_Z_UP_TO_Y_UP
This flag forces the conversion from Z-up to Y-up for all model types.

See Also:
Constant Field Values

DEFAULT_FLAGS

public static final int DEFAULT_FLAGS
See Also:
Constant Field Values
Constructor Detail

ModelLoader

protected ModelLoader(int flags)
Constructs a ModelLoader with the specified flags word.

Parameters:
flags -

ModelLoader

protected ModelLoader()
Constructs a ModelLoader with default flags.

Method Detail

setFlags

public final void setFlags(int flags)
This method sets the load flags for the file. The flags should equal 0 by default (which tells the loader to only load geometry).


getFlags

public final int getFlags()
Returns:
the current loading flags setting.

setFlag

public final void setFlag(int flag,
                          boolean enable)
This method sets the specified load flag for the file. The flags should equal 0 by default (which tells the loader to only load geometry).

Parameters:
flag - the flag to set/reset
enable - true to enable the flag

getFlag

public final boolean getFlag(int flag)
Returns:
the current loading flag setting.

extractModelType

protected ModelLoader.SourceModelType extractModelType(java.net.URL url,
                                                       java.lang.String filename)

extractModelType

protected final ModelLoader.SourceModelType extractModelType(java.net.URL url)

extractModelType

protected final ModelLoader.SourceModelType extractModelType(java.lang.String filename)

loadModel

protected Model loadModel(java.net.URL url,
                          java.lang.String filenameBase,
                          ModelLoader.SourceModelType modelType,
                          java.net.URL baseURL,
                          java.lang.String skin,
                          float scale,
                          int flags,
                          org.jagatoo.loaders.models._util.AppearanceFactory appFactory,
                          org.jagatoo.loaders.models._util.GeometryFactory geomFactory,
                          org.jagatoo.loaders.models._util.NodeFactory nodeFactory,
                          org.jagatoo.loaders.models._util.AnimationFactory animFactory,
                          org.jagatoo.loaders.models._util.SpecialItemsHandler siHandler,
                          Model model)
                   throws java.io.IOException,
                          org.jagatoo.util.errorhandling.IncorrectFormatException,
                          org.jagatoo.util.errorhandling.ParsingException
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public Model loadModel(java.net.URL url,
                       java.lang.String filenameBase,
                       java.net.URL baseURL,
                       java.lang.String skin,
                       float scale,
                       int flags)
                throws java.io.IOException,
                       org.jagatoo.util.errorhandling.IncorrectFormatException,
                       org.jagatoo.util.errorhandling.ParsingException
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.net.URL url,
                             java.lang.String skin,
                             float scale,
                             int flags)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
url - the URL to load the Model from.
skin - the skin resource name
scale - pre-scaling factor
flags - loading flags
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.net.URL url,
                             float scale,
                             int flags)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
url - the URL to load the Model from.
scale - pre-scaling factor
flags - loading flags
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.lang.String filename,
                             java.lang.String skin,
                             float scale,
                             int flags)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
filename - the filename to load the Model from
skin - the skin resource name
scale - pre-scaling factor
flags - loading flags
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.lang.String filename,
                             float scale,
                             int flags)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
filename - the filename to load the Model from
scale - pre-scaling factor
flags - loading flags
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.net.URL url,
                             java.lang.String skin,
                             float scale)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
url - the URL to load the Model from.
skin - the skin resource name
scale - pre-scaling factor
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.net.URL url,
                             float scale)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
url - the URL to load the Model from.
scale - pre-scaling factor
flags - loading flags
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.lang.String filename,
                             java.lang.String skin,
                             float scale)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
filename - the filename to load the Model from
skin - the skin resource name
scale - pre-scaling factor
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.lang.String filename,
                             float scale)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
filename - the filename to load the Model from
scale - pre-scaling factor
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.net.URL url,
                             java.lang.String skin)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
url - the URL to load the Model from.
skin - the skin resource name
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.net.URL url)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
url - the URL to load the Model from.
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.lang.String filename,
                             java.lang.String skin)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
filename - the filename to load the Model from
skin - the skin resource name
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

loadModel

public final Model loadModel(java.lang.String filename)
                      throws java.io.IOException,
                             org.jagatoo.util.errorhandling.IncorrectFormatException,
                             org.jagatoo.util.errorhandling.ParsingException
This method loads the Model from a URL. Any data files referenced by the model file are searched in the following locations in the following order:
  1. By absolute path as referenced in the model file
  2. By relative filename (relative to the baseURL)
  3. In case of textures see TextureLoader's TextureStreamLocator architecture

Parameters:
filename - the filename to load the Model from
Throws:
java.io.IOException
org.jagatoo.util.errorhandling.IncorrectFormatException
org.jagatoo.util.errorhandling.ParsingException

getInstance

public static ModelLoader getInstance()
If you decide to use the Loader as a singleton, here is the method to get the instance from.

Returns:
a singleton instance of the Loader