com.sun.j3d.loaders.lw3d
Class LwsObject

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

 class LwsObject
extends TextfileParser
implements LwsPrimitive

An LwsObject is passed a handle to the text file that contains the scene and is responsible for parsing a particular section of that file that describes a single object. This section defines the type of object (either a group or some geometry specified by an Object file) and some keyframe data that describes the an animation of the orientation/position/scale of the object. For geometry objects, this class instantiates a J3dLwoParser object to parse the binary data file. For the keyframe data, the class instantiates an LwsMotion object to parse and store that data.


Field Summary
(package private)  java.lang.String fileName
           
(package private)  int fileType
           
(package private)  boolean hasPivot
           
(package private)  LwsMotion motion
           
(package private)  java.util.Vector objectBehavior
           
(package private)  TransformGroup objectTransform
           
(package private)  java.lang.String objName
           
(package private)  int parent
           
(package private)  TransformGroup pivotTransGroup
           
(package private)  java.lang.String protocol
           
(package private)  java.util.Vector shapeList
           
(package private)  java.net.URL urlName
           
 
Fields inherited from class com.sun.j3d.loaders.lw3d.TextfileParser
currentLevel, debugPrinter, EXCEPTION, LINE_TRACE, lineSeparatorChar, MISC, NONE, NUMBER, TIME, TRACE, VALUES, WORD
 
Constructor Summary
LwsObject(java.io.StreamTokenizer st, boolean loadObject, int firstFrame, int totalFrames, float totalTime, Lw3dLoader loader, int debugVals)
          Constructor: parses object section of this scene file and creates all appropriate data structures to hold the information
 
Method Summary
(package private)  void addChild(LwsPrimitive child)
          Adds the given child to the transform of this node (its parent).
(package private)  void createJava3dObject(LwsObject cloneObject, int loadBehaviors)
          Creates Java3d objects from the data stored for this object.
 java.util.Vector getObjectBehaviors()
          Return the Group that holds this object's behaviors.
 TransformGroup getObjectNode()
          Return the TransformGroup that holds this object file
(package private)  int getParent()
          Returns parent object
(package private)  java.lang.String getQualifiedFilename(java.lang.String pathname, java.lang.String filename)
          This method takes the given path and filename and checks whether that file exists.
(package private)  java.net.URL getQualifiedURL(java.lang.String path, java.lang.String file)
           
(package private)  java.util.Vector getShapeList()
          Return list of Shape3D objects for this object file.
(package private)  void printVals()
          Utiliy function to print some of the object values.
 
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

fileName

java.lang.String fileName

objName

java.lang.String objName

motion

LwsMotion motion

parent

int parent

objectTransform

TransformGroup objectTransform

objectBehavior

java.util.Vector objectBehavior

shapeList

java.util.Vector shapeList

hasPivot

boolean hasPivot

pivotTransGroup

TransformGroup pivotTransGroup

urlName

java.net.URL urlName

protocol

java.lang.String protocol

fileType

int fileType
Constructor Detail

LwsObject

LwsObject(java.io.StreamTokenizer st,
          boolean loadObject,
          int firstFrame,
          int totalFrames,
          float totalTime,
          Lw3dLoader loader,
          int debugVals)
    throws java.io.FileNotFoundException,
           ParsingErrorException
Constructor: parses object section of this scene file and creates all appropriate data structures to hold the information

Parameters:
st - StreamTokenizer for scene file
loadObject - boolean specifying that object is not a lw3d Null object
firstFrame - int holding the first frame of the scene's animation
totalFrames - int holding the total number of frames in the scene
totalTime - float holding the total time of the animation
loader - Lw3dLoader loader object that was created by user
debugVals - in holding current debug flags
Throws:
java.io.FileNotFoundException
ParsingErrorException
Method Detail

getQualifiedFilename

java.lang.String getQualifiedFilename(java.lang.String pathname,
                                      java.lang.String filename)
                                throws java.io.FileNotFoundException
This method takes the given path and filename and checks whether that file exists. If not, it chops off the last part of pathname and recurse to try again. This has the effect of searching all the way up a given pathname for the existence of the file anywhere along that path. This is somewhat of a hack to get around the constraining way that Lightwave uses to define its data object locations in its scene files. If the filename is absolute, it will use the path information from the filename first, then the path information from the lws file. If the file can not be found in these locations, the local directory will be searched. In addition, it will look for filenames converted to lowercase to make it easier to use between Windows and Unix.

Throws:
java.io.FileNotFoundException

getQualifiedURL

java.net.URL getQualifiedURL(java.lang.String path,
                             java.lang.String file)
                       throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

getParent

int getParent()
Returns parent object


addChild

void addChild(LwsPrimitive child)
Adds the given child to the transform of this node (its parent).


createJava3dObject

void createJava3dObject(LwsObject cloneObject,
                        int loadBehaviors)
                  throws IncorrectFormatException,
                         ParsingErrorException,
                         java.io.FileNotFoundException
Creates Java3d objects from the data stored for this object. The objects created consist of: A TransformGroup that holds the transform specified by the first keyframe, a Behavior that acts on the TransformGroup if there are more than 1 keyframes, and some geometry (created by J3dLwoParser) from an external geometry file (if the object wasn't an lw3d Null object (group)).

Throws:
IncorrectFormatException
ParsingErrorException
java.io.FileNotFoundException

getShapeList

java.util.Vector getShapeList()
Return list of Shape3D objects for this object file. This is used when cloning objects (if the scene file requests the same object file more than once, that object will be cloned instead of recreated each time).


getObjectNode

public TransformGroup getObjectNode()
Return the TransformGroup that holds this object file

Specified by:
getObjectNode in interface LwsPrimitive

getObjectBehaviors

public java.util.Vector getObjectBehaviors()
Return the Group that holds this object's behaviors. The behaviors are grouped separately from the geometry so that they can be handled differently by the parent application.

Specified by:
getObjectBehaviors in interface LwsPrimitive

printVals

void printVals()
Utiliy function to print some of the object values. Used in debugging.



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