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);
}
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();
}
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;
}
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;
}
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);
}
Aggregations