From 9ab8ca9906b60f84c3b0f3894a47170b97ca4445 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 21:06:28 +0000 Subject: [PATCH 1/3] Initial plan From e13d1a6ed5da1fa1c4289ba684c42b957586f58b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 21:14:14 +0000 Subject: [PATCH 2/3] Fix VehicleCreator not receiving input The root cause was that keyboard events captured by SceneViewerTopComponent were only forwarded to the active camera controller's onKeyEvent method, but never reached the jME3 InputManager. This meant VehicleEditorController's input mappings registered via InputManager.addListener were never triggered. The fix follows the pattern used by ComposerCameraController: 1. VehicleCreatorCameraController now overrides onKeyEvent to forward key events to VehicleEditorController 2. VehicleEditorController now has an onKeyEvent method that translates key codes to action bindings and calls onAction 3. VehicleCreatorTopComponent passes the editorController reference to the cameraController Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com> --- .../VehicleCreatorCameraController.java | 17 +++++++++ .../VehicleCreatorTopComponent.java | 1 + .../VehicleEditorController.java | 36 +++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorCameraController.java b/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorCameraController.java index 50fbbaabb..5e8379dda 100644 --- a/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorCameraController.java +++ b/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorCameraController.java @@ -33,6 +33,7 @@ import com.jme3.gde.core.scene.controller.AbstractCameraController; import com.jme3.input.InputManager; +import com.jme3.input.event.KeyInputEvent; import com.jme3.renderer.Camera; import com.jme3.scene.Spatial; @@ -43,6 +44,7 @@ public class VehicleCreatorCameraController extends AbstractCameraController { private Spatial vehicle; + private VehicleEditorController editorController; public VehicleCreatorCameraController(Camera cam, InputManager inputManager) { super(cam, inputManager); @@ -67,6 +69,21 @@ public void setVehicle(Spatial vehicle) { this.vehicle = vehicle; } + /** + * @param editorController the VehicleEditorController to forward key events to + */ + public void setEditorController(VehicleEditorController editorController) { + this.editorController = editorController; + } + + @Override + public void onKeyEvent(KeyInputEvent kie) { + super.onKeyEvent(kie); + if (editorController != null) { + editorController.onKeyEvent(kie); + } + } + @Override public boolean useCameraControls() { return true; diff --git a/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.java b/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.java index aafb7770a..cd0857cd6 100644 --- a/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.java +++ b/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleCreatorTopComponent.java @@ -909,6 +909,7 @@ public void sceneOpened(final SceneRequest request) { editorController = newEditorController; cameraController = new VehicleCreatorCameraController(SceneApplication.getApplication().getCamera(), SceneApplication.getApplication().getInputManager()); cameraController.setMaster(this); + cameraController.setEditorController(editorController); cameraController.enable(); cameraController.setVehicle(request.getRootNode()); setLoadedScene(currentRequest.getDataObject().getNodeDelegate(), true); diff --git a/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleEditorController.java b/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleEditorController.java index 9ffd03d7f..698babafa 100644 --- a/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleEditorController.java +++ b/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleEditorController.java @@ -22,6 +22,7 @@ import com.jme3.input.KeyInput; import com.jme3.input.controls.ActionListener; import com.jme3.input.controls.KeyTrigger; +import com.jme3.input.event.KeyInputEvent; import com.jme3.light.DirectionalLight; import com.jme3.math.Matrix3f; import com.jme3.math.Vector3f; @@ -522,6 +523,41 @@ public void onAction(String binding, boolean value, float f) { } } + /** + * Handles key input events forwarded from the camera controller. + * Converts key codes to action bindings and calls onAction. + * + * @param kie the key input event + */ + public void onKeyEvent(KeyInputEvent kie) { + String binding = null; + switch (kie.getKeyCode()) { + case KeyInput.KEY_A: + binding = "VehicleEditor_Left"; + break; + case KeyInput.KEY_D: + binding = "VehicleEditor_Right"; + break; + case KeyInput.KEY_W: + binding = "VehicleEditor_Up"; + break; + case KeyInput.KEY_S: + binding = "VehicleEditor_Down"; + break; + case KeyInput.KEY_SPACE: + binding = "VehicleEditor_Space"; + break; + case KeyInput.KEY_RETURN: + binding = "VehicleEditor_Reset"; + break; + default: + return; + } + if (binding != null) { + onAction(binding, kie.isPressed(), 0); + } + } + /** * @return the motorForce */ From 786f604577ddbbcaed72090a476ee6a48d169ee1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 21:17:22 +0000 Subject: [PATCH 3/3] Remove unnecessary null check in onKeyEvent Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com> --- .../jme3/gde/vehiclecreator/VehicleEditorController.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleEditorController.java b/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleEditorController.java index 698babafa..7c92314da 100644 --- a/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleEditorController.java +++ b/jme3-vehicle-creator/src/com/jme3/gde/vehiclecreator/VehicleEditorController.java @@ -530,7 +530,7 @@ public void onAction(String binding, boolean value, float f) { * @param kie the key input event */ public void onKeyEvent(KeyInputEvent kie) { - String binding = null; + String binding; switch (kie.getKeyCode()) { case KeyInput.KEY_A: binding = "VehicleEditor_Left"; @@ -553,9 +553,7 @@ public void onKeyEvent(KeyInputEvent kie) { default: return; } - if (binding != null) { - onAction(binding, kie.isPressed(), 0); - } + onAction(binding, kie.isPressed(), 0); } /**