From 6e03d150e7c992e033a90e903093e29e7993ff1e Mon Sep 17 00:00:00 2001 From: Stephen Gold Date: Sat, 6 Jul 2019 16:08:38 -0700 Subject: [PATCH] TestHullContact: add help node --- .../minie/test/TestHullContact.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/MinieExamples/src/main/java/jme3utilities/minie/test/TestHullContact.java b/MinieExamples/src/main/java/jme3utilities/minie/test/TestHullContact.java index 556f0df70..fd867d1ff 100644 --- a/MinieExamples/src/main/java/jme3utilities/minie/test/TestHullContact.java +++ b/MinieExamples/src/main/java/jme3utilities/minie/test/TestHullContact.java @@ -38,6 +38,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE import com.jme3.bullet.debug.DebugInitListener; import com.jme3.bullet.objects.PhysicsRigidBody; import com.jme3.bullet.util.DebugShapeFactory; +import com.jme3.font.Rectangle; import com.jme3.input.KeyInput; import com.jme3.light.AmbientLight; import com.jme3.light.DirectionalLight; @@ -102,6 +103,10 @@ public class TestHullContact final private Generator random = new Generator(); private int numGems = 0; final private Material gemMaterials[] = new Material[4]; + /** + * GUI node for displaying hotkey help/hints + */ + private Node helpNode; /** * space for physics simulation */ @@ -173,11 +178,24 @@ public void moreDefaultBindings() { dim.bind("dump physicsSpace", KeyInput.KEY_O); dim.bind("dump scenes", KeyInput.KEY_P); + dim.bind("signal orbitLeft", KeyInput.KEY_LEFT); dim.bind("signal orbitRight", KeyInput.KEY_RIGHT); dim.bind("signal shower", KeyInput.KEY_I); dim.bind("signal shower", KeyInput.KEY_INSERT); + + dim.bind("toggle help", KeyInput.KEY_H); dim.bind("toggle pause", KeyInput.KEY_PERIOD); + + float x = 10f; + float y = cam.getHeight() - 10f; + float width = cam.getWidth() - 20f; + float height = cam.getHeight() - 20f; + Rectangle rectangle = new Rectangle(x, y, width, height); + + float space = 20f; + helpNode = HelpUtils.buildNode(dim, rectangle, guiFont, space); + guiNode.attachChild(helpNode); } /** @@ -199,6 +217,10 @@ public void onAction(String actionString, boolean ongoing, float tpf) { dumpScenes(); return; + case "toggle help": + toggleHelp(); + return; + case "toggle pause": togglePause(); return; @@ -382,6 +404,17 @@ private void dumpScenes() { dumper.dump(renderManager); } + /** + * Toggle visibility of the helpNode. + */ + private void toggleHelp() { + if (helpNode.getCullHint() == Spatial.CullHint.Always) { + helpNode.setCullHint(Spatial.CullHint.Never); + } else { + helpNode.setCullHint(Spatial.CullHint.Always); + } + } + /** * Toggle the animation and physics simulation: paused/running. */