}
_controlHandle = FirstPersonControl.setupTriggers(_logicalLayer, _worldUp, true);
_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"));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.ESCAPE), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
exit();
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.L), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
_lightState.setEnabled(!_lightState.isEnabled());
// Either an update or a markDirty is needed here since we did not touch the affected spatial directly.
_root.markDirty(DirtyType.RenderState);
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F4), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
_showDepth = !_showDepth;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.T), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
_wireframeState.setEnabled(!_wireframeState.isEnabled());
// Either an update or a markDirty is needed here since we did not touch the affected spatial directly.
_root.markDirty(DirtyType.RenderState);
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.B), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
_showBounds = !_showBounds;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.C), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
System.out.println("Camera: " + _canvas.getCanvasRenderer().getCamera());
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.N), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
_showNormals = !_showNormals;
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new KeyPressedCondition(Key.F1), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
_doShot = true;
}
}));
final Predicate<TwoInputStates> clickLeftOrRight = Predicates.or(new MouseButtonClickedCondition(
MouseButton.LEFT), new MouseButtonClickedCondition(MouseButton.RIGHT));
_logicalLayer.registerTrigger(new InputTrigger(clickLeftOrRight, new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputStates, final double tpf) {
System.err.println("clicked: " + inputStates.getCurrent().getMouseState().getClickCounts());
}
}));
_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);
}
}
}));
_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);
}
}
}));
_logicalLayer.registerTrigger(new InputTrigger(new AnyKeyCondition(), new TriggerAction() {
public void perform(final Canvas source, final TwoInputStates inputState, final double tpf) {
System.out.println("Key character pressed: "
+ inputState.getCurrent().getKeyboardState().getKeyEvent().getKeyChar());
}
}));