Search in sources :

Example 1 with MouseInput

use of com.jme3.input.MouseInput in project jmonkeyengine by jMonkeyEngine.

the class VRMouseManager method initialize.

/**
     * Initialize the VR mouse manager.
     */
protected void initialize() {
    logger.config("Initializing VR mouse manager.");
    // load default mouseimage
    mouseImage = new Picture("mouse");
    setImage("Common/Util/mouse.png");
    // hide default cursor by making it invisible
    MouseInput mi = environment.getApplication().getContext().getMouseInput();
    if (mi instanceof GlfwMouseInputVR) {
        ((GlfwMouseInputVR) mi).hideActiveCursor();
    }
    centerMouse();
    logger.config("Initialized VR mouse manager [SUCCESS]");
}
Also used : GlfwMouseInputVR(com.jme3.input.lwjgl.GlfwMouseInputVR) Picture(com.jme3.ui.Picture) MouseInput(com.jme3.input.MouseInput)

Example 2 with MouseInput

use of com.jme3.input.MouseInput in project jmonkeyengine by jMonkeyEngine.

the class VRMouseManager method centerMouse.

/**
     * Center the mouse on the display.
     */
public void centerMouse() {
    if (environment != null) {
        if (environment.getApplication() != null) {
            // set mouse in center of the screen if newly added
            Vector2f size = environment.getVRGUIManager().getCanvasSize();
            MouseInput mi = environment.getApplication().getContext().getMouseInput();
            AppSettings as = environment.getApplication().getContext().getSettings();
            if (mi instanceof GlfwMouseInputVR)
                ((GlfwMouseInputVR) mi).setCursorPosition((int) (as.getWidth() / 2f), (int) (as.getHeight() / 2f));
            if (environment.isInVR()) {
                cursorPos.x = size.x / 2f;
                cursorPos.y = size.y / 2f;
                recentCenterCount = 2;
            }
        } else {
            throw new IllegalStateException("This VR environment is not attached to any application.");
        }
    } else {
        throw new IllegalStateException("This VR view manager is not attached to any VR environment.");
    }
}
Also used : GlfwMouseInputVR(com.jme3.input.lwjgl.GlfwMouseInputVR) AppSettings(com.jme3.system.AppSettings) Vector2f(com.jme3.math.Vector2f) MouseInput(com.jme3.input.MouseInput)

Example 3 with MouseInput

use of com.jme3.input.MouseInput in project jmonkeyengine by jMonkeyEngine.

the class JoglNewtAbstractDisplay method getMouseInput.

@Override
public MouseInput getMouseInput() {
    if (mouseInput == null) {
        mouseInput = new NewtMouseInput();
        ((NewtMouseInput) mouseInput).setInputSource(canvas);
    }
    return mouseInput;
}
Also used : NewtMouseInput(com.jme3.input.jogl.NewtMouseInput)

Example 4 with MouseInput

use of com.jme3.input.MouseInput in project jmonkeyengine by jMonkeyEngine.

the class LwjglContext 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 : GLFbo(com.jme3.renderer.opengl.GLFbo) GLRenderer(com.jme3.renderer.opengl.GLRenderer) GL(com.jme3.renderer.opengl.GL) LwjglGL(com.jme3.renderer.lwjgl.LwjglGL) LwjglGLExt(com.jme3.renderer.lwjgl.LwjglGLExt) LwjglGLFboGL3(com.jme3.renderer.lwjgl.LwjglGLFboGL3) LwjglGLExt(com.jme3.renderer.lwjgl.LwjglGLExt) GLExt(com.jme3.renderer.opengl.GLExt) GLCapabilities(org.lwjgl.opengl.GLCapabilities) RendererException(com.jme3.renderer.RendererException) GLDebugDesktop(com.jme3.renderer.opengl.GLDebugDesktop) GLTimingState(com.jme3.renderer.opengl.GLTimingState) LwjglGLFboEXT(com.jme3.renderer.lwjgl.LwjglGLFboEXT) LwjglGL(com.jme3.renderer.lwjgl.LwjglGL)

Example 5 with MouseInput

use of com.jme3.input.MouseInput in project jmonkeyengine by jMonkeyEngine.

the class JoglContext method initContextFirstTime.

protected void initContextFirstTime() {
    if (GLContext.getCurrent().getGLVersionNumber().getMajor() < 2) {
        throw new RendererException("OpenGL 2.0 or higher is " + "required for jMonkeyEngine");
    }
    if (settings.getRenderer().startsWith("JOGL")) {
        com.jme3.renderer.opengl.GL gl = new JoglGL();
        GLExt glext = new JoglGLExt();
        GLFbo glfbo = new JoglGLFbo();
        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 = (com.jme3.renderer.opengl.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 = (com.jme3.renderer.opengl.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 (GLContext.getCurrentGL().isExtensionAvailable("GL_ARB_debug_output") && settings.getBoolean("GraphicsDebug")) {
        GLContext.getCurrent().enableGLDebugMessage(true);
        GLContext.getCurrent().addGLDebugListener(new JoglGLDebugOutputHandler());
    }
    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();
    }
    if (settings.isOpenCLSupport()) {
        initOpenCL();
    }
}
Also used : JoglGLFbo(com.jme3.renderer.jogl.JoglGLFbo) GLFbo(com.jme3.renderer.opengl.GLFbo) GLRenderer(com.jme3.renderer.opengl.GLRenderer) JoglGLFbo(com.jme3.renderer.jogl.JoglGLFbo) GLExt(com.jme3.renderer.opengl.GLExt) JoglGLExt(com.jme3.renderer.jogl.JoglGLExt) JoglGLExt(com.jme3.renderer.jogl.JoglGLExt) RendererException(com.jme3.renderer.RendererException) GLDebugDesktop(com.jme3.renderer.opengl.GLDebugDesktop) GLTimingState(com.jme3.renderer.opengl.GLTimingState) JoglGL(com.jme3.renderer.jogl.JoglGL)

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