m3g11
Class UvAnimation

java.lang.Object
  extended by m3g11.UvAnimation

public class UvAnimation
extends java.lang.Object

Encapsulates a UV animation. UV animations display sequences of images by modifying texture coordinates.

Author:
Claus Hoefele

Field Summary
private  javax.microedition.m3g.AnimationController controller
          Controller for animation.
private  int duration
          Duration of animation.
 
Constructor Summary
protected UvAnimation(javax.microedition.m3g.AnimationController controller, int duration)
          Protected because a new UvAnimation object must be created with one of the static create methods.
 
Method Summary
private static UvAnimation createAnimation(javax.microedition.m3g.Mesh mesh, javax.microedition.m3g.Image2D image, javax.microedition.m3g.KeyframeSequence sequence, float scaleX, float scaleY)
          Creates a UV animation based on the given parameters.
static UvAnimation createConveyorBeltAnimation(javax.microedition.m3g.Mesh mesh, javax.microedition.m3g.Image2D image, int duration, float scaleX)
          Creates an animation where an image is scrolled horizontally as if it were attached to a conveyor belt.
static UvAnimation createFlipBookAnimation(javax.microedition.m3g.Mesh mesh, javax.microedition.m3g.Image2D image, int delay, int framesX, int framesY)
          Creates an animation where frames inside an image are displayed successively like in a flip-book animation.
 void playBackward(int worldTime)
          Plays the animation in backward direction.
 void playForward(int worldTime)
          Plays the animation in forward direction.
 void stop()
          Stops the animation.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

controller

private javax.microedition.m3g.AnimationController controller
Controller for animation.


duration

private int duration
Duration of animation.

Constructor Detail

UvAnimation

protected UvAnimation(javax.microedition.m3g.AnimationController controller,
                      int duration)
Protected because a new UvAnimation object must be created with one of the static create methods.

Parameters:
controller - animation controller.
duration - duration of animation.
See Also:
createConveyorBeltAnimation(javax.microedition.m3g.Mesh, javax.microedition.m3g.Image2D, int, float), createFlipBookAnimation(javax.microedition.m3g.Mesh, javax.microedition.m3g.Image2D, int, int, int)
Method Detail

createAnimation

private static UvAnimation createAnimation(javax.microedition.m3g.Mesh mesh,
                                           javax.microedition.m3g.Image2D image,
                                           javax.microedition.m3g.KeyframeSequence sequence,
                                           float scaleX,
                                           float scaleY)
Creates a UV animation based on the given parameters.

Parameters:
mesh - mesh to use for UV animation.
image - image to use for UV animation.
sequence - animation sequence.
scaleX - scaling factor of texture in x direction.
scaleY - scaling factor of texture in y direction.
Returns:
new UvAnimation object.

createConveyorBeltAnimation

public static UvAnimation createConveyorBeltAnimation(javax.microedition.m3g.Mesh mesh,
                                                      javax.microedition.m3g.Image2D image,
                                                      int duration,
                                                      float scaleX)
Creates an animation where an image is scrolled horizontally as if it were attached to a conveyor belt.

Parameters:
mesh - mesh to use for UV animation.
image - image to use for UV animation.
duration - duration of one entire rotation.
scaleX - scaling factor of texture in x direction.
Returns:
new UvAnimation object.

createFlipBookAnimation

public static UvAnimation createFlipBookAnimation(javax.microedition.m3g.Mesh mesh,
                                                  javax.microedition.m3g.Image2D image,
                                                  int delay,
                                                  int framesX,
                                                  int framesY)
Creates an animation where frames inside an image are displayed successively like in a flip-book animation.

Parameters:
mesh - mesh to use for UV animation.
image - image to use for UV animation.
delay - delay between successive frames.
framesX - number of frames inside the image in x direction.
framesY - number of frames inside the image in y direction.
Returns:
new UvAnimation object.

stop

public void stop()
Stops the animation.


playForward

public void playForward(int worldTime)
Plays the animation in forward direction.

Parameters:
worldTime - current world time.

playBackward

public void playBackward(int worldTime)
Plays the animation in backward direction.

Parameters:
worldTime - current world time.