Search in sources :

Example 1 with MotionPath

use of com.jme3.cinematic.MotionPath in project jmonkeyengine by jMonkeyEngine.

the class TestCinematic method createCameraMotion.

private void createCameraMotion() {
    CameraNode camNode = cinematic.bindCamera("topView", cam);
    camNode.setLocalTranslation(new Vector3f(0, 50, 0));
    camNode.lookAt(teapot.getLocalTranslation(), Vector3f.UNIT_Y);
    CameraNode camNode2 = cinematic.bindCamera("aroundCam", cam);
    path = new MotionPath();
    path.setCycle(true);
    path.addWayPoint(new Vector3f(20, 3, 0));
    path.addWayPoint(new Vector3f(0, 3, 20));
    path.addWayPoint(new Vector3f(-20, 3, 0));
    path.addWayPoint(new Vector3f(0, 3, -20));
    path.setCurveTension(0.83f);
    cameraMotionEvent = new MotionEvent(camNode2, path);
    cameraMotionEvent.setLoopMode(LoopMode.Loop);
    cameraMotionEvent.setLookAt(model.getWorldTranslation(), Vector3f.UNIT_Y);
    cameraMotionEvent.setDirectionType(MotionEvent.Direction.LookAt);
}
Also used : CameraNode(com.jme3.scene.CameraNode) Vector3f(com.jme3.math.Vector3f) MotionPath(com.jme3.cinematic.MotionPath)

Example 2 with MotionPath

use of com.jme3.cinematic.MotionPath in project jmonkeyengine by jMonkeyEngine.

the class TestMotionPath method simpleInitApp.

@Override
public void simpleInitApp() {
    createScene();
    cam.setLocation(new Vector3f(8.4399185f, 11.189463f, 14.267577f));
    path = new MotionPath();
    path.addWayPoint(new Vector3f(10, 3, 0));
    path.addWayPoint(new Vector3f(10, 3, 10));
    path.addWayPoint(new Vector3f(-40, 3, 10));
    path.addWayPoint(new Vector3f(-40, 3, 0));
    path.addWayPoint(new Vector3f(-40, 8, 0));
    path.addWayPoint(new Vector3f(10, 8, 0));
    path.addWayPoint(new Vector3f(10, 8, 10));
    path.addWayPoint(new Vector3f(15, 8, 10));
    path.enableDebugShape(assetManager, rootNode);
    motionControl = new MotionEvent(teapot, path);
    motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
    motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y));
    motionControl.setInitialDuration(10f);
    motionControl.setSpeed(2f);
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    final BitmapText wayPointsText = new BitmapText(guiFont, false);
    wayPointsText.setSize(guiFont.getCharSet().getRenderedSize());
    guiNode.attachChild(wayPointsText);
    path.addListener(new MotionPathListener() {

        public void onWayPointReach(MotionEvent control, int wayPointIndex) {
            if (path.getNbWayPoints() == wayPointIndex + 1) {
                wayPointsText.setText(control.getSpatial().getName() + "Finished!!! ");
            } else {
                wayPointsText.setText(control.getSpatial().getName() + " Reached way point " + wayPointIndex);
            }
            wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);
        }
    });
    flyCam.setEnabled(false);
    ChaseCamera chaser = new ChaseCamera(cam, teapot);
    //        motionControl.setSpeed(-3f);
    //        motionControl.setLoopMode(LoopMode.Loop);
    //        path.setCycle(true);
    // chaser.setEnabled(false);
    chaser.registerWithInput(inputManager);
    initInputs();
}
Also used : MotionPathListener(com.jme3.cinematic.MotionPathListener) BitmapText(com.jme3.font.BitmapText) Quaternion(com.jme3.math.Quaternion) Vector3f(com.jme3.math.Vector3f) ChaseCamera(com.jme3.input.ChaseCamera) MotionPath(com.jme3.cinematic.MotionPath) MotionEvent(com.jme3.cinematic.events.MotionEvent)

Example 3 with MotionPath

use of com.jme3.cinematic.MotionPath in project jmonkeyengine by jMonkeyEngine.

the class TestCameraMotionPath method simpleInitApp.

@Override
public void simpleInitApp() {
    createScene();
    cam.setLocation(new Vector3f(8.4399185f, 11.189463f, 14.267577f));
    camNode = new CameraNode("Motion cam", cam);
    camNode.setControlDir(ControlDirection.SpatialToCamera);
    camNode.setEnabled(false);
    path = new MotionPath();
    path.setCycle(true);
    path.addWayPoint(new Vector3f(20, 3, 0));
    path.addWayPoint(new Vector3f(0, 3, 20));
    path.addWayPoint(new Vector3f(-20, 3, 0));
    path.addWayPoint(new Vector3f(0, 3, -20));
    path.setCurveTension(0.83f);
    path.enableDebugShape(assetManager, rootNode);
    cameraMotionControl = new MotionEvent(camNode, path);
    cameraMotionControl.setLoopMode(LoopMode.Loop);
    //cameraMotionControl.setDuration(15f);
    cameraMotionControl.setLookAt(teapot.getWorldTranslation(), Vector3f.UNIT_Y);
    cameraMotionControl.setDirectionType(MotionEvent.Direction.LookAt);
    rootNode.attachChild(camNode);
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    final BitmapText wayPointsText = new BitmapText(guiFont, false);
    wayPointsText.setSize(guiFont.getCharSet().getRenderedSize());
    guiNode.attachChild(wayPointsText);
    path.addListener(new MotionPathListener() {

        public void onWayPointReach(MotionEvent control, int wayPointIndex) {
            if (path.getNbWayPoints() == wayPointIndex + 1) {
                wayPointsText.setText(control.getSpatial().getName() + " Finish!!! ");
            } else {
                wayPointsText.setText(control.getSpatial().getName() + " Reached way point " + wayPointIndex);
            }
            wayPointsText.setLocalTranslation((cam.getWidth() - wayPointsText.getLineWidth()) / 2, cam.getHeight(), 0);
        }
    });
    flyCam.setEnabled(false);
    chaser = new ChaseCamera(cam, teapot);
    chaser.registerWithInput(inputManager);
    chaser.setSmoothMotion(true);
    chaser.setMaxDistance(50);
    chaser.setDefaultDistance(50);
    initInputs();
}
Also used : MotionPathListener(com.jme3.cinematic.MotionPathListener) BitmapText(com.jme3.font.BitmapText) Vector3f(com.jme3.math.Vector3f) CameraNode(com.jme3.scene.CameraNode) ChaseCamera(com.jme3.input.ChaseCamera) MotionPath(com.jme3.cinematic.MotionPath) MotionEvent(com.jme3.cinematic.events.MotionEvent)

