@@ -35,6 +35,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
3535import com .jme3 .bullet .collision .shapes .CollisionShape ;
3636import com .jme3 .bullet .control .RigidBodyControl ;
3737import com .jme3 .bullet .util .CollisionShapeFactory ;
38+ import com .jme3 .font .Rectangle ;
3839import com .jme3 .input .CameraInput ;
3940import com .jme3 .input .KeyInput ;
4041import com .jme3 .light .AmbientLight ;
@@ -113,6 +114,10 @@ public class TestHeightfield extends ActionApplication {
113114 * parent for added geometries
114115 */
115116 final private Node addNode = new Node ("add" );
117+ /**
118+ * GUI node for displaying hotkey help/hints
119+ */
120+ private Node helpNode ;
116121 /**
117122 * dump debugging information to System.out
118123 */
@@ -203,8 +208,19 @@ public void moreDefaultBindings() {
203208 dim .bind ("signal orbitLeft" , KeyInput .KEY_LEFT );
204209 dim .bind ("signal orbitRight" , KeyInput .KEY_RIGHT );
205210
211+ dim .bind ("toggle help" , KeyInput .KEY_H );
206212 dim .bind ("toggle meshes" , KeyInput .KEY_M );
207213 dim .bind ("toggle physics debug" , KeyInput .KEY_SLASH );
214+
215+ float x = 10f ;
216+ float y = cam .getHeight () - 10f ;
217+ float width = cam .getWidth () - 20f ;
218+ float height = cam .getHeight () - 20f ;
219+ Rectangle rectangle = new Rectangle (x , y , width , height );
220+
221+ float space = 20f ;
222+ helpNode = HelpUtils .buildNode (dim , rectangle , guiFont , space );
223+ guiNode .attachChild (helpNode );
208224 }
209225
210226 /**
@@ -234,6 +250,10 @@ public void onAction(String actionString, boolean ongoing, float tpf) {
234250 dumper .dump (renderManager );
235251 return ;
236252
253+ case "toggle help" :
254+ toggleHelp ();
255+ return ;
256+
237257 case "toggle meshes" :
238258 toggleMeshes ();
239259 return ;
@@ -465,6 +485,17 @@ private AbstractHeightMap loadHeightMap() {
465485 return heightMap ;
466486 }
467487
488+ /**
489+ * Toggle visibility of the helpNode.
490+ */
491+ private void toggleHelp () {
492+ if (helpNode .getCullHint () == Spatial .CullHint .Always ) {
493+ helpNode .setCullHint (Spatial .CullHint .Never );
494+ } else {
495+ helpNode .setCullHint (Spatial .CullHint .Always );
496+ }
497+ }
498+
468499 /**
469500 * Toggle rendering of added geometries on/off.
470501 */
0 commit comments