de.rico.engine.geometry.modelloader
Class Animation

java.lang.Object
  extended by de.rico.engine.geometry.modelloader.Animation

public class Animation
extends java.lang.Object

This class encapsulates the metadata for an animation, but not the triangles itself.

Author:
Frank Bruns

Constructor Summary
Animation(java.lang.String name, int start, int end, int dur)
          Creates a new animation with the specified data.
Animation(java.lang.String name, int start, int end, int dur, Mp3Sound sound)
          Creates a new animation with the specified data.
 
Method Summary
 int getCurrentFrame()
           
 int getDurPerFrame()
          Returns the duration per frame of the animation in miliseconds.
 int getEndFrame()
          Returns the last frame of the animation.
 java.lang.String getName()
          Returns the name of the animation.
 Mp3Sound getSound()
          Returns the mp3 sound that is assigned to the animation. if none was assigned the method returns null.
 int getStartFrame()
          Returns the number of the first frame of the animation.
 void reset()
          Resets the animation to its start frame.
 void setDurPerFrame(int durPerFrame)
          Sets the duration per frame of the animation in miliseconds.
 void setEndFrame(int endFrame)
          Sets the last frame of the animation.
 void setName(java.lang.String name)
          Sets the name of the animation.
 void setStartFrame(int startFrame)
          Sets the number of the first frame of the animation.
 void start()
          Starts/resumes the animation (and possible sound file playing) again.
 void stop()
          Stops the animation (and possible sound file playing)
 void update(long elapsedTime)
          Updates the animation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Animation

public Animation(java.lang.String name,
                 int start,
                 int end,
                 int dur)
Creates a new animation with the specified data.

Parameters:
name - name of the animation
start - number of the animation's start frame
end - number of the animation's end frame
dur - duration per frame

Animation

public Animation(java.lang.String name,
                 int start,
                 int end,
                 int dur,
                 Mp3Sound sound)
Creates a new animation with the specified data. You can specifiy the path to a (looped) mp3 sound file for the animation.

Note: The sound file needs to get stopped manually, before the animation gets changed. Otherwise the sound would play forever and ever.

Parameters:
name - name of the animation
start - number of the animation's start frame
end - number of the animation's end frame
dur - duration per frame
sound - possibly looped mp3 sound file
Method Detail

getDurPerFrame

public int getDurPerFrame()
Returns the duration per frame of the animation in miliseconds.

Returns:
duration per frame

setDurPerFrame

public void setDurPerFrame(int durPerFrame)
Sets the duration per frame of the animation in miliseconds.

Parameters:
durPerFrame - new duration per frame

getEndFrame

public int getEndFrame()
Returns the last frame of the animation.

Returns:
number of the last frame of the animation

setEndFrame

public void setEndFrame(int endFrame)
Sets the last frame of the animation.

Parameters:
endFrame - number of the last animation frame

getName

public java.lang.String getName()
Returns the name of the animation.

Returns:
name of the animation

setName

public void setName(java.lang.String name)
Sets the name of the animation.

Parameters:
name - name of the animation

getStartFrame

public int getStartFrame()
Returns the number of the first frame of the animation.

Returns:
number of the animation's start frame

setStartFrame

public void setStartFrame(int startFrame)
Sets the number of the first frame of the animation.

Parameters:
startFrame - number of the animation's start frame

getSound

public Mp3Sound getSound()
Returns the mp3 sound that is assigned to the animation. if none was assigned the method returns null.

Returns:
assigned mp3 sound of the animation

reset

public void reset()
Resets the animation to its start frame.


stop

public void stop()
Stops the animation (and possible sound file playing)


start

public void start()
Starts/resumes the animation (and possible sound file playing) again.


getCurrentFrame

public int getCurrentFrame()

update

public void update(long elapsedTime)
Updates the animation.

Parameters:
elapsedTime - time between two frames