Renamed AnimationHelper to AnimationFactory
git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8958 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
e902588700
commit
d6124d3489
@ -52,7 +52,7 @@ import com.jme3.math.Vector3f;
|
|||||||
*
|
*
|
||||||
* @author Nehon
|
* @author Nehon
|
||||||
*/
|
*/
|
||||||
public class AnimationHelper {
|
public class AnimationFactory {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* step for splitting rotation that have a n ange above PI/2
|
* step for splitting rotation that have a n ange above PI/2
|
||||||
@ -150,7 +150,7 @@ public class AnimationHelper {
|
|||||||
* @param duration the desired duration for the resulting animation
|
* @param duration the desired duration for the resulting animation
|
||||||
* @param name the name of the resulting animation
|
* @param name the name of the resulting animation
|
||||||
*/
|
*/
|
||||||
public AnimationHelper(float duration, String name) {
|
public AnimationFactory(float duration, String name) {
|
||||||
this(duration, name, 30);
|
this(duration, name, 30);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ public class AnimationHelper {
|
|||||||
* @param name the name of the resulting animation
|
* @param name the name of the resulting animation
|
||||||
* @param fps the number of frames per second for this animation (default is 30)
|
* @param fps the number of frames per second for this animation (default is 30)
|
||||||
*/
|
*/
|
||||||
public AnimationHelper(float duration, String name, int fps) {
|
public AnimationFactory(float duration, String name, int fps) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
this.fps = fps;
|
this.fps = fps;
|
@ -32,7 +32,7 @@
|
|||||||
package jme3test.animation;
|
package jme3test.animation;
|
||||||
|
|
||||||
import com.jme3.animation.AnimControl;
|
import com.jme3.animation.AnimControl;
|
||||||
import com.jme3.animation.AnimationHelper;
|
import com.jme3.animation.AnimationFactory;
|
||||||
import com.jme3.animation.LoopMode;
|
import com.jme3.animation.LoopMode;
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
import com.jme3.cinematic.Cinematic;
|
import com.jme3.cinematic.Cinematic;
|
||||||
@ -108,28 +108,28 @@ public class TestCinematic extends SimpleApplication {
|
|||||||
createCameraMotion();
|
createCameraMotion();
|
||||||
|
|
||||||
//creating spatial animation for the teapot
|
//creating spatial animation for the teapot
|
||||||
AnimationHelper helper = new AnimationHelper(20, "teapotAnim");
|
AnimationFactory factory = new AnimationFactory(20, "teapotAnim");
|
||||||
helper.addTimeTranslation(0, new Vector3f(10, 0, 10));
|
factory.addTimeTranslation(0, new Vector3f(10, 0, 10));
|
||||||
helper.addTimeTranslation(20, new Vector3f(10, 0, -10));
|
factory.addTimeTranslation(20, new Vector3f(10, 0, -10));
|
||||||
helper.addTimeScale(10, new Vector3f(4, 4, 4));
|
factory.addTimeScale(10, new Vector3f(4, 4, 4));
|
||||||
helper.addTimeScale(20, new Vector3f(1, 1, 1));
|
factory.addTimeScale(20, new Vector3f(1, 1, 1));
|
||||||
helper.addTimeRotation(20, new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y));
|
factory.addTimeRotationAngles(20, 0, 4 * FastMath.TWO_PI, 0);
|
||||||
AnimControl control = new AnimControl();
|
AnimControl control = new AnimControl();
|
||||||
control.addAnim(helper.buildAnimation());
|
control.addAnim(factory.buildAnimation());
|
||||||
teapot.addControl(control);
|
teapot.addControl(control);
|
||||||
|
|
||||||
//fade in
|
//fade in
|
||||||
cinematic.addCinematicEvent(0, new FadeEvent(true));
|
cinematic.addCinematicEvent(0, new FadeEvent(true));
|
||||||
cinematic.activateCamera(0, "aroundCam");
|
// cinematic.activateCamera(0, "aroundCam");
|
||||||
cinematic.addCinematicEvent(0, new AnimationTrack(teapot, "teapotAnim", LoopMode.DontLoop));
|
cinematic.addCinematicEvent(0, new AnimationTrack(teapot, "teapotAnim", LoopMode.DontLoop));
|
||||||
cinematic.addCinematicEvent(0, cameraMotionTrack);
|
cinematic.addCinematicEvent(0, cameraMotionTrack);
|
||||||
cinematic.addCinematicEvent(0, new SoundTrack("Sound/Environment/Nature.ogg", LoopMode.Loop));
|
cinematic.addCinematicEvent(0, new SoundTrack("Sound/Environment/Nature.ogg", LoopMode.Loop));
|
||||||
cinematic.addCinematicEvent(3f, new SoundTrack("Sound/Effects/kick.wav"));
|
cinematic.addCinematicEvent(3f, new SoundTrack("Sound/Effects/kick.wav"));
|
||||||
cinematic.addCinematicEvent(3, new SubtitleTrack(nifty, "start", 3, "jMonkey engine really kicks A..."));
|
cinematic.addCinematicEvent(3, new SubtitleTrack(nifty, "start", 3, "jMonkey engine really kicks A..."));
|
||||||
cinematic.addCinematicEvent(5.1f, new SoundTrack("Sound/Effects/Beep.ogg", 1));
|
cinematic.addCinematicEvent(5.1f, new SoundTrack("Sound/Effects/Beep.ogg", 1));
|
||||||
cinematic.addCinematicEvent(2, new AnimationTrack(model, "Walk", LoopMode.Loop));
|
cinematic.addCinematicEvent(2, new AnimationTrack(model, "Walk", LoopMode.Loop));
|
||||||
cinematic.activateCamera(6, "topView");
|
cinematic.activateCamera(0, "topView");
|
||||||
cinematic.activateCamera(10, "aroundCam");
|
// cinematic.activateCamera(10, "aroundCam");
|
||||||
|
|
||||||
//fade out
|
//fade out
|
||||||
cinematic.addCinematicEvent(19, new FadeEvent(false));
|
cinematic.addCinematicEvent(19, new FadeEvent(false));
|
||||||
@ -184,7 +184,7 @@ public class TestCinematic extends SimpleApplication {
|
|||||||
|
|
||||||
CameraNode camNode = cinematic.bindCamera("topView", cam);
|
CameraNode camNode = cinematic.bindCamera("topView", cam);
|
||||||
camNode.setLocalTranslation(new Vector3f(0, 50, 0));
|
camNode.setLocalTranslation(new Vector3f(0, 50, 0));
|
||||||
camNode.lookAt(model.getLocalTranslation(), Vector3f.UNIT_Y);
|
camNode.lookAt(teapot.getLocalTranslation(), Vector3f.UNIT_Y);
|
||||||
|
|
||||||
CameraNode camNode2 = cinematic.bindCamera("aroundCam", cam);
|
CameraNode camNode2 = cinematic.bindCamera("aroundCam", cam);
|
||||||
path = new MotionPath();
|
path = new MotionPath();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package jme3test.model.anim;
|
package jme3test.model.anim;
|
||||||
|
|
||||||
import com.jme3.animation.AnimControl;
|
import com.jme3.animation.AnimControl;
|
||||||
import com.jme3.animation.AnimationHelper;
|
import com.jme3.animation.AnimationFactory;
|
||||||
import com.jme3.app.SimpleApplication;
|
import com.jme3.app.SimpleApplication;
|
||||||
import com.jme3.light.AmbientLight;
|
import com.jme3.light.AmbientLight;
|
||||||
import com.jme3.light.DirectionalLight;
|
import com.jme3.light.DirectionalLight;
|
||||||
@ -13,7 +13,7 @@ import com.jme3.scene.Node;
|
|||||||
import com.jme3.scene.shape.Box;
|
import com.jme3.scene.shape.Box;
|
||||||
import com.jme3.util.TangentBinormalGenerator;
|
import com.jme3.util.TangentBinormalGenerator;
|
||||||
|
|
||||||
public class TestAnimationHelper extends SimpleApplication {
|
public class TestAnimationFactory extends SimpleApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
TestSpatialAnim app = new TestSpatialAnim();
|
TestSpatialAnim app = new TestSpatialAnim();
|
||||||
@ -48,32 +48,32 @@ public class TestAnimationHelper extends SimpleApplication {
|
|||||||
|
|
||||||
//creating quite complex animation witht the AnimationHelper
|
//creating quite complex animation witht the AnimationHelper
|
||||||
// animation of 6 seconds named "anim" and with 25 frames per second
|
// animation of 6 seconds named "anim" and with 25 frames per second
|
||||||
AnimationHelper animationHelper = new AnimationHelper(6, "anim", 25);
|
AnimationFactory animationFactory = new AnimationFactory(6, "anim", 25);
|
||||||
|
|
||||||
//creating a translation keyFrame at time = 3 with a translation on the x axis of 5 WU
|
//creating a translation keyFrame at time = 3 with a translation on the x axis of 5 WU
|
||||||
animationHelper.addTimeTranslation(3, new Vector3f(5, 0, 0));
|
animationFactory.addTimeTranslation(3, new Vector3f(5, 0, 0));
|
||||||
//reseting the translation to the start position at time = 6
|
//reseting the translation to the start position at time = 6
|
||||||
animationHelper.addTimeTranslation(6, new Vector3f(0, 0, 0));
|
animationFactory.addTimeTranslation(6, new Vector3f(0, 0, 0));
|
||||||
|
|
||||||
//Creating a scale keyFrame at time = 2 with the unit scale.
|
//Creating a scale keyFrame at time = 2 with the unit scale.
|
||||||
animationHelper.addTimeScale(2, new Vector3f(1, 1, 1));
|
animationFactory.addTimeScale(2, new Vector3f(1, 1, 1));
|
||||||
//Creating a scale keyFrame at time = 4 scaling to 1.5
|
//Creating a scale keyFrame at time = 4 scaling to 1.5
|
||||||
animationHelper.addTimeScale(4, new Vector3f(1.5f, 1.5f, 1.5f));
|
animationFactory.addTimeScale(4, new Vector3f(1.5f, 1.5f, 1.5f));
|
||||||
//reseting the scale to the start value at time = 5
|
//reseting the scale to the start value at time = 5
|
||||||
animationHelper.addTimeScale(5, new Vector3f(1, 1, 1));
|
animationFactory.addTimeScale(5, new Vector3f(1, 1, 1));
|
||||||
|
|
||||||
|
|
||||||
//Creating a rotation keyFrame at time = 0.5 of quarter PI around the Z axis
|
//Creating a rotation keyFrame at time = 0.5 of quarter PI around the Z axis
|
||||||
animationHelper.addTimeRotation(0.5f,new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Z));
|
animationFactory.addTimeRotation(0.5f,new Quaternion().fromAngleAxis(FastMath.QUARTER_PI, Vector3f.UNIT_Z));
|
||||||
//rotating back to initial rotation value at time = 1
|
//rotating back to initial rotation value at time = 1
|
||||||
animationHelper.addTimeRotation(1,Quaternion.IDENTITY);
|
animationFactory.addTimeRotation(1,Quaternion.IDENTITY);
|
||||||
//Creating a rotation keyFrame at time = 2. Note that i used the Euler angle version because the angle is higher than PI
|
//Creating a rotation keyFrame at time = 2. Note that i used the Euler angle version because the angle is higher than PI
|
||||||
//this should result in a complete revolution of the spatial around the x axis in 1 second (from 1 to 2)
|
//this should result in a complete revolution of the spatial around the x axis in 1 second (from 1 to 2)
|
||||||
animationHelper.addTimeRotationAngles(2, FastMath.TWO_PI,0, 0);
|
animationFactory.addTimeRotationAngles(2, FastMath.TWO_PI,0, 0);
|
||||||
|
|
||||||
|
|
||||||
AnimControl control = new AnimControl();
|
AnimControl control = new AnimControl();
|
||||||
control.addAnim(animationHelper.buildAnimation());
|
control.addAnim(animationFactory.buildAnimation());
|
||||||
|
|
||||||
model.addControl(control);
|
model.addControl(control);
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user