本文整理汇总了Java中com.jme3.input.InputManager类的典型用法代码示例。如果您正苦于以下问题:Java InputManager类的具体用法?Java InputManager怎么用?Java InputManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InputManager类属于com.jme3.input包,在下文中一共展示了InputManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import com.jme3.input.InputManager; //导入依赖的package包/类
@Override
@JMEThread
public void initialize(@NotNull final AppStateManager stateManager, @NotNull final Application application) {
super.initialize(stateManager, application);
this.stateManager = stateManager;
final Node rootNode = EDITOR.getRootNode();
rootNode.attachChild(getStateNode());
final TonegodTranslucentBucketFilter translucentBucketFilter = EDITOR.getTranslucentBucketFilter();
translucentBucketFilter.setEnabled(true);
final EditorCamera editorCamera = getEditorCamera();
final InputManager inputManager = EDITOR.getInputManager();
checkAndAddMappings(inputManager);
registerActionListener(inputManager);
registerAnalogListener(inputManager);
if (editorCamera != null) {
editorCamera.setEnabled(true);
editorCamera.registerInput(inputManager);
}
}
示例2: cleanup
import com.jme3.input.InputManager; //导入依赖的package包/类
@Override
@JMEThread
public void cleanup() {
super.cleanup();
final TonegodTranslucentBucketFilter translucentBucketFilter = EDITOR.getTranslucentBucketFilter();
translucentBucketFilter.setEnabled(false);
final Node rootNode = EDITOR.getRootNode();
rootNode.detachChild(getStateNode());
final EditorCamera editorCamera = getEditorCamera();
final InputManager inputManager = EDITOR.getInputManager();
inputManager.removeListener(actionListener);
inputManager.removeListener(analogListener);
if (editorCamera != null) {
editorCamera.setEnabled(false);
editorCamera.unregisterInput(inputManager);
}
}
示例3: initInput
import com.jme3.input.InputManager; //导入依赖的package包/类
/**
* Initializes mouse and keyboard input. Also
* initializes joystick input if joysticks are enabled in the
* AppSettings.
*/
private void initInput(){
mouseInput = context.getMouseInput();
if (mouseInput != null)
mouseInput.initialize();
keyInput = context.getKeyInput();
if (keyInput != null)
keyInput.initialize();
touchInput = context.getTouchInput();
if (touchInput != null)
touchInput.initialize();
if (!settings.getBoolean("DisableJoysticks")){
joyInput = context.getJoyInput();
if (joyInput != null)
joyInput.initialize();
}
inputManager = new InputManager(mouseInput, keyInput, joyInput, touchInput);
}
示例4: NiftyJmeDisplay
import com.jme3.input.InputManager; //导入依赖的package包/类
public NiftyJmeDisplay(AssetManager assetManager,
InputManager inputManager,
AudioRenderer audioRenderer,
ViewPort vp){
this.assetManager = assetManager;
w = vp.getCamera().getWidth();
h = vp.getCamera().getHeight();
resourceLocation = new ResourceLocationJme();
ResourceLoader.removeAllResourceLocations();
ResourceLoader.addResourceLocation(resourceLocation);
soundDev = new SoundDeviceJme(assetManager, audioRenderer);
renderDev = new RenderDeviceJme(this);
inputSys = new InputSystemJme(inputManager);
if (inputManager != null)
inputManager.addRawInputListener(inputSys);
nifty = new Nifty(renderDev, soundDev, inputSys, new TimeProvider());
inputSys.setNifty(nifty);
}
示例5: setActiveCursor
import com.jme3.input.InputManager; //导入依赖的package包/类
/**
* For internal use - Use setForcedCursor instead
*
* @param cur
*/
public void setActiveCursor(CursorType cur) {
if (!Objects.equals(cur, currentCursor)) {
InputManager inputManager = getApplication().getInputManager();
if (themeInstance != null && themeInstance.hasCursors()) {
if (!forceCursor) {
if (cur == null || cur.equals(CursorType.HIDDEN)) {
inputManager.setCursorVisible(false);
} else {
inputManager.setCursorVisible(true);
JmeCursor jmeCur = themeInstance.getCursor(cur);
if (jmeCur != null) {
inputManager.setMouseCursor(jmeCur);
}
}
}
}
currentCursor = cur;
}
}
示例6: initKeys
import com.jme3.input.InputManager; //导入依赖的package包/类
public void initKeys(InputManager inputManager) {
inputManager.addMapping(name + "LeftClick", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addMapping(name + "RightClick", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addMapping(name + "MouseMove",
new MouseAxisTrigger(MouseInput.AXIS_X, true),
new MouseAxisTrigger(MouseInput.AXIS_X, false),
new MouseAxisTrigger(MouseInput.AXIS_Y, true),
new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(name + "PlaneRotate", new KeyTrigger(KeyInput.KEY_SLASH));
inputManager.addMapping(name + "PlaneRotate90", new KeyTrigger(KeyInput.KEY_LCONTROL));
inputManager.addListener(this, "shiftKey");
inputManager.addListener(this, name + "LeftClick");
inputManager.addListener(this, name + "RightClick");
inputManager.addListener(this, name + "MouseMove");
inputManager.addListener(this, name + "PlaneRotate");
inputManager.addListener(this, name + "PlaneRotate90");
}
示例7: createSimpleChaseCamera
import com.jme3.input.InputManager; //导入依赖的package包/类
public static ChaseCamera createSimpleChaseCamera(Camera camera
, InputManager inputManager) {
ChaseCamera chaseCam = new ChaseCamera(camera, inputManager);
// 开启镜头跟随可能让部分人容易犯头晕
// chaseCam.setSmoothMotion(true);
// chaseCam.setTrailingEnabled(false);
chaseCam.setInvertVerticalAxis(true);
chaseCam.setLookAtOffset(Vector3f.UNIT_Y.mult(2f));
chaseCam.setZoomSensitivity(0.5f);
chaseCam.setRotationSpeed(5f);
chaseCam.setRotationSensitivity(5);
chaseCam.setMaxDistance(15);
chaseCam.setMinDistance(2f);
chaseCam.setDefaultDistance(15);
chaseCam.setChasingSensitivity(5);
chaseCam.setDownRotateOnCloseViewOnly(true);
chaseCam.setUpVector(Vector3f.UNIT_Y);
// 不要隐藏光标,否则在MAC系统下鼠标点击后会上下错位
chaseCam.setHideCursorOnRotate(false);
return chaseCam;
}
示例8: registerWithInput
import com.jme3.input.InputManager; //导入依赖的package包/类
/**
* Registers inputs with the input manager
* @param inputManager
*/
public final void registerWithInput(InputManager inputManager) {
String[] inputs = {EDIT_CAMERA_TOGGLEROTATE,
EDIT_CAMERA_DOWN,
EDIT_CAMERA_UP,
EDIT_CAMERA_MOVELEFT,
EDIT_CAMERA_MOVERIGHT,
EDIT_CAMERA_ZOOMIN,
EDIT_CAMERA_ZOOMOUT};
this.inputManager = inputManager;
inputManager.addMapping(EDIT_CAMERA_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping(EDIT_CAMERA_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(EDIT_CAMERA_ZOOMIN, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
inputManager.addMapping(EDIT_CAMERA_ZOOMOUT, new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
inputManager.addMapping(EDIT_CAMERA_MOVELEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(EDIT_CAMERA_MOVERIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(EDIT_CAMERA_TOGGLEROTATE, new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE));
inputManager.addListener(this, inputs);
}
示例9: initControls
import com.jme3.input.InputManager; //导入依赖的package包/类
public void initControls(InputManager inputManager) {
inputManager.deleteMapping(SimpleApplication.INPUT_MAPPING_EXIT);
inputManager.addMapping("open_menu", new KeyTrigger(KeyInput.KEY_ESCAPE));
inputManager.addMapping("view_atom", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(new ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if ("open_menu".equals(name) && isPressed) {
NiftyAppState s = stateManager.getState(NiftyAppState.class);
if ("menu".equals(s.nifty.getCurrentScreen().getScreenId())) {
s.exitMenu();
} else {
s.openMenu();
}
} else if ("view_atom".equals(name) && isPressed) {
triggerViewAtom();
}
}
}, "open_menu", "view_atom");
}
示例10: registerWithInput
import com.jme3.input.InputManager; //导入依赖的package包/类
public void registerWithInput(InputManager inputManager) {
this.inputManager = inputManager;
String[] mappings = new String[] { "+SIDE", "+FWD", "+ROTATE", "+TILT", "+DISTANCE",
"-SIDE", "-FWD", "-ROTATE", "-TILT", "-DISTANCE", };
inputManager.addMapping("-SIDE", new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping("+SIDE", new KeyTrigger(KeyInput.KEY_D));
inputManager.addMapping("+FWD", new KeyTrigger(KeyInput.KEY_S));
inputManager.addMapping("-FWD", new KeyTrigger(KeyInput.KEY_W));
inputManager.addMapping("+ROTATE", new KeyTrigger(KeyInput.KEY_Q));
inputManager.addMapping("-ROTATE", new KeyTrigger(KeyInput.KEY_E));
inputManager.addMapping("+TILT", new KeyTrigger(KeyInput.KEY_R));
inputManager.addMapping("-TILT", new KeyTrigger(KeyInput.KEY_F));
inputManager.addMapping("-DISTANCE", new KeyTrigger(KeyInput.KEY_Z));
inputManager.addMapping("+DISTANCE", new KeyTrigger(KeyInput.KEY_X));
inputManager.addListener(this, mappings);
inputManager.setCursorVisible(true);
}
示例11: setupKeys
import com.jme3.input.InputManager; //导入依赖的package包/类
private void setupKeys(InputManager inputManager){
//Set up keys and listener to read it
String[] mappings = new String[]{
"MoveShip",
"FireBullets",
"FireRocket",
"LockMouse",
"SelectAim"
};
InputManager input = asm.getInputManager();
input.addMapping("LockMouse", new KeyTrigger(KeyInput.KEY_SPACE));
input.addMapping("SelectAim", new KeyTrigger(KeyInput.KEY_E));
input.addMapping("MoveShip", new KeyTrigger(KeyInput.KEY_W));
input.addMapping("FireBullets", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
input.addListener(anl, mappings);
input.addListener(acl, mappings);
}
示例12: setupKeys
import com.jme3.input.InputManager; //导入依赖的package包/类
private void setupKeys() {
InputManager inputManager = app.getInputManager();
inputManager.addMapping("Rotate Left",
new KeyTrigger(KeyInput.KEY_A),
new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping("Rotate Right",
new KeyTrigger(KeyInput.KEY_D),
new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping("Walk Forward",
new KeyTrigger(KeyInput.KEY_W),
new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping("Walk Backward",
new KeyTrigger(KeyInput.KEY_S),
new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addMapping("Jump",
new KeyTrigger(KeyInput.KEY_SPACE));
// inputManager.addListener(this, "Strafe Left", "Strafe Right");
inputManager.addListener(this, "Rotate Left", "Rotate Right");
inputManager.addListener(this, "Walk Forward", "Walk Backward");
inputManager.addListener(this, "Jump");
inputManager = null;
}
示例13: initialize
import com.jme3.input.InputManager; //导入依赖的package包/类
/**
* Initializes the tool.
*
* @param manager the AssetManager to load objects and materials from.
* @param inputManager can be used to register keypresses that can be used
* with this tool.
*/
public void initialize(AssetManager manager, InputManager inputManager) {
ObjectType objectType = GlobalObjects.getInstance().getObjectsTypeCategory().getObjectType("Terrain", "Brush");
defaultBrush = (TerrainBrush)objectType.create(manager, "defaultbrush");
defaultBrush.setLayerName("terrain");
brushShape = new Cylinder(2, 12, defaultBrush.getRadius(), 1.0f);
brushGizmo = new Geometry("terrainBrush", brushShape);
Quaternion q = new Quaternion();
q.fromAngles(FastMath.HALF_PI, 0, 0);
brushGizmo.setLocalRotation(q);
brushGizmo.setMaterial(manager.loadMaterial("Materials/BrushGizmoMaterial.j3m"));
inputManager.addListener(shiftListener, new String[]{"DOBRUSH"});
GlobalObjects.getInstance().registerListener(this);
}
示例14: registerInputs
import com.jme3.input.InputManager; //导入依赖的package包/类
@Override
public void registerInputs(InputManager inputManager){
inputManager.addMapping(ROTATE_UP, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(ROTATE_DOWN, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping(ROTATE_LEFT, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(ROTATE_RIGHT, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(STRAFE_LEFT, new KeyTrigger(KeyInput.KEY_Q),
new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping(STRAFE_RIGHT, new KeyTrigger(KeyInput.KEY_D),
new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping(MOVE_FOREWARD, new KeyTrigger(KeyInput.KEY_Z),
new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping(MOVE_BACKWARD, new KeyTrigger(KeyInput.KEY_S),
new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addListener(this, mappings);
}
示例15: registerInputs
import com.jme3.input.InputManager; //导入依赖的package包/类
@Override
protected void registerInputs(InputManager inputManager) {
inputManager.addMapping(SWITCH_CTRL_1, new KeyTrigger(KeyInput.KEY_F1));
inputManager.addMapping(SWITCH_CTRL_2, new KeyTrigger(KeyInput.KEY_F2));
inputManager.addMapping(SWITCH_CTRL_3, new KeyTrigger(KeyInput.KEY_F3));
inputManager.addMapping(SELECT, new MouseButtonTrigger(0));
inputManager.addMapping(ACTION, new MouseButtonTrigger(1));
inputManager.addMapping(MOVE_ATTACK, new KeyTrigger(KeyInput.KEY_A));
inputManager.addMapping(MULTIPLE_SELECTION, new KeyTrigger(KeyInput.KEY_LCONTROL),
new KeyTrigger(KeyInput.KEY_RCONTROL));
inputManager.addMapping(HOLD, new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping(PAUSE, new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addListener(this, mappings);
logger.info("battlefield controller online");
}