com.sun.j3d.loaders.lw3d
Class LwoParser

java.lang.Object
  extended by com.sun.j3d.loaders.lw3d.ParserObject
      extended by com.sun.j3d.loaders.lw3d.LwoParser
Direct Known Subclasses:
J3dLwoParser

 class LwoParser
extends ParserObject

This class is responsible for parsing a binary Object file and storing the data. This class is not called directly, but is the parent class of J3dLwoObject. The subclass calls this class to parse the file, then it turns the resulting data into Java3D objects. LwoObject instantiates an LWOBFileReader object to parse the data. Then the class creates a list of ShapeHolder objects to hold all of the vertex/facet data and surface references and creates a list of LwoSurface objects to hold the data for each surface.
Rather than describe in detail how the file is parsed for each method, I advise the user of this code to understand the lw3d file format specs, which are pretty clear.


Field Summary
(package private)  int blue
           
(package private)  float[] coordsArray
           
(package private)  int currLength
           
(package private)  float diffuse
           
(package private)  int[] facetIndicesArray
           
(package private)  int[] facetSizesArray
           
(package private)  int gloss
           
(package private)  int green
           
(package private)  float luminosity
           
(package private)  float[] normalCoordsArray
           
(package private)  int[] normalIndicesArray
           
(package private)  int red
           
(package private)  java.util.Vector shapeList
           
(package private)  float specular
           
(package private)  java.util.Vector surfaceList
           
(package private)  java.util.Vector surfNameList
           
(package private)  LWOBFileReader theReader
           
(package private)  float transparency
           
 
Fields inherited from class com.sun.j3d.loaders.lw3d.ParserObject
debugPrinter, EXCEPTION, LINE_TRACE, MISC, NONE, TIME, TRACE, VALUES, WARNING
 
Constructor Summary
LwoParser(java.lang.String fileName, int debugVals)
          Constructor: Creates file reader and calls parseFile() to actually read the file and grab the data
LwoParser(java.net.URL url, int debugVals)
           
 
Method Summary
(package private)  ShapeHolder getAppropriateShape(int numSurf, int numVerts)
          Returns already-existing ShapeHolder if one exists with the same surface and the same geometry type (point, line, or poly)
(package private)  void getPnts(int length)
          Parses file to get all vertices
(package private)  void getPols(int length)
          Parse the file for all the data for a POLS object (polygon description)
(package private)  void getSrfs(int length)
          Parses file to get the names of all surfaces.
(package private)  void getSurf(int length)
          Creates new LwoSurface object that parses file and gets all surface parameters for a particular surface
(package private) static void main(java.lang.String[] args)
          This method is used only for testing
(package private)  int parseFile()
          parses entire file.
(package private)  int skipDetailPolygons(int numPolys)
          Detail polygons are currently not implemented by this loader.
 
Methods inherited from class com.sun.j3d.loaders.lw3d.ParserObject
debugOutput, debugOutputLn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

theReader

LWOBFileReader theReader

currLength

int currLength

coordsArray

float[] coordsArray

normalCoordsArray

float[] normalCoordsArray

facetIndicesArray

int[] facetIndicesArray

facetSizesArray

int[] facetSizesArray

normalIndicesArray

int[] normalIndicesArray

red

int red

green

int green

blue

int blue

diffuse

float diffuse

specular

float specular

transparency

float transparency

luminosity

float luminosity

gloss

int gloss

surfNameList

java.util.Vector surfNameList

surfaceList

java.util.Vector surfaceList

shapeList

java.util.Vector shapeList
Constructor Detail

LwoParser

LwoParser(java.lang.String fileName,
          int debugVals)
    throws java.io.FileNotFoundException
Constructor: Creates file reader and calls parseFile() to actually read the file and grab the data

Throws:
java.io.FileNotFoundException

LwoParser

LwoParser(java.net.URL url,
          int debugVals)
    throws java.io.FileNotFoundException
Throws:
java.io.FileNotFoundException
Method Detail

skipDetailPolygons

int skipDetailPolygons(int numPolys)
                 throws ParsingErrorException
Detail polygons are currently not implemented by this loader. Their structure in geometry files is a bit complex, so there's this separate method for simply parsing through and ignoring the data for detail polygons

Throws:
ParsingErrorException

getAppropriateShape

ShapeHolder getAppropriateShape(int numSurf,
                                int numVerts)
Returns already-existing ShapeHolder if one exists with the same surface and the same geometry type (point, line, or poly)


getPols

void getPols(int length)
Parse the file for all the data for a POLS object (polygon description)


getSrfs

void getSrfs(int length)
Parses file to get the names of all surfaces. Each polygon will be associated with a particular surface number, which is the index number of these names


getPnts

void getPnts(int length)
       throws ParsingErrorException
Parses file to get all vertices

Throws:
ParsingErrorException

getSurf

void getSurf(int length)
       throws java.io.FileNotFoundException
Creates new LwoSurface object that parses file and gets all surface parameters for a particular surface

Throws:
java.io.FileNotFoundException

parseFile

int parseFile()
        throws java.io.FileNotFoundException,
               IncorrectFormatException
parses entire file. return -1 on error or 0 on completion

Throws:
java.io.FileNotFoundException
IncorrectFormatException

main

static void main(java.lang.String[] args)
This method is used only for testing



Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.