Example 4 with MotionPath

use of com.jme3.cinematic.MotionPath in project jmonkeyengine by jMonkeyEngine.

the class TestJaime method setupCinematic.

public void setupCinematic(final Node jaime) {
    cinematic = new Cinematic(rootNode, 60);
    stateManager.attach(cinematic);
    jaime.move(0, 0, -3);
    AnimationFactory af = new AnimationFactory(0.7f, "JumpForward");
    af.addTimeTranslation(0, new Vector3f(0, 0, -3));
    af.addTimeTranslation(0.35f, new Vector3f(0, 1, -1.5f));
    af.addTimeTranslation(0.7f, new Vector3f(0, 0, 0));
    jaime.getControl(AnimControl.class).addAnim(af.buildAnimation());
    cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Idle", 3, LoopMode.DontLoop));
    float jumpStart = cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "JumpStart", LoopMode.DontLoop));
    cinematic.addCinematicEvent(jumpStart + 0.2f, new AnimationEvent(jaime, "JumpForward", LoopMode.DontLoop, 1));
    cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "JumpEnd", LoopMode.DontLoop));
    cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Punches", LoopMode.DontLoop));
    cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "SideKick", LoopMode.DontLoop));
    float camStart = cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Taunt", LoopMode.DontLoop));
    cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Idle", 1, LoopMode.DontLoop));
    cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Wave", LoopMode.DontLoop));
    cinematic.enqueueCinematicEvent(new AnimationEvent(jaime, "Idle", LoopMode.DontLoop));
    CameraNode camNode = cinematic.bindCamera("cam", cam);
    camNode.setLocalTranslation(new Vector3f(1.1f, 1.2f, 2.9f));
    camNode.lookAt(new Vector3f(0, 0.5f, 0), Vector3f.UNIT_Y);
    MotionPath path = new MotionPath();
    path.addWayPoint(new Vector3f(1.1f, 1.2f, 2.9f));
    path.addWayPoint(new Vector3f(0f, 1.2f, 3.0f));
    path.addWayPoint(new Vector3f(-1.1f, 1.2f, 2.9f));
    path.enableDebugShape(assetManager, rootNode);
    path.setCurveTension(0.8f);
    MotionEvent camMotion = new MotionEvent(camNode, path, 6);
    camMotion.setDirectionType(MotionEvent.Direction.LookAt);
    camMotion.setLookAt(new Vector3f(0, 0.5f, 0), Vector3f.UNIT_Y);
    cinematic.addCinematicEvent(camStart, camMotion);
    cinematic.activateCamera(0, "cam");
    cinematic.fitDuration();
    cinematic.setSpeed(1.2f);
    cinematic.setLoopMode(LoopMode.Loop);
    cinematic.play();
}
Also used : AnimationEvent(com.jme3.cinematic.events.AnimationEvent) Cinematic(com.jme3.cinematic.Cinematic) AnimationFactory(com.jme3.animation.AnimationFactory) Vector3f(com.jme3.math.Vector3f) CameraNode(com.jme3.scene.CameraNode) MotionPath(com.jme3.cinematic.MotionPath) AnimControl(com.jme3.animation.AnimControl) MotionEvent(com.jme3.cinematic.events.MotionEvent)

Example 5 with MotionPath

use of com.jme3.cinematic.MotionPath in project jmonkeyengine by jMonkeyEngine.

the class MotionEvent method read.

@Override
public void read(JmeImporter im) throws IOException {
    super.read(im);
    InputCapsule in = im.getCapsule(this);
    lookAt = (Vector3f) in.readSavable("lookAt", null);
    upVector = (Vector3f) in.readSavable("upVector", Vector3f.UNIT_Y);
    rotation = (Quaternion) in.readSavable("rotation", null);
    directionType = in.readEnum("directionType", Direction.class, Direction.None);
    path = (MotionPath) in.readSavable("path", null);
    spatial = (Spatial) in.readSavable("spatial", null);
}
Also used : InputCapsule(com.jme3.export.InputCapsule)

Aggregations

MotionPath (com.jme3.cinematic.MotionPath)4 Vector3f (com.jme3.math.Vector3f)4 MotionEvent (com.jme3.cinematic.events.MotionEvent)3 CameraNode (com.jme3.scene.CameraNode)3 MotionPathListener (com.jme3.cinematic.MotionPathListener)2 BitmapText (com.jme3.font.BitmapText)2 ChaseCamera (com.jme3.input.ChaseCamera)2 AnimControl (com.jme3.animation.AnimControl)1 AnimationFactory (com.jme3.animation.AnimationFactory)1 Cinematic (com.jme3.cinematic.Cinematic)1 AnimationEvent (com.jme3.cinematic.events.AnimationEvent)1 InputCapsule (com.jme3.export.InputCapsule)1 Quaternion (com.jme3.math.Quaternion)1