diff options
author | Joshua Slack <[email protected]> | 2018-01-15 12:05:59 -0600 |
---|---|---|
committer | Joshua Slack <[email protected]> | 2018-01-15 12:05:59 -0600 |
commit | ec71ecdbbb1437dd57a0f47a1f70d36a25529038 (patch) | |
tree | 1b3eb134296e5341fcc75959fbe6c048edbe8b47 /ardor3d-examples | |
parent | 7f712e9e1516547a9472d424ff8f47b726066358 (diff) |
Added new method to Canvas interface providing a way to store and retrieve the mouse manager for a given canvas.
Diffstat (limited to 'ardor3d-examples')
10 files changed, 87 insertions, 75 deletions
diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java index 4f24172..97912de 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/ExampleBase.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -239,7 +239,7 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { // Execute updateQueue item GameTaskQueueManager.getManager(_canvas.getCanvasRenderer().getRenderContext()).getQueue(GameTaskQueue.UPDATE) - .execute(); + .execute(); /** Call simpleUpdate in any derived classes of ExampleBase. */ updateExample(timer); @@ -263,7 +263,7 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { public boolean renderUnto(final Renderer renderer) { // Execute renderQueue item GameTaskQueueManager.getManager(_canvas.getCanvasRenderer().getRenderContext()).getQueue(GameTaskQueue.RENDER) - .execute(renderer); + .execute(renderer); // Clean up card garbage such as textures, vbos, etc. ContextGarbageCollector.doRuntimeCleanup(renderer); @@ -347,14 +347,14 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { prefs.getFrequency(), // alpha _minAlphaBits != -1 ? _minAlphaBits : prefs.getAlphaBits(), - // depth - _minDepthBits != -1 ? _minDepthBits : prefs.getDepthBits(), - // stencil - _minStencilBits != -1 ? _minStencilBits : prefs.getStencilBits(), - // samples - prefs.getSamples(), - // other - prefs.isFullscreen(), _stereo); + // depth + _minDepthBits != -1 ? _minDepthBits : prefs.getDepthBits(), + // stencil + _minStencilBits != -1 ? _minStencilBits : prefs.getStencilBits(), + // samples + prefs.getSamples(), + // other + prefs.isFullscreen(), _stereo); example._settings = settings; @@ -363,18 +363,20 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { try { SharedLibraryLoader.load(true); } catch (Exception e) {e.printStackTrace();} - + final LwjglCanvasRenderer canvasRenderer = new LwjglCanvasRenderer(example); example._canvas = new LwjglCanvas(settings, canvasRenderer); example._physicalLayer = new PhysicalLayer(new LwjglKeyboardWrapper(), new LwjglMouseWrapper(), new LwjglControllerWrapper(), (LwjglCanvas) example._canvas); example._mouseManager = new LwjglMouseManager(); + example._canvas.setMouseManager(example._mouseManager); TextureRendererFactory.INSTANCE.setProvider(new LwjglTextureRendererProvider()); } else if (prefs.getRenderer().startsWith("JOGL")) { final JoglCanvasRenderer canvasRenderer = new JoglCanvasRenderer(example); example._canvas = new JoglNewtWindow(canvasRenderer, settings); final JoglNewtWindow canvas = (JoglNewtWindow) example._canvas; example._mouseManager = new JoglNewtMouseManager(canvas); + example._canvas.setMouseManager(example._mouseManager); example._physicalLayer = new PhysicalLayer(new JoglNewtKeyboardWrapper(canvas), new JoglNewtMouseWrapper( canvas, example._mouseManager), DummyControllerWrapper.INSTANCE, new JoglNewtFocusWrapper(canvas)); TextureRendererFactory.INSTANCE.setProvider(new JoglTextureRendererProvider()); @@ -460,17 +462,17 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonClickedCondition(MouseButton.RIGHT), new TriggerAction() { - public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { - - final Vector2 pos = Vector2.fetchTempInstance().set( - inputStates.getCurrent().getMouseState().getX(), - inputStates.getCurrent().getMouseState().getY()); - final Ray3 pickRay = new Ray3(); - _canvas.getCanvasRenderer().getCamera().getPickRay(pos, false, pickRay); - Vector2.releaseTempInstance(pos); - doPick(pickRay); - } - }, "pickTrigger")); + public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) { + + final Vector2 pos = Vector2.fetchTempInstance().set( + inputStates.getCurrent().getMouseState().getX(), + inputStates.getCurrent().getMouseState().getY()); + final Ray3 pickRay = new Ray3(); + _canvas.getCanvasRenderer().getCamera().getPickRay(pos, false, pickRay); + Vector2.releaseTempInstance(pos); + doPick(pickRay); + } + }, "pickTrigger")); _logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ESCAPE), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { @@ -535,20 +537,20 @@ public abstract class ExampleBase implements Runnable, Updater, Scene { _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonPressedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.GRABBED); - } - } - })); + public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.GRABBED); + } + } + })); _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); - } - } - })); + public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); + } + } + })); _logicalLayer.registerTrigger(new InputTrigger(new AnyKeyCondition(), new TriggerAction() { public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) { diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java index 0c3f726..7952c5f 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/JoglBaseApplet.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -197,7 +197,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene { // Execute updateQueue item GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext()) - .getQueue(GameTaskQueue.UPDATE).execute(); + .getQueue(GameTaskQueue.UPDATE).execute(); updateAppletScene(_timer); // Update controllers/render states/transforms/bounds for rootNode. @@ -213,6 +213,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene { protected void initInput() { _mouseManager = new JoglNewtMouseManager(_glCanvas); + _glCanvas.setMouseManager(_mouseManager); _logicalLayer = new LogicalLayer(); _physicalLayer = new PhysicalLayer(new JoglNewtKeyboardWrapper(_glCanvas), new JoglNewtMouseWrapper(_glCanvas, _mouseManager), new JoglNewtFocusWrapper(_glCanvas)); @@ -258,23 +259,23 @@ public abstract class JoglBaseApplet extends Applet implements Scene { _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonPressedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, - final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.GRABBED); - } - } - })); + public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, + final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.GRABBED); + } + } + })); _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, - final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); - } - } - })); + public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, + final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); + } + } + })); } protected void initBaseScene() { @@ -305,7 +306,7 @@ public abstract class JoglBaseApplet extends Applet implements Scene { public boolean renderUnto(final Renderer renderer) { // Execute renderQueue item GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext()) - .getQueue(GameTaskQueue.RENDER).execute(renderer); + .getQueue(GameTaskQueue.RENDER).execute(renderer); // Clean up card garbage such as textures, vbos, etc. ContextGarbageCollector.doRuntimeCleanup(renderer); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/LwjglBaseApplet.java b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/LwjglBaseApplet.java index ab1d9f9..99eb59f 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/applet/LwjglBaseApplet.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/applet/LwjglBaseApplet.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -191,7 +191,7 @@ public abstract class LwjglBaseApplet extends Applet implements Scene { // Execute updateQueue item GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext()) - .getQueue(GameTaskQueue.UPDATE).execute(); + .getQueue(GameTaskQueue.UPDATE).execute(); updateAppletScene(_timer); @@ -218,6 +218,8 @@ public abstract class LwjglBaseApplet extends Applet implements Scene { protected void initInput() { _mouseManager = new LwjglMouseManager(); + _glCanvas.setMouseManager(_mouseManager); + _logicalLayer = new LogicalLayer(); _physicalLayer = new PhysicalLayer(new LwjglKeyboardWrapper(), new LwjglMouseWrapper(), new LwjglControllerWrapper(), _glCanvas); @@ -265,23 +267,23 @@ public abstract class LwjglBaseApplet extends Applet implements Scene { _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonPressedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, - final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.GRABBED); - } - } - })); + public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, + final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.GRABBED); + } + } + })); _logicalLayer.registerTrigger(new InputTrigger(new MouseButtonReleasedCondition(MouseButton.LEFT), new TriggerAction() { - public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, - final double tpf) { - if (_mouseManager.isSetGrabbedSupported()) { - _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); - } - } - })); + public void perform(final com.ardor3d.framework.Canvas source, final TwoInputStates inputState, + final double tpf) { + if (_mouseManager.isSetGrabbedSupported()) { + _mouseManager.setGrabbed(GrabbedState.NOT_GRABBED); + } + } + })); } protected void initBaseScene() { @@ -312,7 +314,7 @@ public abstract class LwjglBaseApplet extends Applet implements Scene { public boolean renderUnto(final Renderer renderer) { // Execute renderQueue item GameTaskQueueManager.getManager(_glCanvas.getCanvasRenderer().getRenderContext()) - .getQueue(GameTaskQueue.RENDER).execute(renderer); + .getQueue(GameTaskQueue.RENDER).execute(renderer); // Clean up card garbage such as textures, vbos, etc. ContextGarbageCollector.doRuntimeCleanup(renderer); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java index 57128bf..b0044ed 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtDesktopExample.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -152,6 +152,7 @@ public class JoglAwtDesktopExample { final AwtFocusWrapper focusWrapper = new AwtFocusWrapper(theCanvas); final AwtMouseManager mouseManager = new AwtMouseManager(theCanvas); final AwtMouseWrapper mouseWrapper = new AwtMouseWrapper(theCanvas, mouseManager); + theCanvas.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java index 9b902f1..99dad6e 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglAwtExample.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -163,6 +163,7 @@ public class JoglAwtExample { final AwtFocusWrapper focusWrapper = new AwtFocusWrapper(theCanvas); final AwtMouseManager mouseManager = new AwtMouseManager(theCanvas); final AwtMouseWrapper mouseWrapper = new AwtMouseWrapper(theCanvas, mouseManager); + theCanvas.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java index b3778f6..61de00d 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtAwtExample.java @@ -165,6 +165,7 @@ public class JoglNewtAwtExample { final JoglNewtFocusWrapper focusWrapper = new JoglNewtFocusWrapper(theCanvas); final JoglNewtMouseManager mouseManager = new JoglNewtMouseManager(theCanvas); final JoglNewtMouseWrapper mouseWrapper = new JoglNewtMouseWrapper(theCanvas, mouseManager); + theCanvas.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java index 59f54b6..c93fcad 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglNewtSwtExample.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -204,6 +204,7 @@ public class JoglNewtSwtExample { final JoglNewtFocusWrapper focusWrapper = new JoglNewtFocusWrapper(canvas1); final JoglNewtMouseManager mouseManager = new JoglNewtMouseManager(canvas1); final JoglNewtMouseWrapper mouseWrapper = new JoglNewtMouseWrapper(canvas1, mouseManager); + canvas1.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java index 3026828..8062a57 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/JoglSwtExample.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -208,6 +208,7 @@ public class JoglSwtExample { final SwtMouseWrapper mouseWrapper = new SwtMouseWrapper(canvas1); final SwtFocusWrapper focusWrapper = new SwtFocusWrapper(canvas1); final SwtMouseManager mouseManager = new SwtMouseManager(canvas1); + canvas1.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglAwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglAwtExample.java index a45df8f..b12b3b4 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglAwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglAwtExample.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -163,6 +163,7 @@ public class LwjglAwtExample { final AwtFocusWrapper focusWrapper = new AwtFocusWrapper(theCanvas); final AwtMouseManager mouseManager = new AwtMouseManager(theCanvas); final AwtMouseWrapper mouseWrapper = new AwtMouseWrapper(theCanvas, mouseManager); + theCanvas.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); diff --git a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglSwtExample.java b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglSwtExample.java index e564393..2d6fb5b 100644 --- a/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglSwtExample.java +++ b/ardor3d-examples/src/main/java/com/ardor3d/example/canvas/LwjglSwtExample.java @@ -3,7 +3,7 @@ * * This file is part of Ardor3D. * - * Ardor3D is free software: you can redistribute it and/or modify it + * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ @@ -222,6 +222,7 @@ public class LwjglSwtExample { final SwtMouseWrapper mouseWrapper = new SwtMouseWrapper(canvas1); final SwtFocusWrapper focusWrapper = new SwtFocusWrapper(canvas1); final SwtMouseManager mouseManager = new SwtMouseManager(canvas1); + canvas1.setMouseManager(mouseManager); final ControllerWrapper controllerWrapper = new DummyControllerWrapper(); final PhysicalLayer pl = new PhysicalLayer(keyboardWrapper, mouseWrapper, controllerWrapper, focusWrapper); |