use of com.jme3.input.controls.MouseAxisTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestWriteToTexture method simpleInitApp.
@Override
public void simpleInitApp() {
initOpenCL1();
tex = new Texture2D(settings.getWidth(), settings.getHeight(), 1, com.jme3.texture.Image.Format.RGBA8);
Picture pic = new Picture("julia");
pic.setTexture(assetManager, tex, true);
pic.setPosition(0, 0);
pic.setWidth(settings.getWidth());
pic.setHeight(settings.getHeight());
guiNode.attachChild(pic);
initCounter = 0;
flyCam.setEnabled(false);
inputManager.setCursorVisible(true);
inputManager.addMapping("right", new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping("left", new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping("up", new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping("down", new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping("drag", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addListener(this, "right", "left", "up", "down", "drag");
dragging = false;
}
use of com.jme3.input.controls.MouseAxisTrigger in project chordatlas by twak.
the class Tweed method simpleInitApp.
public void simpleInitApp() {
// TweedSettings.load( new File ( Tweed.DATA ) );
point = new PointLight();
point.setEnabled(true);
point.setColor(ColorRGBA.White.mult(4));
point.setRadius(50);
rootNode.addLight(point);
sun = new DirectionalLight();
// sun.setDirection(new Vector3f(-0.0f, -1f, -0f).normalizeLocal());
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
sun.setColor(new ColorRGBA(1f, 0.95f, 0.99f, 1f));
rootNode.addLight(sun);
// enable multiple lights
renderManager.setPreferredLightMode(LightMode.SinglePass);
renderManager.setSinglePassLightBatchSize(16);
ambient = new AmbientLight();
rootNode.addLight(ambient);
setAmbient(0);
setDisplayFps(false);
setDisplayStatView(false);
clearBackground();
buildBackground();
getFlyByCamera().setDragToRotate(true);
setTool(tools[0]);
debug = new Node("dbg");
rootNode.attachChild(debug);
// String folder = ; // data-source
// SpotLightShadowRenderer shadows = new SpotLightShadowRenderer(assetManager, 1024);
// shadows.setLight(sun);
// shadows.setShadowIntensity(0.3f);
// shadows.setEdgeFilteringMode(EdgeFilteringMode.PCF8);
// viewPort.addProcessor(shadows);
cam.setLocation(TweedSettings.settings.cameraLocation);
cam.setRotation(TweedSettings.settings.cameraOrientation);
setFov(0);
setCameraSpeed(0);
if (false) {
// TweedSettings.settings.SSAO ) {
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
SSAOFilter filter = new SSAOFilter(0.50997847f, 1.440001f, 1.39999998f, 0);
// fpp.addFilter( new ColorOverlayFilter( ColorRGBA.Magenta ));
fpp.addFilter(filter);
fpp.addFilter(new FXAAFilter());
viewPort.addProcessor(fpp);
}
TweedSettings.loadDefault();
inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping(MOUSE_MOVE, new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addListener(moveListener, MOUSE_MOVE);
inputManager.addMapping(CLICK, new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addListener(analogListener, CLICK);
inputManager.addMapping(SPEED_UP, new KeyTrigger(KeyInput.KEY_UP));
inputManager.addMapping(SPEED_DOWN, new KeyTrigger(KeyInput.KEY_DOWN));
inputManager.addMapping(AMBIENT_UP, new KeyTrigger(KeyInput.KEY_RIGHT));
inputManager.addMapping(AMBIENT_DOWN, new KeyTrigger(KeyInput.KEY_LEFT));
inputManager.addMapping(FOV_UP, new KeyTrigger(KeyInput.KEY_PGUP));
inputManager.addMapping(FOV_DOWN, new KeyTrigger(KeyInput.KEY_PGDN));
inputManager.addMapping(TOGGLE_ORTHO, new KeyTrigger(KeyInput.KEY_O));
inputManager.addListener(new com.jme3.input.controls.ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (name == SPEED_UP)
setCameraSpeed(+1);
else
setCameraSpeed(-1);
}
}, SPEED_UP, SPEED_DOWN);
inputManager.addListener(new com.jme3.input.controls.ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (!isPressed)
return;
if (name == AMBIENT_UP)
setAmbient(+1);
else
setAmbient(-1);
}
}, AMBIENT_UP, AMBIENT_DOWN);
inputManager.addListener(new com.jme3.input.controls.ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (!isPressed)
return;
if (name == FOV_UP)
setFov(+1);
else
setFov(-1);
}
}, FOV_UP, FOV_DOWN);
inputManager.addListener(new com.jme3.input.controls.ActionListener() {
@Override
public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed) {
TweedSettings.settings.ortho = !TweedSettings.settings.ortho;
setCameraPerspective();
}
}
}, TOGGLE_ORTHO);
}
use of com.jme3.input.controls.MouseAxisTrigger in project TeachingInSimulation by ScOrPiOzzy.
the class CircuitState method bindCircuitBoardEvents.
private void bindCircuitBoardEvents() {
// 给电路板添加监听
addMapping("CONNECT_ON_DESKTOP_AXIR_X+", new MouseAxisTrigger(MouseInput.AXIS_X, true));
addMapping("CONNECT_ON_DESKTOP_AXIR_X-", new MouseAxisTrigger(MouseInput.AXIS_X, false));
addMapping("CONNECT_ON_DESKTOP_AXIR_Y+", new MouseAxisTrigger(MouseInput.AXIS_Y, true));
addMapping("CONNECT_ON_DESKTOP_AXIR_Y-", new MouseAxisTrigger(MouseInput.AXIS_Y, false));
String[] hoverMapping = new String[] { "CONNECT_ON_DESKTOP_AXIR_X+", "CONNECT_ON_DESKTOP_AXIR_X-", "CONNECT_ON_DESKTOP_AXIR_Y+", "CONNECT_ON_DESKTOP_AXIR_Y-" };
addListener((AnalogListener) (name, value, tpf) -> {
if (state == null) {
return;
}
// 先判断鼠标是否在元器件上
collision = JmeUtil.getCollisionFromCursor(rootCompNode, cam, inputManager);
// 如果没有宣导元器件
if (collision == null) {
// 再尝试和桌面碰撞
collision = JmeUtil.getCollisionFromCursor(desktop, cam, inputManager);
}
if (collision == null) {
return;
}
Vector3f point = collision.getContactPoint();
// 离电路板略高一些。
point.addLocal(0, minHeight, 0);
if (state == State.Starting) {
// 开头
Vector3f project = point.subtract(startLine1.getStart()).project(dir);
if (project.dot(dir) < minLen) {
return;
}
Vector3f line1EndPoint = startLine1.getStart().add(project);
startLine1.updatePoints(startLine1.getStart(), line1EndPoint);
Vector3f line2EndPoint = line1EndPoint.add(point.subtract(line1EndPoint).project(Vector3f.UNIT_Y));
startLine2.updatePoints(line1EndPoint, line2EndPoint);
// Vector3f line3EndPoint = point;
startLine3.updatePoints(line2EndPoint, point);
} else if (state == State.Mid) {
// 计算midLine1.getStart() 与 鼠标point 向量在X与Z轴的投影。
Vector3f tmpPoint = null;
tmpPoint = midLine1.getStart().add(point.subtract(midLine1.getStart()).project(midAxis));
midLine1.updatePoints(midLine1.getStart(), tmpPoint);
midLine2.updatePoints(tmpPoint, point);
} else if (state == State.Ending) {
// endLine1.updatePoints(endLine1.getStart(), point);
}
}, hoverMapping);
addMapping("CLICKED_ON_BOARD", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
addMapping("CANCEL_ON_CONNECTING", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
addListener((ActionListener) (name, isPressed, tpf) -> {
if (collision == null) {
return;
}
if (desktop != collision.getGeometry()) {
return;
}
if ("CANCEL_ON_CONNECTING".equals(name) && isPressed) {
if (state == State.Starting || state == State.Mid) {
connectClean();
}
}
if ("CLICKED_ON_BOARD".equals(name) && isPressed) {
if (state == null) {
return;
}
if (state == State.Starting) {
connectStarting();
// 设置当前接线状态为接线中
state = State.Mid;
} else if (state == State.Mid) {
connectMid();
} else if (state == State.Ending) {
// do nothing
}
}
}, "CLICKED_ON_BOARD", "CANCEL_ON_CONNECTING");
}
use of com.jme3.input.controls.MouseAxisTrigger in project TeachingInSimulation by ScOrPiOzzy.
the class SceneCameraState method initializeLocal.
@Override
public void initializeLocal() {
// 初始化相机
cam.setLocation(new Vector3f(0, 10, 10));
cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);
// 添加鼠标监听事件
inputManager.addMapping("MouseAxisX", new MouseAxisTrigger(MouseInput.AXIS_X, false));
inputManager.addMapping("MouseAxisY", new MouseAxisTrigger(MouseInput.AXIS_Y, false));
inputManager.addMapping("MouseAxisX-", new MouseAxisTrigger(MouseInput.AXIS_X, true));
inputManager.addMapping("MouseAxisY-", new MouseAxisTrigger(MouseInput.AXIS_Y, true));
inputManager.addMapping("MouseWheel", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, false));
inputManager.addMapping("MouseWheel-", new MouseAxisTrigger(MouseInput.AXIS_WHEEL, true));
inputManager.addMapping("MouseButtonLeft", new MouseButtonTrigger(MouseInput.BUTTON_LEFT));
inputManager.addMapping("MouseButtonMiddle", new MouseButtonTrigger(MouseInput.BUTTON_MIDDLE));
inputManager.addMapping("MouseButtonRight", new MouseButtonTrigger(MouseInput.BUTTON_RIGHT));
inputManager.addMapping("ShiftModifier", new KeyTrigger(KeyInput.KEY_LSHIFT));
// 注册监听
inputManager.addListener(this, "MouseAxisX", "MouseAxisY", "MouseAxisX-", "MouseAxisY-", "MouseWheel", "MouseWheel-", "MouseButtonLeft", "MouseButtonMiddle", "MouseButtonRight", "ShiftModifier");
// 设置相机视锥
float aspect = (float) cam.getWidth() / cam.getHeight();
cam.setParallelProjection(false);
cam.setFrustumPerspective(45f, aspect, 0.01f, 1000);
camera = new WASDListener(cam);
camera.registerWithInput(inputManager);
}
Aggregations