Xj3D VRML/X3D Code API

org.web3d.ogl.loaders
Class BaseLoader

java.lang.Object
  extended byorg.web3d.ogl.loaders.BaseLoader
Direct Known Subclasses:
VRML97Loader, Web3DLoader, X3DLoader

public abstract class BaseLoader
extends java.lang.Object

Common base implementation Aviatrix3D file loader implementation for reading loading files and building a Aviatrix3D scenegraph with them.

The loader considers sensor handling and routing to be behaviours. Some asynchronous loading of files for textures is performed. Sound file loading is performed if audio clips are asked for. For example, if behaviours are not requested then Inlines will not have their content loaded.

If the loader asks for no runtime, then we will still load nodes that need a runtime system to work, but will disable their use. For example, a LOD will still need to have all of the geometry loaded, just not shown or activated because the LOD's internal behavior is disabled. Scripts are considered to be behaviours, and they will not be loaded at all if runtime loading is disabled.

The implementation only makes use of two behaviours. One is a per-frame behaviour for the event model evaluation. The other is a handler for trapping user input events. If you disable behaviours, you loose both of these. For content other than static geometry, such as animations, turning off behaviours will result in no animations. However, every loaded scene will be attempting to do work like navigation. This will become quite CPU intensive because every model will be performing picking operations. To cut down on this CPU usage, the navigation processing is turned off by default. If you want the loaded code to also do the navigation of the viewpoints, then you can call the setNavigationEnable() method. The default setup for runtime activities is ListsRouterFactory and MemCacheLoadManager

Version:
$Revision: 1.3 $
Author:
Justin Couch

Field Summary
protected  ErrorReporter errorReporter
          Class that represents the external reporter
protected  VRMLScene parsedScene
          The high-level VRML scene that was parsed to create the OGL scene
protected  VRMLParserFactory parserFactory
          The parser factory that we are going to use.
protected  boolean vrml97Only
          Flag to say if the scene builder factory should only use VRML97
 
Constructor Summary
protected BaseLoader()
          Construct a default loader implementation with no flags set.
 
Method Summary
 int getLoadFlags()
          Get the current set collection of load flags.
 boolean getNavigationEnabled()
          Get the currently set navigation state.
 boolean isInternalModelKept()
          Check to see whether the loader should be currently keeping the internal model.
 void keepInternalModel(boolean enable)
          Define whether this loader should also keep around it's internal representation of the file format, if it has one.
 AVModel load(java.io.File file)
          Load a model from the given file.
 AVModel load(java.io.InputStream stream)
          Load a model from the given input stream.
 AVModel load(java.net.URL url)
          Load a model from the given URL.
 void registerURNLocation(java.lang.String prefix, java.lang.String directory)
          Add a prefix and directory to the URN resolution system.
 void setErrorReporter(ErrorReporter reporter)
          Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion.
 void setLoadFlags(int flags)
          Set the flags for which parts of the file that should be loaded.
 void setNavigationEnabled(boolean state)
          Enable or disable navigation processing sub-section of the user input processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parserFactory

protected VRMLParserFactory parserFactory
The parser factory that we are going to use.


vrml97Only

protected boolean vrml97Only
Flag to say if the scene builder factory should only use VRML97


errorReporter

protected ErrorReporter errorReporter
Class that represents the external reporter


parsedScene

protected VRMLScene parsedScene
The high-level VRML scene that was parsed to create the OGL scene

Constructor Detail

BaseLoader

protected BaseLoader()
Construct a default loader implementation with no flags set. When asked to load a file it will not produce anything unless flags have been set through the setFlags() method.

Method Detail

load

public AVModel load(java.net.URL url)
             throws java.io.IOException
Load a model from the given URL.

Parameters:
url - The url to load the model from
Returns:
A representation of the model at the URL
Throws:
java.io.IOException - something went wrong while reading the file

load

public AVModel load(java.io.InputStream stream)
             throws java.io.IOException
Load a model from the given input stream. If the file format would prefer to use a Reader interface, then use the InputStreamReader to convert this stream to the desired type. The caller will be responsible for closing down the stream at the end of this process.

Parameters:
stream - The stream to load the model from
Returns:
A representation of the model from the stream contents
Throws:
java.io.IOException - something went wrong while reading the file

load

public AVModel load(java.io.File file)
             throws java.io.IOException
Load a model from the given file.

Parameters:
file - The file instance to load the model from
Returns:
A representation of the model in the file
Throws:
java.io.IOException - something went wrong while reading the file

setLoadFlags

public void setLoadFlags(int flags)
Set the flags for which parts of the file that should be loaded. The flags are bit-fields, so can be bitwise OR'd together.

Parameters:
flags - The collection of flags to use

getLoadFlags

public int getLoadFlags()
Get the current set collection of load flags.

Returns:
A bitmask of flags that are currently set

keepInternalModel

public void keepInternalModel(boolean enable)
Define whether this loader should also keep around it's internal representation of the file format, if it has one. If kept, this can be retrieved through the AVModel#getRawModel() method and cast to the appropriate class type.

Parameters:
enable - true to enable keeping the raw model, false otherwise

isInternalModelKept

public boolean isInternalModelKept()
Check to see whether the loader should be currently keeping the internal model.

Returns:
true when the internal model should be kept

getNavigationEnabled

public boolean getNavigationEnabled()
Get the currently set navigation state.

Returns:
true for the current state

setNavigationEnabled

public void setNavigationEnabled(boolean state)
Enable or disable navigation processing sub-section of the user input processing. By default the navigation processing is enabled.

Parameters:
state - true to enable navigation

setErrorReporter

public void setErrorReporter(ErrorReporter reporter)
Register an error reporter with the engine so that any errors generated by the loading of script code can be reported in a nice, pretty fashion. Setting a value of null will clear the currently set reporter. If one is already set, the new value replaces the old.

Parameters:
reporter - The instance to use or null

registerURNLocation

public void registerURNLocation(java.lang.String prefix,
                                java.lang.String directory)
                         throws java.lang.IllegalArgumentException
Add a prefix and directory to the URN resolution system. Whenever the prefix is found under the web3d area, this directory will be searched.

Parameters:
prefix - The subspace prefix to use
directory - The directory that GeoVRML is installed in
Throws:
java.lang.IllegalArgumentException - The directory is not valid

Xj3D VRML/X3D Code API

Copyright © 2001 - 2005 Web3D Consortium