Java Code Examples for com.jme3.cinematic.MotionPath#addWayPoint()
The following examples show how to use
com.jme3.cinematic.MotionPath#addWayPoint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CreateMotionControlAction.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread protected @NotNull Control createControl(@NotNull final Spatial parent) { final MotionPath motionPath = new MotionPath(); motionPath.addWayPoint(Vector3f.ZERO.clone()); motionPath.addWayPoint(new Vector3f(0f, 1f, 0f)); motionPath.addWayPoint(new Vector3f(1f, 0f, 1f)); final MotionEvent control = new MotionEvent(); control.setLookAt(Vector3f.UNIT_Z, Vector3f.UNIT_Y); control.setRotation(Quaternion.IDENTITY); control.setPath(motionPath); return control; }
Example 2
Source File: TestCinematic.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 6 votes |
private void createCameraMotion() { CameraNode camNode = cinematic.bindCamera("topView", cam); camNode.setLocalTranslation(new Vector3f(0, 50, 0)); camNode.lookAt(model.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); cameraMotionTrack = new MotionTrack(camNode2, path); cameraMotionTrack.setLoopMode(LoopMode.Loop); cameraMotionTrack.setLookAt(model.getWorldTranslation(), Vector3f.UNIT_Y); cameraMotionTrack.setDirectionType(MotionTrack.Direction.LookAt); }
Example 3
Source File: TestCameraMotionPath.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@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() { @Override 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(); }
Example 4
Source File: TestJaime.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
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(); }
Example 5
Source File: TestMotionPath.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
@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() { @Override 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(); }
Example 6
Source File: TestCameraMotionPath.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@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.getControl(CameraControl.class).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 MotionTrack(camNode, path); cameraMotionControl.setLoopMode(LoopMode.Loop); //cameraMotionControl.setDuration(15f); cameraMotionControl.setLookAt(teapot.getWorldTranslation(), Vector3f.UNIT_Y); cameraMotionControl.setDirectionType(MotionTrack.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(MotionTrack 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(); }
Example 7
Source File: TestMotionPath.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 4 votes |
@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 MotionTrack(teapot,path); motionControl.setDirectionType(MotionTrack.Direction.PathAndRotation); motionControl.setRotation(new Quaternion().fromAngleNormalAxis(-FastMath.HALF_PI, Vector3f.UNIT_Y)); motionControl.setInitialDuration(10f); motionControl.setSpeed(0.1f); 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(MotionTrack 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); // chaser.setEnabled(false); chaser.registerWithInput(inputManager); initInputs(); }