Skip to content

Commit 54296a4

Browse files
committed
TestHullContact: add help node
1 parent 57357f5 commit 54296a4

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

MinieExamples/src/main/java/jme3utilities/minie/test/TestHullContact.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3838
import com.jme3.bullet.debug.DebugInitListener;
3939
import com.jme3.bullet.objects.PhysicsRigidBody;
4040
import com.jme3.bullet.util.DebugShapeFactory;
41+
import com.jme3.font.Rectangle;
4142
import com.jme3.input.KeyInput;
4243
import com.jme3.light.AmbientLight;
4344
import com.jme3.light.DirectionalLight;
@@ -102,6 +103,10 @@ public class TestHullContact
102103
final private Generator random = new Generator();
103104
private int numGems = 0;
104105
final private Material gemMaterials[] = new Material[4];
106+
/**
107+
* GUI node for displaying hotkey help/hints
108+
*/
109+
private Node helpNode;
105110
/**
106111
* space for physics simulation
107112
*/
@@ -173,11 +178,24 @@ public void moreDefaultBindings() {
173178

174179
dim.bind("dump physicsSpace", KeyInput.KEY_O);
175180
dim.bind("dump scenes", KeyInput.KEY_P);
181+
176182
dim.bind("signal orbitLeft", KeyInput.KEY_LEFT);
177183
dim.bind("signal orbitRight", KeyInput.KEY_RIGHT);
178184
dim.bind("signal shower", KeyInput.KEY_I);
179185
dim.bind("signal shower", KeyInput.KEY_INSERT);
186+
187+
dim.bind("toggle help", KeyInput.KEY_H);
180188
dim.bind("toggle pause", KeyInput.KEY_PERIOD);
189+
190+
float x = 10f;
191+
float y = cam.getHeight() - 10f;
192+
float width = cam.getWidth() - 20f;
193+
float height = cam.getHeight() - 20f;
194+
Rectangle rectangle = new Rectangle(x, y, width, height);
195+
196+
float space = 20f;
197+
helpNode = HelpUtils.buildNode(dim, rectangle, guiFont, space);
198+
guiNode.attachChild(helpNode);
181199
}
182200

183201
/**
@@ -199,6 +217,10 @@ public void onAction(String actionString, boolean ongoing, float tpf) {
199217
dumpScenes();
200218
return;
201219

220+
case "toggle help":
221+
toggleHelp();
222+
return;
223+
202224
case "toggle pause":
203225
togglePause();
204226
return;
@@ -382,6 +404,17 @@ private void dumpScenes() {
382404
dumper.dump(renderManager);
383405
}
384406

407+
/**
408+
* Toggle visibility of the helpNode.
409+
*/
410+
private void toggleHelp() {
411+
if (helpNode.getCullHint() == Spatial.CullHint.Always) {
412+
helpNode.setCullHint(Spatial.CullHint.Never);
413+
} else {
414+
helpNode.setCullHint(Spatial.CullHint.Always);
415+
}
416+
}
417+
385418
/**
386419
* Toggle the animation and physics simulation: paused/running.
387420
*/

0 commit comments

Comments
 (0)