Skip to content

Commit

Permalink
TestHullContact: add help node
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Jul 6, 2019
1 parent b91e690 commit 6e03d15
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down Expand Up @@ -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);
}

/**
Expand All @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 6e03d15

Please sign in to comment.