本文整理汇总了Java中com.jme3.cinematic.MotionPath.addListener方法的典型用法代码示例。如果您正苦于以下问题:Java MotionPath.addListener方法的具体用法?Java MotionPath.addListener怎么用?Java MotionPath.addListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jme3.cinematic.MotionPath
的用法示例。
在下文中一共展示了MotionPath.addListener方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: addPathListener
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
private MotionPath addPathListener(final EntityId id, MotionPath path) {
path.addListener(new MotionPathListener() {
@Override
public void onWayPointReach(MotionEvent control, int wayPointIndex) {
if (control.getPath().getNbWayPoints() == wayPointIndex + 1) {
// System.err.println(control.getSpatial().getName() + " has finished moving. ");
entityData.removeComponent(id, MoveToComponent.class);
} else {
// System.err.println(control.getSpatial().getName() + " has reached way point " + wayPointIndex);
}
updatePosition(id, control);
if (movementUpdateGoal.containsKey(id)) {
// System.err.println("Start a new movement path.");
buildNewPath(id, control, this);
} else if (control.getPath().getNbWayPoints() == wayPointIndex + 1) {
// System.err.println("All movement has been done.");
entityData.removeComponent(id, MoveToComponent.class);
}
}
});
return path;
}
开发者ID:MultiverseKing,项目名称:MultiverseKing_JME,代码行数:23,代码来源:HexMovementSystem.java示例2: getContainerFromTruck
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
public void getContainerFromTruck(int agvId, int craneId) {
List<Vector3f> list = new ArrayList<Vector3f>();
list.add(new Vector3f());
list.add(new Vector3f(1, 0, 0));
ConnectionManager.sendCommand(new TruckCraneData(agvId, craneId, craneId, false));
MotionPath path = new MotionPath();
for (Vector3f v : list)
path.addWayPoint(v);
path.setCurveTension(0.0f);
path.addListener(new CMotionPathListener());
AGV agv = AGVHandler.getInstance().getAGV(agvId);
agv.setContainer(this.locations.get(craneId).c);
AGVHandler.getInstance().setAGV(agv.agvId, agv);
ServerSpatial spatial = new ServerSpatial(AGVHandler.getInstance().getAGV(agvId), "truckLocation_" + String.valueOf(craneId) + "_loaded");
ContainingServer.getRoot().attachChild(spatial);
MotionEvent motionControl = new MotionEvent(spatial, path);
motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
motionControl.setRotation(new Quaternion().fromAngleNormalAxis(0, Vector3f.UNIT_Y));
motionControl.setInitialDuration(30f);
motionControl.setSpeed(ContainingServer.getSpeed());
motionControl.play();
}
开发者ID:megagorilla,项目名称:Containing,代码行数:24,代码来源:TruckPlatformHandler.java示例3: getContainerFromAGV
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
public void getContainerFromAGV(int agvId, int craneId) {
List<Vector3f> list = new ArrayList<Vector3f>();
list.add(new Vector3f());
list.add(new Vector3f(1, 0, 0));
ConnectionManager.sendCommand(new TruckCraneData(agvId, craneId, craneId, true));
MotionPath path = new MotionPath();
for (Vector3f v : list)
path.addWayPoint(v);
path.setCurveTension(0.0f);
path.addListener(new CMotionPathListener());
ServerSpatial spatial = new ServerSpatial(AGVHandler.getInstance().getAGV(agvId), "truckLocation_" + String.valueOf(craneId) + "_loaded");
ContainingServer.getRoot().attachChild(spatial);
MotionEvent motionControl = new MotionEvent(spatial, path);
motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
motionControl.setRotation(new Quaternion().fromAngleNormalAxis(0, Vector3f.UNIT_Y));
motionControl.setInitialDuration(30f);
motionControl.setSpeed(1f);
motionControl.play();
}
开发者ID:megagorilla,项目名称:Containing,代码行数:22,代码来源:TruckPlatformHandler.java示例4: buildNewPath
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
/**
* @return true if a new path have been build.
*/
private boolean buildNewPath(EntityId id, MotionEvent motionControl, MotionPathListener listeners) {
boolean result = false;
/**
* We build a new path starting from the current waypoint.
*/
List<HexCoordinate> newPath = getPathfinderPath(
new HexCoordinate(motionControl.getPath().getWayPoint(motionControl.getCurrentWayPoint() + 1)),
movementUpdateGoal.get(id));
if (newPath != null) {
motionControl.stop();
motionControl.getPath().disableDebugShape();
MotionPath newMotion = buildPath(motionControl.getSpatial().getLocalTranslation(), newPath);
motionControl.setPath(newMotion);
float ms = new EntityLoader(app).loadTitanStats(
entityData.getComponent(id, RenderComponent.class).getName())
.getInitialStatsComponent().getMoveSpeed();
float addedDist = motionControl.getSpatial().getLocalTranslation().distance(
newPath.get(0).toWorldPosition(mapData.getTile(newPath.get(0)).getHeight()));
float baseDist = newPath.get(0).toWorldPosition(mapData.getTile(newPath.get(0)).getHeight())
.distance(newPath.get(1).toWorldPosition(mapData.getTile(newPath.get(1)).getHeight()));
motionControl.setInitialDuration(ms * (newPath.size() + 1));// + (ms / baseDist * addedDist));
if (listeners != null) {
newMotion.addListener(listeners);
} else {
addPathListener(id, newMotion);
}
movementGoal.put(id, movementUpdateGoal.get(id));
motionControl.play();
result = true;
} else if (movementGoal.containsKey(id)) {
entityData.setComponent(id, new MoveToComponent(movementGoal.get(id)));
}
movementUpdateGoal.remove(id);
return result;
}
开发者ID:MultiverseKing,项目名称:MultiverseKing_JME,代码行数:39,代码来源:HexMovementSystem.java示例5: motionPath
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
private void motionPath() {
firstTime = false;
final MotionPath path = new MotionPath();
final Vector3f location = spatial.getLocalTranslation();
path.addWayPoint(location);
path.addWayPoint(location.add(0, 40f, 0));
path.addWayPoint(location);
path.setCurveTension(0.75f);
MotionEvent motionControl = new MotionEvent(spatial, path);
motionControl.setInitialDuration(0.75f);
motionControl.setSpeed(1f);
MotionPathListener pathListener = (MotionEvent cM, int wpIndex) -> {
if (wpIndex == path.getNbWayPoints() - 1) {
spatial.getControl(CCharacterPhysics.class)
.switchToNormalPhysicsMode();
shouldContinue = false;
}
};
path.addListener(pathListener);
motionControl.play();
spatial.getControl(CCharacterPhysics.class)
.switchToMotionCollisionMode();
}
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:30,代码来源:EarthQuake.java示例6: motion
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
private void motion(final Vector3f target) {
final Node worldRoot = spatial.getParent();
final Node fakeRoot
= (Node) worldRoot.getParent().getChild("fake-world-root");
Vector3f start = spatial.getLocalTranslation();
final MotionPath path = new MotionPath();
path.setPathSplineType(Spline.SplineType.Linear);
path.addWayPoint(start);
path.addWayPoint(target);
MotionEvent motionControl = new MotionEvent(spatial, path);
motionControl.setSpeed(1f);
motionControl.setInitialDuration(
target.distance(start) / EtherealFlame.SPEED);
final CCharacterPhysics body
= spatial.getControl(CCharacterPhysics.class);
body.lookAt(target);
body.switchToMotionCollisionMode();
spatial.removeFromParent();
fakeRoot.attachChild(spatial);
path.addListener((MotionEvent m, int wayPointIndex) -> {
if (path.getNbWayPoints() == wayPointIndex + 1) {
spatial.removeFromParent();
worldRoot.attachChild(spatial);
body.switchToNormalPhysicsMode();
body.warp(target);
timeLeft = 0f;
}
});
motionControl.play();
}
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:38,代码来源:EtherealFlame.java示例7: motionPath
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
private void motionPath() {
final CCharacterPhysics physics =
spatial.getControl(CCharacterPhysics.class);
physics.switchToMotionCollisionMode();
final MotionPath path = new MotionPath();
// We set y to 1 to prevent ground collision on start
final Vector3f startLocation =
spatial.getLocalTranslation().add(0, 1f, 0);
World world = Globals.app.getStateManager().getState(World.class);
Spatial walls = world.getWorldRoot().getChild("Walls");
final Vector3f finalLocation = PathCheck.closestNonColliding(walls,
startLocation, spatial.getControl(CSpellCast.class)
.getClosestPointToTarget(spell),
physics.getCapsuleShape().getRadius()) ;
path.addWayPoint(startLocation);
path.addWayPoint(spatial.getLocalTranslation().add(finalLocation)
.divideLocal(2)
.setY(finalLocation.distance(startLocation) / 1.8f));
path.addWayPoint(finalLocation);
MotionEvent motionControl = new MotionEvent(spatial, path);
motionControl.setInitialDuration(finalLocation.distance(startLocation)
/ ACastRocketJump.forwardSpeed);
motionControl.setSpeed(1f);
physics.setViewDirection(finalLocation.subtract(startLocation));
path.addListener((MotionEvent m, int wayPointIndex) -> {
if (wayPointIndex == path.getNbWayPoints() - 1) {
physics.switchToNormalPhysicsMode();
}
});
motionControl.play();
}
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:39,代码来源:RocketJump.java示例8: simpleInitApp
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
@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(0).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();
}
开发者ID:mleoking,项目名称:PhET,代码行数:52,代码来源:TestCameraMotionPath.java示例9: simpleInitApp
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
@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();
}
开发者ID:mleoking,项目名称:PhET,代码行数:48,代码来源:TestMotionPath.java示例10: sendAGV
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
/**
* Sends the agv to a certain location on the graph and creates a motionpath
* for the server to keep track of that object.
*
* @param id
* @param list
* @param destination
*/
public void sendAGV(int id, List<Vector3f> list, String destination) {
AGV agv = AGVHandler.getInstance().getAGV(id);
UpdateMessage message = new UpdateMessage(Integer.toString(id));
float tempdist = 0f;
float duration = 0f;
for (int i = 0; i < list.size(); i++) {
if (list.get(i).x != list.get(i + 1).x && list.get(i).z == list.get(i + 1).z) {
tempdist += Math.abs(list.get(i).x - list.get(i + 1).x);
}
else if (list.get(i).z != list.get(i + 1).z && list.get(i).x == list.get(i + 1).x) {
tempdist += Math.abs(list.get(i).z - list.get(i + 1).z);
}
else if (list.get(i).x != list.get(i + 1).x && list.get(i).z != list.get(i + 1).z) {
tempdist += Math.abs(Math.sqrt(Math.pow(list.get(i).x - list.get(i + 1).x, 2) + Math.pow(list.get(i).z - list.get(i + 1).z, 2)));
}
if (i + 1 == list.size() - 1)
break;
}
duration = tempdist / (agv.getLoaded() ? 5.555f : 11.111f);// Loaded and Unloaded speed for the AGV
message.addData(id, list, duration, ContainingServer.getSpeed());
ConnectionManager.sendCommand(message);
MotionPath path = new MotionPath();
for (Vector3f v : list)
path.addWayPoint(v);
path.setCurveTension(0.0f);
path.addListener(new CMotionPathListener());
ServerSpatial spatial = new ServerSpatial(agv, destination);
ContainingServer.getRoot().attachChild(spatial);
MotionEvent motionControl = new MotionEvent(spatial, path);
motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
motionControl.setRotation(new Quaternion().fromAngleNormalAxis(0, Vector3f.UNIT_Y));
motionControl.setInitialDuration(duration);
motionControl.setSpeed(ContainingServer.getSpeed());
motionControl.play();
}
开发者ID:megagorilla,项目名称:Containing,代码行数:51,代码来源:ControlHandler.java示例11: motion
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
private void motion() {
Vector3f startLocation
= spatial.getLocalTranslation().add(0, 1f, 0);
int playerId = spatial.getUserData(UserData.PLAYER_ID);
final int firewalkId = world.addNewEntity(spell.getId(),
startLocation, Quaternion.IDENTITY, playerId);
Spatial firewalkNode = world.getEntity(firewalkId);
final PlayerEntityAwareness awareness
= spatial.getControl(CEntityVariable.class).getAwareness();
awareness.setOwnSpatial(firewalkNode);
CSpellBuff buffControl = firewalkNode.getControl(CSpellBuff.class);
buffControl.setOwnerInterface(spatial
.getControl(CInfluenceInterface.class));
buffControl.getBuffs().addAll(additionalBuffs);
final MotionPath path = new MotionPath();
path.setPathSplineType(Spline.SplineType.Linear);
float room = spatial.getControl(CCharacterPhysics.class)
.getCapsuleShape().getRadius();
CSpellCast castControl = spatial.getControl(CSpellCast.class);
Spatial walls = world.getWorldRoot().getChild("Walls");
final Vector3f finalLocation = PathCheck.closestNonColliding(walls,
startLocation,
castControl.getClosestPointToTarget(spell).add(0, 1f, 0),
room);
path.addWayPoint(startLocation);
path.addWayPoint(finalLocation);
MotionEvent motionControl = new MotionEvent(firewalkNode, path);
motionControl.setSpeed(1f);
motionControl.setInitialDuration(
finalLocation.distance(startLocation) / 105f);
final int id = spatial.getUserData(UserData.ENTITY_ID);
world.temporarilyRemoveEntity(id);
path.addListener((MotionEvent cMotion, int wayPointIndex) -> {
if (path.getNbWayPoints() == wayPointIndex + 1) {
world.restoreTemporarilyRemovedEntity(id, finalLocation,
spatial.getLocalRotation());
world.removeEntity(firewalkId, -1);
awareness.setOwnSpatial(spatial);
}
});
motionControl.play();
}
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:52,代码来源:Firewalk.java示例12: motionPathVersion
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
private void motionPathVersion() {
final CCharacterPhysics physics
= spatial.getControl(CCharacterPhysics.class);
physics.switchToMotionCollisionMode();
Spatial walls = Globals.app.getStateManager().getState(World.class)
.getWorldRoot().getChild("Walls");
// We set y to 1 to prevent ground collision on start
Vector3f startLocation = spatial.getLocalTranslation().add(0, 1f, 0);
Vector3f finalLocation = PathCheck.closestNonColliding(walls,
startLocation, spatial.getControl(CSpellCast.class)
.getClosestPointToTarget(spell),
physics.getCapsuleShape().getRadius());
final MotionPath path = new MotionPath();
path.addWayPoint(startLocation);
path.addWayPoint(spatial.getLocalTranslation().add(finalLocation)
.divideLocal(2).setY(
finalLocation.distance(startLocation) / 2f));
path.addWayPoint(finalLocation);
path.setPathSplineType(Spline.SplineType.CatmullRom);
path.setCurveTension(0.75f);
MotionEvent motionControl = new MotionEvent(spatial, path);
motionControl.setInitialDuration(
finalLocation.distance(startLocation) / forwardSpeed);
motionControl.setSpeed(1f);
direction = finalLocation.subtract(startLocation);
physics.setViewDirection(direction);
path.addListener((MotionEvent cMotion, int index) -> {
if (index == path.getNbWayPoints() - 2) {
} else if (index == path.getNbWayPoints() - 1) {
physics.switchToNormalPhysicsMode();
spatial.getControl(CActionQueue.class).enqueueAction(
new AChangeAnimation(Venator.ANIM_LAND));
landingEffect();
motionPending = false;
}
});
motionControl.play();
}
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:46,代码来源:Leap.java示例13: simpleInitApp
import com.jme3.cinematic.MotionPath; //导入方法依赖的package包/类
@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();
}
开发者ID:chototsu,项目名称:MikuMikuStudio,代码行数:52,代码来源:TestCameraMotionPath.java本文标签属性:
示例:示例志愿表
代码:代码转换器
java:java面试题
MotionPath:MotionPath
addListener:addListener