com.sun.j3d.loaders.lw3d
Class Lw3dLoader

java.lang.Object
  extended by com.sun.j3d.loaders.lw3d.TextfileParser
      extended by com.sun.j3d.loaders.lw3d.Lw3dLoader
All Implemented Interfaces:
Loader

public class Lw3dLoader
extends TextfileParser
implements Loader

This class implements the Loader API and allows users to load Lightwave 3D scene files. In order to load properly, the object files referred to in the scene files and the image files referred to by the object files must all be specified with path and filenames that are valid with respect to the directory in which the application is being executed.


Field Summary
(package private)  Color3f ambientColor
           
(package private)  LwsBackground background
           
(package private)  java.lang.String basePath
           
(package private)  java.net.URL baseUrl
           
(package private)  LwsCamera camera
           
(package private) static int FILE_TYPE_FILENAME
           
(package private) static int FILE_TYPE_NONE
           
(package private) static int FILE_TYPE_READER
           
(package private) static int FILE_TYPE_URL
           
(package private)  int fileType
           
(package private)  LwsFog fog
           
(package private)  java.lang.String internalBasePath
           
(package private)  java.lang.String internalBaseUrl
           
(package private)  java.util.Vector lightList
           
(package private)  int loadBehaviors
           
(package private)  int loadFlags
           
(package private)  java.util.Vector objectList
           
(package private)  SceneBase scene
           
(package private)  java.util.Vector sceneBehaviors
           
(package private)  BranchGroup sceneGroupNode
           
 
Fields inherited from class com.sun.j3d.loaders.lw3d.TextfileParser
currentLevel, debugPrinter, EXCEPTION, LINE_TRACE, lineSeparatorChar, MISC, NONE, NUMBER, TIME, TRACE, VALUES, WORD
 
Fields inherited from interface com.sun.j3d.loaders.Loader
LOAD_ALL, LOAD_BACKGROUND_NODES, LOAD_BEHAVIOR_NODES, LOAD_FOG_NODES, LOAD_LIGHT_NODES, LOAD_SOUND_NODES, LOAD_VIEW_GROUPS
 
Constructor Summary
Lw3dLoader()
          Default constructor.
Lw3dLoader(int flags)
          This constructor takes a flags word that specifies which types of scenefile items should be loaded into the scene.
 
Method Summary
(package private)  void addAmbient()
          Adds Ambient lighting effects to the scene
(package private)  void addBackground()
          Add appropriate background effects to the scene.
(package private)  void addBehaviors()
          Add the behaviors to the scene
(package private)  void addCamera()
          Adds the Camera's transform group to the scene, either by parenting it to the appropriate object or by adding it to the scene root.
(package private)  void addFog()
          Add appropriate fog effects to the scene
(package private)  void addLights()
          Add any defined lights to the java3d scene
(package private)  void constructScene()
          This method creates the Scene (actually SceneBase) data structure and adds all appropriate items to it.
 java.lang.String getBasePath()
          Returns the current base path setting.
 java.net.URL getBaseUrl()
          Returns the current base URL setting.
(package private)  int getFileType()
           
 int getFlags()
          Returns the current loading flags setting.
(package private)  java.lang.String getInternalBasePath()
           
(package private)  java.lang.String getInternalBaseUrl()
           
 TransformGroup getObject(java.lang.String name)
          getObject() iterates through the objectList checking the given name against the fileName and objectName of each object in turn.
 Scene load(java.io.Reader reader)
          This method loads the Reader and returns the Scene containing the scene.
 Scene load(java.lang.String fileName)
          This method loads the named file and returns the Scene containing the scene.
 Scene load(java.net.URL url)
          This method loads the named file and returns the Scene containing the scene.
(package private)  void parentObjects()
          This method parents all objects in the scene appropriately.
 void setBasePath(java.lang.String pathName)
          This method sets the base path to be used when searching for all data files within a Lightwave scene.
 void setBaseUrl(java.net.URL url)
          This method sets the base URL name for data files associated with the file passed into the load(URL) method.
 void setFlags(int flags)
          This method sets the load flags for the file.
(package private)  void setInternalBasePath(java.lang.String fileName)
          Standardizes the filename for use in the loader
(package private)  void setInternalBaseUrl(java.net.URL url)
          Creates a url for internal use.
(package private)  void setupTokenizer(java.io.StreamTokenizer tokenizer)
          This method sets up the StreamTokenizer for the scene file.
 
Methods inherited from class com.sun.j3d.loaders.lw3d.TextfileParser
checkString, checkType, debugOutput, debugOutputLn, getAndCheckString, getName, getNumber, getString, isCurrentToken, skip, skipUntilString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

objectList

java.util.Vector objectList

lightList

java.util.Vector lightList

sceneGroupNode

BranchGroup sceneGroupNode

ambientColor

Color3f ambientColor

camera

LwsCamera camera

fog

LwsFog fog

background

LwsBackground background

loadFlags

int loadFlags

loadBehaviors

int loadBehaviors

sceneBehaviors

java.util.Vector sceneBehaviors

scene

SceneBase scene

basePath

java.lang.String basePath

internalBasePath

java.lang.String internalBasePath

baseUrl

java.net.URL baseUrl

internalBaseUrl

