use of com.jme3.input.MouseInput in project jmonkeyengine by jMonkeyEngine.
the class JoglAbstractDisplay method getMouseInput.
@Override
public MouseInput getMouseInput() {
if (mouseInput == null) {
mouseInput = new AwtMouseInput();
((AwtMouseInput) mouseInput).setInputSource(canvas);
}
return mouseInput;
}
use of com.jme3.input.MouseInput in project jmonkeyengine by jMonkeyEngine.
the class VRMouseManager method update.
/**
* Update the mouse manager. This method should not be called manually.
* The standard behavior for this method is to be called from the {@link VRViewManager#update(float) update method} of the attached {@link VRViewManager VR view manager}.
* @param tpf the time per frame.
*/
protected void update(float tpf) {
if (environment.getApplication().getInputManager().isCursorVisible()) {
if (mouseImage.getParent() == null) {
environment.getApplication().getGuiViewPort().attachScene(mouseImage);
centerMouse();
// the "real" mouse pointer should stay hidden
if (environment.getApplication().getContext() instanceof LwjglWindow) {
GLFW.glfwSetInputMode(((LwjglWindow) environment.getApplication().getContext()).getWindowHandle(), GLFW.GLFW_CURSOR, GLFW.GLFW_CURSOR_DISABLED);
}
}
// handle mouse movements, which may be in addition to (or exclusive from) tracked movement
MouseInput mi = environment.getApplication().getContext().getMouseInput();
if (mi instanceof GlfwMouseInputVR) {
if (recentCenterCount <= 0) {
//Vector2f winratio = VRGuiManager.getCanvasToWindowRatio();
// * winratio.x;
cursorPos.x += ((GlfwMouseInputVR) mi).getLastDeltaX();
// * winratio.y;
cursorPos.y += ((GlfwMouseInputVR) mi).getLastDeltaY();
if (cursorPos.x < 0f)
cursorPos.x = 0f;
if (cursorPos.y < 0f)
cursorPos.y = 0f;
if (cursorPos.x > environment.getVRGUIManager().getCanvasSize().x)
cursorPos.x = environment.getVRGUIManager().getCanvasSize().x;
if (cursorPos.y > environment.getVRGUIManager().getCanvasSize().y)
cursorPos.y = environment.getVRGUIManager().getCanvasSize().y;
} else
recentCenterCount--;
((GlfwMouseInputVR) mi).clearDeltas();
}
// ok, update the cursor graphic position
Vector2f currentPos = getCursorPosition();
mouseImage.setLocalTranslation(currentPos.x, currentPos.y - ySize, environment.getVRGUIManager().getGuiDistance() + 1f);
mouseImage.updateGeometricState();
} else if (mouseImage.getParent() != null) {
Node n = mouseImage.getParent();
mouseImage.removeFromParent();
if (n != null) {
n.updateGeometricState();
}
}
}
use of com.jme3.input.MouseInput in project jmonkeyengine by jMonkeyEngine.
the class VRApplication method initInput.
/**
* 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);
}
use of com.jme3.input.MouseInput in project jmonkeyengine by jMonkeyEngine.
the class LwjglContextVR method initContextFirstTime.
protected void initContextFirstTime() {
final GLCapabilities capabilities = createCapabilities(settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3));
if (!capabilities.OpenGL20) {
throw new RendererException("OpenGL 2.0 or higher is required for jMonkeyEngine");
}
if (settings.getRenderer().equals(AppSettings.LWJGL_OPENGL2) || settings.getRenderer().equals(AppSettings.LWJGL_OPENGL3)) {
GL gl = new LwjglGL();
GLExt glext = new LwjglGLExt();
GLFbo glfbo;
if (capabilities.OpenGL30) {
glfbo = new LwjglGLFboGL3();
} else {
glfbo = new LwjglGLFboEXT();
}
if (settings.getBoolean("GraphicsDebug")) {
gl = new GLDebugDesktop(gl, glext, glfbo);
glext = (GLExt) gl;
glfbo = (GLFbo) gl;
}
if (settings.getBoolean("GraphicsTiming")) {
GLTimingState timingState = new GLTimingState();
gl = (GL) GLTiming.createGLTiming(gl, timingState, GL.class, GL2.class, GL3.class, GL4.class);
glext = (GLExt) GLTiming.createGLTiming(glext, timingState, GLExt.class);
glfbo = (GLFbo) GLTiming.createGLTiming(glfbo, timingState, GLFbo.class);
}
if (settings.getBoolean("GraphicsTrace")) {
gl = (GL) GLTracer.createDesktopGlTracer(gl, GL.class, GL2.class, GL3.class, GL4.class);
glext = (GLExt) GLTracer.createDesktopGlTracer(glext, GLExt.class);
glfbo = (GLFbo) GLTracer.createDesktopGlTracer(glfbo, GLFbo.class);
}
renderer = new GLRenderer(gl, glext, glfbo);
renderer.initialize();
} else {
throw new UnsupportedOperationException("Unsupported renderer: " + settings.getRenderer());
}
if (capabilities.GL_ARB_debug_output && settings.getBoolean("GraphicsDebug")) {
ARBDebugOutput.glDebugMessageCallbackARB(new LwjglGLDebugOutputHandler(), 0);
}
renderer.setMainFrameBufferSrgb(settings.isGammaCorrection());
renderer.setLinearizeSrgbImages(settings.isGammaCorrection());
// Init input
if (keyInput != null) {
keyInput.initialize();
}
if (mouseInput != null) {
mouseInput.initialize();
}
if (joyInput != null) {
joyInput.initialize();
}
renderable.set(true);
}
Aggregations