com.sun.j3d.loaders.lw3d
Class LwsMotion

java.lang.Object
  extended by com.sun.j3d.loaders.lw3d.TextfileParser
      extended by com.sun.j3d.loaders.lw3d.LwsMotion

 class LwsMotion
extends TextfileParser

This class is responsible for parsing the data in a Scene file related to an object's animation and constructing the appropriate Java3D Behavior objects. For each keyframe defined for the animation in the Lightwave file, this class creates a LwsFrame object to parse that keyframe data and create the appropriate data structures. Then for each of those LwsFrame objects created, LwsMotion creates a knot value for a PathInterpolator and fills in the appropriate field. Finally, the class creates a RotPosScalePathInterpolator with all of the data from the animation. There are also some utility functions in this class for dealing with special cases of animations, such as animations that begin after the first frame of the scene and animations that define frames in a way that Java3D cannot easily interpret.


Nested Class Summary
(package private)  class LwsMotion.FrameHolder
          Class that associates a particular frame with its effective frame number (which accounts for animations that start after frame 1)
 
Field Summary
(package private)  Behavior behaviors
           
(package private)  int firstFrame
           
(package private)  LwsFrame[] frames
           
(package private)  boolean loop
           
(package private)  java.lang.String motionName
           
(package private)  int numChannels
           
(package private)  int numFrames
           
(package private)  int totalFrames
           
(package private)  float totalTime
           
 
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
LwsMotion(java.io.StreamTokenizer st, int frames, float time)
          Constructor
LwsMotion(java.io.StreamTokenizer st, int firstFrame, int frames, float time, int debugVals)
          Constructor: takes tokenizer, 1st frame of this animation, total number of frames, total time of animation, and the debug settings
 
Method Summary
(package private)  void createJava3dBehaviors(TransformGroup target)
          Create j3d behaviors for the data stored in this animation.
(package private)  void createJava3dBehaviorsForFramesSubset(TransformGroup target)
          Normally, we just create j3d behaviors from the frames.
(package private)  void fixFrames()
          The previous version of this method looked for sucessive frames with the same rotation value (mod 2PI).
(package private)  Behavior getBehaviors()
          Returns the Behavior object created for this animation
(package private)  LwsFrame getFirstFrame()
          Returns the first LwsFrame object (which contains the initial setup for a given object)
(package private)  void getMotion(java.io.StreamTokenizer st)
          This method parses the tokenizer and creates the data structures that hold the data from that file.
(package private)  int intMod(int divisee, int divisor)
          Utility for getting integer mod value
(package private)  void playWithFrameTimes(java.util.Vector framesVector)
          This method was added to account for animations that start after the first frame (e.g., Juggler.lws starts at frame 30).
(package private)  void printVals()
          Utility function for printing 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

motionName

java.lang.String motionName

frames

LwsFrame[] frames

numFrames

int numFrames

numChannels

int numChannels

loop

boolean loop

totalTime

float totalTime

firstFrame

int firstFrame

totalFrames

int totalFrames

behaviors

Behavior behaviors
Constructor Detail

LwsMotion

LwsMotion(java.io.StreamTokenizer st,
          int frames,
          float time)
Constructor


LwsMotion

LwsMotion(java.io.StreamTokenizer st,
          int firstFrame,
          int frames,
          float time,
          int debugVals)
    throws ParsingErrorException,
           IncorrectFormatException
Constructor: takes tokenizer, 1st frame of this animation, total number of frames, total time of animation, and the debug settings

Throws:
ParsingErrorException
IncorrectFormatException
Method Detail

getMotion

void getMotion(java.io.StreamTokenizer st)
         throws ParsingErrorException,
                IncorrectFormatException
This method parses the tokenizer and creates the data structures that hold the data from that file. For each separate keyframe, this method calls LwsFrame to parse and interpret that data.

Throws:
ParsingErrorException
IncorrectFormatException

fixFrames

void fixFrames()
The previous version of this method looked for sucessive frames with the same rotation value (mod 2PI). If it found such frames, it would divide that interval into 4 separate frames. This fix is not sufficient for various rotation cases, though. For instance, if the rotation difference between two frames is more than 2PI, the rotation will not case a flag to be fixed and the resulting rotation will only be between the delta of the two rotations, mod 2PI. The real fix should behave as follows: - Iterate through all sucessive frames - For any two frames that have rotation components that differ by more than PI/2 (one quarter rotation - no reason for this, but let's pick a small value to give our resulting path interpolations a better chance of behaving correctly), figure out how many frames we need to create to get increments of <= PI/2 between each frame. - Create these new frames - Set the odl frames pointer to the new frames structures.


intMod

int intMod(int divisee,
           int divisor)
Utility for getting integer mod value


playWithFrameTimes

void playWithFrameTimes(java.util.Vector framesVector)
This method was added to account for animations that start after the first frame (e.g., Juggler.lws starts at frame 30). We need to alter some of the information for the frames in this "frame subset"


createJava3dBehaviorsForFramesSubset

void createJava3dBehaviorsForFramesSubset(TransformGroup target)
Normally, we just create j3d behaviors from the frames. But if the animation's first frame is after frame number one, then we have to shuffle things around to account for playing/looping on this subset of the total frames of the animation


createJava3dBehaviors

void createJava3dBehaviors(TransformGroup target)
Create j3d behaviors for the data stored in this animation. This is done by creating a RotPosScalePathInterpolator object that contains all of the position, orientation, scale data for each keyframe.


getBehaviors

Behavior getBehaviors()
Returns the Behavior object created for this animation


getFirstFrame

LwsFrame getFirstFrame()
Returns the first LwsFrame object (which contains the initial setup for a given object)


printVals

void printVals()
Utility function for printing values



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