Search in sources :

Example 6 with MotionEvent

use of com.jme3.cinematic.events.MotionEvent 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 7 with MotionEvent

use of com.jme3.cinematic.events.MotionEvent 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 8 with MotionEvent

use of com.jme3.cinematic.events.MotionEvent in project jmonkeyengine by jMonkeyEngine.

the class AndroidGestureProcessor method onScroll.

@Override
public boolean onScroll(MotionEvent startEvent, MotionEvent endEvent, float distX, float distY) {
    // for the fact that jME has y=0 at bottom where Android has y=0 at top.
    if (!touchInput.getScaleDetector().isInProgress()) {
        //            logger.log(Level.INFO, "onScroll pointerId: {0}, startAction: {1}, startX: {2}, startY: {3}, endAction: {4}, endX: {5}, endY: {6}, dx: {7}, dy: {8}",
        //                    new Object[]{touchInput.getPointerId(startEvent), touchInput.getAction(startEvent), startEvent.getX(), startEvent.getY(), touchInput.getAction(endEvent), endEvent.getX(), endEvent.getY(), distX, distY});
        float jmeX = touchInput.getJmeX(endEvent.getX());
        float jmeY = touchInput.invertY(touchInput.getJmeY(endEvent.getY()));
        TouchEvent touchEvent = touchInput.getFreeTouchEvent();
        touchEvent.set(TouchEvent.Type.SCROLL, jmeX, jmeY, touchInput.getJmeX(-distX), touchInput.getJmeY(distY));
        touchEvent.setPointerId(touchInput.getPointerId(endEvent));
        touchEvent.setTime(endEvent.getEventTime());
        touchEvent.setPressure(endEvent.getPressure());
        touchInput.addEvent(touchEvent);
    }
    return true;
}
Also used : TouchEvent(com.jme3.input.event.TouchEvent)

Example 9 with MotionEvent

use of com.jme3.cinematic.events.MotionEvent in project jmonkeyengine by jMonkeyEngine.

the class AndroidGestureProcessor method onDoubleTapEvent.

@Override
public boolean onDoubleTapEvent(MotionEvent event) {
    //                new Object[]{touchInput.getPointerId(event), touchInput.getAction(event), event.getX(), event.getY()});
    if (touchInput.getAction(event) == MotionEvent.ACTION_UP) {
        TouchEvent touchEvent = touchInput.getFreeTouchEvent();
        touchEvent.set(TouchEvent.Type.DOUBLETAP, event.getX(), touchInput.invertY(event.getY()), 0, 0);
        touchEvent.setPointerId(touchInput.getPointerId(event));
        touchEvent.setTime(event.getEventTime());
        touchEvent.setPressure(event.getPressure());
        touchInput.addEvent(touchEvent);
    }
    return true;
}
Also used : TouchEvent(com.jme3.input.event.TouchEvent)

Example 10 with MotionEvent

use of com.jme3.cinematic.events.MotionEvent in project jmonkeyengine by jMonkeyEngine.

the class AndroidGestureProcessor method onLongPress.

@Override
public void onLongPress(MotionEvent event) {
    //        logger.log(Level.INFO, "onLongPress pointerId: {0}, action: {1}, x: {2}, y: {3}",
    //                new Object[]{touchInput.getPointerId(event), touchInput.getAction(event), event.getX(), event.getY()});
    float jmeX = touchInput.getJmeX(event.getX());
    float jmeY = touchInput.invertY(touchInput.getJmeY(event.getY()));
    TouchEvent touchEvent = touchInput.getFreeTouchEvent();
    touchEvent.set(TouchEvent.Type.LONGPRESSED, jmeX, jmeY, 0, 0);
    touchEvent.setPointerId(touchInput.getPointerId(event));
    touchEvent.setTime(event.getEventTime());
    touchEvent.setPressure(event.getPressure());
    touchInput.addEvent(touchEvent);
}
Also used : TouchEvent(com.jme3.input.event.TouchEvent)

Aggregations

TouchEvent (com.jme3.input.event.TouchEvent)9 Vector3f (com.jme3.math.Vector3f)5 MotionPath (com.jme3.cinematic.MotionPath)4 MotionEvent (com.jme3.cinematic.events.MotionEvent)3 Vector2f (com.jme3.math.Vector2f)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 DefaultJoystickAxis (com.jme3.input.DefaultJoystickAxis)1 JoystickAxis (com.jme3.input.JoystickAxis)1 JoyAxisEvent (com.jme3.input.event.JoyAxisEvent)1 Quaternion (com.jme3.math.Quaternion)1 TempVars (com.jme3.util.TempVars)1