java.lang.String internalBaseUrl

FILE_TYPE_NONE

static final int FILE_TYPE_NONE
See Also:
Constant Field Values

FILE_TYPE_URL

static final int FILE_TYPE_URL
See Also:
Constant Field Values

FILE_TYPE_FILENAME

static final int FILE_TYPE_FILENAME
See Also:
Constant Field Values

FILE_TYPE_READER

static final int FILE_TYPE_READER
See Also:
Constant Field Values

fileType

int fileType
Constructor Detail

Lw3dLoader

public Lw3dLoader()
Default constructor. Sets up default values for some variables.


Lw3dLoader

public Lw3dLoader(int flags)
This constructor takes a flags word that specifies which types of scenefile items should be loaded into the scene. The possible values are specified in the com.sun.j3d.loaders.Loader class.

Method Detail

load

public Scene load(java.net.URL url)
           throws java.io.FileNotFoundException,
                  IncorrectFormatException,
                  ParsingErrorException
This method loads the named file and returns the Scene containing the scene. Any data files referenced by the Reader should be located in the same place as the named file; otherwise, users should specify an alternate base path with the setBaseUrl(URL) method.

Specified by:
load in interface Loader
Throws:
java.io.FileNotFoundException
IncorrectFormatException
ParsingErrorException

load

public Scene load(java.lang.String fileName)
           throws java.io.FileNotFoundException,
                  IncorrectFormatException,
                  ParsingErrorException
This method loads the named file and returns the Scene containing the scene. Any data files referenced by this file should be located in the same place as the named file; otherwise users should specify an alternate base path with the setBasePath(String) method.

Specified by:
load in interface Loader
Throws:
java.io.FileNotFoundException
IncorrectFormatException
ParsingErrorException

load

public Scene load(java.io.Reader reader)
           throws java.io.FileNotFoundException,
                  IncorrectFormatException,
                  ParsingErrorException
This method loads the Reader and returns the Scene containing the scene. Any data files referenced by the Reader should be located in the user's current working directory.

Specified by:
load in interface Loader
Throws:
java.io.FileNotFoundException
IncorrectFormatException
ParsingErrorException

constructScene

void constructScene()
This method creates the Scene (actually SceneBase) data structure and adds all appropriate items to it. This is the data structure that the user will get back from the load() call and inquire to get data from the scene.


setInternalBaseUrl

void setInternalBaseUrl(java.net.URL url)
Creates a url for internal use. This method is not currently used (url's are ignored for this loader; only filenames work)


setInternalBasePath

void setInternalBasePath(java.lang.String fileName)
Standardizes the filename for use in the loader


getInternalBasePath

java.lang.String getInternalBasePath()

getInternalBaseUrl

java.lang.String getInternalBaseUrl()

getFileType

int getFileType()

parentObjects

void parentObjects()
This method parents all objects in the scene appropriately. If the scen file specifies a Parent node for the object, then the object is parented to that node. If not, then the object is parented to the scene's root.


setBaseUrl

public void setBaseUrl(java.net.URL url)
This method sets the base URL name for data files associated with the file passed into the load(URL) method. The basePath should be null by default, which is an indicator to the loader that it should look for any associated files starting from the same directory as the file passed into the load(URL) method.

Specified by:
setBaseUrl in interface Loader

setBasePath

public void setBasePath(java.lang.String pathName)
This method sets the base path to be used when searching for all data files within a Lightwave scene.

Specified by:
setBasePath in interface Loader

getBaseUrl

public java.net.URL getBaseUrl()
Returns the current base URL setting.

Specified by:
getBaseUrl in interface Loader

getBasePath

public java.lang.String getBasePath()
Returns the current base path setting.

Specified by:
getBasePath in interface Loader

setFlags

public 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).

Specified by:
setFlags in interface Loader

getFlags

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

Specified by:
getFlags in interface Loader

getObject

public TransformGroup getObject(java.lang.String name)
getObject() iterates through the objectList checking the given name against the fileName and objectName of each object in turn. For the filename, it carves off the pathname and just checks the final name (e.g., "missile.lwo"). If name has []'s at the end, it will use the number inside those brackets to pick which object out of an ordered set it will send back (objectList is created in the order that objects exist in the file, so this order should correspond to the order specified by the user). If no []'s exist, just pass back the first one encountered that matches.


setupTokenizer

void setupTokenizer(java.io.StreamTokenizer tokenizer)
This method sets up the StreamTokenizer for the scene file. Note that we're not parsing numbers as numbers because the tokenizer does not interpret scientific notation correctly.


addAmbient

void addAmbient()
Adds Ambient lighting effects to the scene


addLights

void addLights()
Add any defined lights to the java3d scene


addCamera

void addCamera()
Adds the Camera's transform group to the scene, either by parenting it to the appropriate object or by adding it to the scene root. To use this camera data, users can request the camera/view data for the scene and can then insert a ViewPlatform in the transform group.


addFog

void addFog()
Add appropriate fog effects to the scene


addBehaviors

void addBehaviors()
Add the behaviors to the scene


addBackground

void addBackground()
Add appropriate background effects to the scene. Note that the java3d background may not have all of the information of the lw3d background, as the loader does not currently process items such as gradients between the horizon and sky colors



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