com.jme3.cinematic.MotionPath Java Examples
The following examples show how to use
com.jme3.cinematic.MotionPath.
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: PrimitiveTreeNodeFactory.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread public <T, V extends TreeNode<T>> @Nullable V createFor(@Nullable final T element, final long objectId) { if (element instanceof Vector3f) { return unsafeCast(new PositionTreeNode((Vector3f) element, objectId)); } else if (element instanceof VertexBuffer) { return unsafeCast(new VertexBufferTreeNode((VertexBuffer) element, objectId)); } else if (element instanceof Buffer) { return unsafeCast(new BufferTreeNode((Buffer) element, objectId)); } else if (element instanceof VehicleWheel) { return unsafeCast(new VehicleWheelTreeNode((VehicleWheel) element, objectId)); } else if (element instanceof MotionPath) { return unsafeCast(new MotionPathTreeNode((MotionPath) element, objectId)); } return null; }
Example #2
Source File: MotionPathTreeNode.java From jmonkeybuilder with Apache License 2.0 | 6 votes |
@Override @FxThread public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) { final MotionPath element = getElement(); final int wayPoints = element.getNbWayPoints(); final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class); for (int i = 0; i < wayPoints; i++) { final PositionTreeNode modelNode = notNull(FACTORY_REGISTRY.createFor(element.getWayPoint(i))); modelNode.setName(Messages.MODEL_FILE_EDITOR_NODE_WAY_POINT + " #" + (i + 1)); result.add(modelNode); } return result; }
Example #3
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 #4
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 #5
Source File: MotionEventTreeNode.java From jmonkeybuilder with Apache License 2.0 | 5 votes |
@Override @FxThread public @NotNull Array<TreeNode<?>> getChildren(@NotNull final NodeTree<?> nodeTree) { final MotionPath path = getElement().getPath(); final Array<TreeNode<?>> result = ArrayFactory.newArray(TreeNode.class); result.add(FACTORY_REGISTRY.createFor(path)); return result; }
Example #6
Source File: MotionTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
@Override public void read(JmeImporter im) throws IOException { super.read(im); InputCapsule in = im.getCapsule(this); lookAt = (Vector3f) in.readSavable("lookAt", Vector3f.ZERO); upVector = (Vector3f) in.readSavable("upVector", Vector3f.UNIT_Y); rotation = (Quaternion) in.readSavable("rotation", Quaternion.IDENTITY); directionType = in.readEnum("directionType", Direction.class, Direction.None); path = (MotionPath) in.readSavable("path", null); }
Example #7
Source File: MotionTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Creates a MotionPath for the given spatial on the given motion path * @param spatial * @param path */ public MotionTrack(Spatial spatial, MotionPath path, float initialDuration, LoopMode loopMode) { super(initialDuration); this.spatial = spatial; spatial.addControl(this); this.path = path; this.loopMode = loopMode; }
Example #8
Source File: MotionTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Creates a MotionPath for the given spatial on the given motion path * @param spatial * @param path */ public MotionTrack(Spatial spatial, MotionPath path, LoopMode loopMode) { super(); this.spatial = spatial; spatial.addControl(this); this.path = path; this.loopMode = loopMode; }
Example #9
Source File: MotionTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Creates a MotionPath for the given spatial on the given motion path * @param spatial * @param path */ public MotionTrack(Spatial spatial, MotionPath path, float initialDuration) { super(initialDuration); this.spatial = spatial; spatial.addControl(this); this.path = path; }
Example #10
Source File: MotionTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 5 votes |
/** * Creates a MotionPath for the given spatial on the given motion path * @param spatial * @param path */ public MotionTrack(Spatial spatial, MotionPath path) { super(); this.spatial = spatial; spatial.addControl(this); this.path = path; }
Example #11
Source File: MotionEvent.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
@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); }
Example #12
Source File: MotionEvent.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path, float initialDuration, LoopMode loopMode) { super(initialDuration); spatial.addControl(this); this.path = path; this.loopMode = loopMode; }
Example #13
Source File: MotionEvent.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path, LoopMode loopMode) { super(); spatial.addControl(this); this.path = path; this.loopMode = loopMode; }
Example #14
Source File: MotionEvent.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path, float initialDuration) { super(initialDuration); spatial.addControl(this); this.path = path; }
Example #15
Source File: MotionEvent.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Creates a MotionPath for the given spatial on the given motion path. * @param spatial * @param path */ public MotionEvent(Spatial spatial, MotionPath path) { super(); spatial.addControl(this); this.path = path; }
Example #16
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 #17
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(); }
Example #18
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 #19
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 #20
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 #21
Source File: MotionPathTreeNode.java From jmonkeybuilder with Apache License 2.0 | 4 votes |
public MotionPathTreeNode(@NotNull final MotionPath element, final long objectId) { super(element, objectId); }
Example #22
Source File: MotionTrack.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Creates a MotionPath for the given spatial on the given motion path * @param spatial * @param path */ public MotionTrack(Spatial spatial, MotionPath path, float initialDuration, LoopMode loopMode) { super(spatial, path, initialDuration, loopMode); }
Example #23
Source File: MotionTrack.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Creates a MotionPath for the given spatial on the given motion path * @param spatial * @param path */ public MotionTrack(Spatial spatial, MotionPath path, LoopMode loopMode) { super(spatial, path, loopMode); }
Example #24
Source File: MotionEvent.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Return the motion path this control follows. * @return the pre-existing instance */ public MotionPath getPath() { return path; }
Example #25
Source File: MotionEvent.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Sets the motion path to follow. * @param path */ public void setPath(MotionPath path) { this.path = path; }
Example #26
Source File: MotionTrack.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Creates a MotionPath for the given spatial on the given motion path * @param spatial * @param path */ public MotionTrack(Spatial spatial, MotionPath path, float initialDuration) { super(spatial, path, initialDuration); }
Example #27
Source File: MotionTrack.java From jmonkeyengine with BSD 3-Clause "New" or "Revised" License | 2 votes |
/** * Creates a MotionPath for the given spatial on the given motion path * @param spatial * @param path */ public MotionTrack(Spatial spatial, MotionPath path) { super(spatial, path); }
Example #28
Source File: MotionTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 2 votes |
/** * retun the motion path this control follows * @return */ public MotionPath getPath() { return path; }
Example #29
Source File: MotionTrack.java From MikuMikuStudio with BSD 2-Clause "Simplified" License | 2 votes |
/** * Sets the motion path to follow * @param path */ public void setPath(MotionPath path) { this.path = path; }