j3d.org Code

org.j3d.loaders.ac3d
Class Ac3dParser

java.lang.Object
  extended by org.j3d.loaders.ac3d.Ac3dParser

public class Ac3dParser
extends java.lang.Object

AC3DFileParser handles the work of parsing the AC3D data from a stream. Since the AC3D file format is not only ASCII based, but also formatted using lines, this gets away with just using a BufferedReader and picking off the lines one by one.

Although this parser was implemented to facilitate building an AC3D file loader for importing models into Java3D, this parser aims to be independant of the Java3D API. The intention is to be able to leverage this code in other applications, as well. (Perhaps in a command line format conversion tool...) Thus, the separation of Java3D and parsing code.

Internationalisation Resource Names

Version:
$Revision: 1.14 $
Author:
Ryan Wilhm (ryan@entrophica.com)

Field Summary
static int SUPPORTED_FORMAT_VERSION
          The latest version of the file format this parser supports.
 
Constructor Summary
Ac3dParser()
          Construct a default parser that does not have an input source.
Ac3dParser(java.io.Reader rdr)
          Construct a new parser that sources the data from the given reader.
 
Method Summary
 Ac3dMaterial[] getMaterials()
          Fetch the materials from the previously loaded file.
 Ac3dObject[] getObjects()
          Fetch the objects from the previously loaded file.
 void parse(boolean retainData)
          Performs the action of parsing the data stream already set.
 void reset(java.io.Reader rdr)
          Reset the parser with a new input reader.
 void setErrorReporter(ErrorReporter reporter)
          Register an error reporter with the engine so that any errors generated by the parsing internals can be reported in a nice, pretty fashion.
 void setParseObserver(Ac3dParseObserver obs)
          Set the observer for parsing events that can be used with this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUPPORTED_FORMAT_VERSION

public static final int SUPPORTED_FORMAT_VERSION
The latest version of the file format this parser supports.

See Also:
Constant Field Values
Constructor Detail

Ac3dParser

public Ac3dParser()
Construct a default parser that does not have an input source. An input source would need to be provided through the use of the reset() methods.


Ac3dParser

public Ac3dParser(java.io.Reader rdr)
Construct a new parser that sources the data from the given reader.

Parameters:
rdr - The reader instance to use
Method Detail

setErrorReporter

public void setErrorReporter(ErrorReporter reporter)
Register an error reporter with the engine so that any errors generated by the parsing internals 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

setParseObserver

public void setParseObserver(Ac3dParseObserver obs)
Set the observer for parsing events that can be used with this class. Only a single instance may be set at any time, so calling this will replace the currently registered instance. If called with a null value, it removes the currently set instance.

Parameters:
obs - The observer instance to use

parse

public void parse(boolean retainData)
           throws java.io.IOException
Performs the action of parsing the data stream already set.

Parameters:
retainData - true if the parser should maintain a copy of all the data read locally after completing parsing
Throws:
InvalidFormatException - The file format does not match the expected format for AC3D
UnsupportedFormatException - The format provided is later version than what we currently support
java.io.IOException - An I/O error occurred while processing the file

reset

public void reset(java.io.Reader rdr)
Reset the parser with a new input reader. After calling this method all currently stored information from the previous parsing pass will be discarded.

Parameters:
rdr - The new reader instance to use

getMaterials

public Ac3dMaterial[] getMaterials()
Fetch the materials from the previously loaded file. If nothing has been loaded yet, this will return a zero length array. If the retainData flag was set to false on the parse() method, this will return a zero length array.

Returns:
An array of the materials found

getObjects

public Ac3dObject[] getObjects()
Fetch the objects from the previously loaded file. If nothing has been loaded yet, this will return a zero length array. If the retainData flag was set to false on the parse() method, this will return a zero length array.

Returns:
An array of the materials found

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org