use of com.jme3.input.InputManager in project jmonkeyengine by jMonkeyEngine.
the class TestAppStates method initialize.
@Override
public void initialize() {
super.initialize();
System.out.println("Initialize");
RootNodeState state = new RootNodeState();
viewPort.attachScene(state.getRootNode());
stateManager.attach(state);
Spatial model = assetManager.loadModel("Models/Teapot/Teapot.obj");
model.scale(3);
model.setMaterial(assetManager.loadMaterial("Interface/Logo/Logo.j3m"));
state.getRootNode().attachChild(model);
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
niftyDisplay.getNifty().fromXml("Interface/Nifty/HelloJme.xml", "start");
guiViewPort.addProcessor(niftyDisplay);
}
use of com.jme3.input.InputManager 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.input.InputManager in project jmonkeyengine by jMonkeyEngine.
the class TestHoveringTank method buildPlayer.
private void buildPlayer() {
spaceCraft = assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
CollisionShape colShape = CollisionShapeFactory.createDynamicMeshShape(spaceCraft);
spaceCraft.setShadowMode(ShadowMode.CastAndReceive);
spaceCraft.setLocalTranslation(new Vector3f(-140, 50, -23));
spaceCraft.setLocalRotation(new Quaternion(new float[] { 0, 0.01f, 0 }));
hoverControl = new PhysicsHoverControl(colShape, 500);
spaceCraft.addControl(hoverControl);
rootNode.attachChild(spaceCraft);
getPhysicsSpace().add(hoverControl);
hoverControl.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02);
ChaseCamera chaseCam = new ChaseCamera(cam, inputManager);
spaceCraft.addControl(chaseCam);
flyCam.setEnabled(false);
}
use of com.jme3.input.InputManager in project jmonkeyengine by jMonkeyEngine.
the class BasicProfilerState method initialize.
@Override
protected void initialize(Application app) {
graph = new Geometry("profiler", profiler.getMesh());
Material mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setBoolean("VertexColor", true);
graph.setMaterial(mat);
graph.setLocalTranslation(0, 300, 0);
graph.setLocalScale(1, scale, 1);
Mesh mesh = new Mesh();
background = new Geometry("profiler.background", mesh);
mat = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
mat.setBoolean("VertexColor", true);
mat.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
background.setMaterial(mat);
background.setLocalTranslation(0, 300, -1);
background.setLocalScale(1, scale, 1);
refreshBackground();
InputManager inputManager = app.getInputManager();
if (inputManager != null) {
inputManager.addMapping(INPUT_MAPPING_PROFILER_TOGGLE, new KeyTrigger(KeyInput.KEY_F6));
inputManager.addListener(keyListener, INPUT_MAPPING_PROFILER_TOGGLE);
}
}
use of com.jme3.input.InputManager in project jmonkeyengine by jMonkeyEngine.
the class BasicProfilerState method cleanup.
@Override
protected void cleanup(Application app) {
InputManager inputManager = app.getInputManager();
if (inputManager.hasMapping(INPUT_MAPPING_PROFILER_TOGGLE)) {
inputManager.deleteMapping(INPUT_MAPPING_PROFILER_TOGGLE);
}
inputManager.removeListener(keyListener);
}
Aggregations