Search in sources :

Example 6 with MouseInput

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;
}
Also used : AwtMouseInput(com.jme3.input.awt.AwtMouseInput)

Example 7 with 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();
        }
    }
}
Also used : GlfwMouseInputVR(com.jme3.input.lwjgl.GlfwMouseInputVR) Vector2f(com.jme3.math.Vector2f) Node(com.jme3.scene.Node) LwjglWindow(com.jme3.system.lwjgl.LwjglWindow) MouseInput(com.jme3.input.MouseInput)

Example 8 with MouseInput

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);
}
Also used : InputManager(com.jme3.input.InputManager)

Example 9 with MouseInput

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);
}
Also used : LwjglGL(com.jme3.renderer.lwjgl.LwjglGL) LwjglGLExt(com.jme3.renderer.lwjgl.LwjglGLExt) LwjglGLFboGL3(com.jme3.renderer.lwjgl.LwjglGLFboGL3) LwjglGLExt(com.jme3.renderer.lwjgl.LwjglGLExt) GLCapabilities(org.lwjgl.opengl.GLCapabilities) RendererException(com.jme3.renderer.RendererException) LwjglGLFboEXT(com.jme3.renderer.lwjgl.LwjglGLFboEXT) LwjglGL(com.jme3.renderer.lwjgl.LwjglGL)

Aggregations

MouseInput (com.jme3.input.MouseInput)3 GlfwMouseInputVR (com.jme3.input.lwjgl.GlfwMouseInputVR)3 RendererException (com.jme3.renderer.RendererException)3 Vector2f (com.jme3.math.Vector2f)2 LwjglGL (com.jme3.renderer.lwjgl.LwjglGL)2 LwjglGLExt (com.jme3.renderer.lwjgl.LwjglGLExt)2 LwjglGLFboEXT (com.jme3.renderer.lwjgl.LwjglGLFboEXT)2 LwjglGLFboGL3 (com.jme3.renderer.lwjgl.LwjglGLFboGL3)2 GLDebugDesktop (com.jme3.renderer.opengl.GLDebugDesktop)2 GLExt (com.jme3.renderer.opengl.GLExt)2 GLFbo (com.jme3.renderer.opengl.GLFbo)2 GLRenderer (com.jme3.renderer.opengl.GLRenderer)2 GLTimingState (com.jme3.renderer.opengl.GLTimingState)2 GLCapabilities (org.lwjgl.opengl.GLCapabilities)2 InputManager (com.jme3.input.InputManager)1 AwtMouseInput (com.jme3.input.awt.AwtMouseInput)1 NewtMouseInput (com.jme3.input.jogl.NewtMouseInput)1 JoglGL (com.jme3.renderer.jogl.JoglGL)1 JoglGLExt (com.jme3.renderer.jogl.JoglGLExt)1 JoglGLFbo (com.jme3.renderer.jogl.JoglGLFbo)1