NCSA Portfolio

ncsa.j3d.loaders
Class ModelLoader

java.lang.Object
  |
  +--com.sun.j3d.loaders.LoaderBase
        |
        +--ncsa.j3d.loaders.ModelLoader

public class ModelLoader
extends com.sun.j3d.loaders.LoaderBase

This class is used to load 3D models and return them as a Scene for placement into a scene. In order to write your own object loaders that ModelLoader can recognize, you must do the following:

1. Create an object named by the extension of the type of model you wish to load, with the prefix "Loader_". For example, Wavefront files have the obj extension and VRML files have the wrl extension. Objects created to load those models would be named Loader_OBJ and Loader_WRL, respectively.

2. The object you're creating must implement the BasicLoader interface. ModelLoader uses this interface internally, and uses it to load objects.

3. Currently, the loader must be part of the ncsa.j3d.loaders package. Unless it is, it can not be recognized by ModelLoader. This will probably change in future implementations to make it even easier to add new loaders.

Once you've done this, you should just be able to call ModelLoader as you usually would (see below) and your new Loader will automatically be recognized and called by ModelLoader.

Usage:

ModelLoader loader = new ModelLoader();
Scene model1 = loader.load(new URL("http:/havefun.ncsa.uiuc.edu/~srp/astro.wrl"));
Scene model2 = loader.load("cah.obj");
Scene model3 = loader.load("/opt/jw.dxf");


Constructor Summary
ModelLoader()
           
 
Method Summary
 com.sun.j3d.loaders.Scene load(java.io.Reader reader)
          This method should not be called directly.
 com.sun.j3d.loaders.Scene load(java.io.Reader reader, java.lang.String ext)
          Read the data from the BufferedReader and return it as a Scene.
 com.sun.j3d.loaders.Scene load(java.lang.String filename)
          Loads a model given its filename
 com.sun.j3d.loaders.Scene load(java.net.URL url)
          Loads a model given its URL
 
Methods inherited from class com.sun.j3d.loaders.LoaderBase
getBasePath, getBaseUrl, getFlags, setBasePath, setBaseUrl, setFlags
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ModelLoader

public ModelLoader()
Method Detail

load

public com.sun.j3d.loaders.Scene load(java.net.URL url)
                               throws java.io.FileNotFoundException
Loads a model given its URL
Overrides:
load in class com.sun.j3d.loaders.LoaderBase
Parameters:
url - the URL of the model to load

load

public com.sun.j3d.loaders.Scene load(java.lang.String filename)
                               throws java.io.FileNotFoundException
Loads a model given its filename
Overrides:
load in class com.sun.j3d.loaders.LoaderBase
Parameters:
filename - the file name of the model to load

load

public com.sun.j3d.loaders.Scene load(java.io.Reader reader,
                                      java.lang.String ext)
                               throws java.io.FileNotFoundException
Read the data from the BufferedReader and return it as a Scene. The "ext" indicates what type of model data this is. For example, the wrl extension indicates a VRML file, the obj extension indicates a Wavefront file.
Parameters:
base - the base name of where this file is being read
br - the reader connected to the data to be parsed
ext - the extension indicating the data type

load

public com.sun.j3d.loaders.Scene load(java.io.Reader reader)
This method should not be called directly. It prints a warning message.
Overrides:
load in class com.sun.j3d.loaders.LoaderBase

NCSA Portfolio

NCSA Portfolio, Copyright 1997-1999, National Center for Supercomputing Applications, University of Illinois Urbana-Champaign, All Rights Reserved