Skip to content

Vibe/mavehicles editor phases 1 2 fe2b90 - #728

Open
neph1 wants to merge 8 commits into
jMonkeyEngine:masterfrom
neph1:vibe/mavehicles-editor-phases-1-2-fe2b90
Open

neph1 wants to merge 8 commits into
jMonkeyEngine:masterfrom
neph1:vibe/mavehicles-editor-phases-1-2-fe2b90

Conversation

@neph1

@neph1 neph1 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements phases 1 and 2 of the jme-vehicles (MaVehicles) migration plan for jme3-vehicle-creator.

Phase 1 — dependency plumbing

build.gradle: add com.github.stephengold:MaVehicles:0.7.2 and com.github.stephengold:jme-ttf:3.0.1 to corelibs, and route both jars to jme3-core-baselibs (same module as jme3-core/Minie/Heart, following the PR https://github.com/jMonkeyEngine/sdk/pull/547 Minie pattern) in both copyBaseLibs and createBaseXml. This is required for the NetBeans module classloader: com.jme3.gde.core.libraries declares no dependency on baselibs, so MaVehicles classes loaded from there could not resolve jme3utilities.* (Heart) / com.jme3.bullet.* (Minie) — the initial ClassNotFoundException: jme3utilities.Loadable — whereas baselibs exports all of them plus com.jayfella.jme.vehicle.* / com.atr.jme.font.* from a single module. jme3-vehicle-creator already depends on baselibs, so no module dependency changes are needed.
Pinned release 0.7.2 (newest on Maven Central) is built against jME 3.8.1 and works with the SDK's Minie 9.0.3 + Heart 9.3.0 on master's jME 3.10.0-beta2; no Minie upgrade needed. 3-clause BSD license.

Phase 2 — editable four-wheeled vehicle

New EditableVehicle: concrete MaVehicles Vehicle with exactly four wheels (two steered front wheels in +Z, two rear), a SimpleEngine, and a 4+1 GearBox, built around the scene root node as chassis.
New SimpleEngine / SimpleWheelModel (generated cylinder, or a user spatial normalized to the WheelModel convention).
SuspensionSettings migrated to MaVehicles parameters: suspension stiffness / max force / rest length / travel / compress+relax damping ratios, wheel radius / frictionSlip / roll influence / max steer angle / power fraction, Pacejka tire coefficients, engine max watts, per-gear upshift speeds. Provides applyToWheel / applyToVehicle / loadFromWheel / loadFromVehicle.
VehicleEditorController rewritten around the EditableVehicle: doCheckVehicle creates it from the scene root, doAddWheel retunes the wheel nearest the selected spatial (radius from its bounding box or fixed), applyWheelData targets all/front/rear wheels, hull shape from selected spatial still supported, and "test vehicle" drives it through a minimal VehicleWorld backed by the preview's BulletAppState (WASD / space / enter).
VehicleCreatorTopComponent keeps its UI shell; damping sliders are now 0–1 damping ratios and the motor/brake spinners are 0–1 control signals (.form + Bundle.properties updated to match).

Out of scope per the plan: loading old PhysicsVehicle scenes, a new vehicle file format, bikes/props, test-drive HUD/chase cam polish, and .j3o export (note: in 0.7.2 Vehicle implements Heart's Loadable, not Savable — the Savable/.j3o story applies to the unpublished 0.7.3-SNAPSHOT, a phase-4 decision).
Verification

./gradlew copyBaseLibs createBaseXml — MaVehicles-0.7.2.jar and jme-ttf-3.0.1.jar land in jme3-core-baselibs/release/modules/ext; generated baselibs project.xml exports com.jayfella.jme.vehicle.*, com.atr.jme.font.* and jme3utilities.*; built module jar com-jme3-gde-core-baselibs.jar manifest confirms the same public packages (single module classloader for MaVehicles + Heart + Minie + jme3-core).
ant -f jme3-vehicle-creator/build.xml clean netbeans (with plugins.version=3.10.0 + set-spec-version, reverted afterwards) — BUILD SUCCESSFUL, only benign JDK 25 this-escape lint warnings.
Standalone smoke test against the built module jar + ext jars with Libbulletjme natives: EditableVehicle constructs with 4 wheels (front two steered) and SuspensionSettings applies stiffness/friction/engine/gear/tire values — prints OK.

mistral-vibe and others added 8 commits November 25, 2026 17:36
Phase 1: wrap com.github.stephengold:MaVehicles:0.7.2 and jme-ttf:3.0.1
as SDK libraries (routed to jme3-core-libraries by copyBaseLibs/
createBaseXml) and add the com.jme3.gde.core.libraries module
dependency to jme3-vehicle-creator.

Phase 2: rewrite the editor's data layer around a MaVehicles Vehicle:
- EditableVehicle: concrete four-wheeled Vehicle (chassis spatial, two
  steered front wheels, Engine, GearBox)
- SimpleEngine / SimpleWheelModel: default MaVehicles parts
- SuspensionSettings migrated to MaVehicles parameters (suspension
  stiffness/damping/travel, wheel radius/friction/steering, Pacejka
  tire coefficients, engine power, gear upshift speeds)
- VehicleEditorController now builds and edits the EditableVehicle in
  memory and test-drives it through a minimal VehicleWorld backed by
  the preview's BulletAppState
- TopComponent keeps its UI shell; motor/brake spinners are now 0..1
  control signals

Co-authored-by: mindbotbot <mindbotbot@users.noreply.github.com>
MaVehicles classes reference jme3-core/Minie/Heart classes (notably
jme3utilities.Loadable from Heart). jme3-core-libraries declares no
dependency on jme3-core-baselibs, so its module classloader cannot
resolve those types, causing ClassNotFoundException: jme3utilities.Loadable
when loading com.jayfella.jme.vehicle.Vehicle. Keep the jars in the same
module as Minie/Heart (the PR jMonkeyEngine#547 pattern) in both copyBaseLibs and
createBaseXml; the vehicle-creator's existing baselibs dependency then
covers them, so the core.libraries dependency is dropped again.

Co-authored-by: mindbotbot <mindbotbot@users.noreply.github.com>
doCheckVehicle passed the scene root node as the MaVehicles chassis, so
setChassis reparented it under the vehicle's private node: the preview
went blank (the 'non-visible' geometry) and addToWorld then tried to
attach the vehicle node to itself (IllegalArgumentException: Cannot add
child to itself).

Now the vehicle gets its own chassis node and stays detached from the
scene graph while editing; the scene host is captured up front. On
'test vehicle' the edited scene root is moved under the chassis and the
vehicle is attached to the host via the captured parent; on stop the
vehicle is removed and the scene root is restored.

Co-authored-by: mindbotbot <mindbotbot@users.noreply.github.com>
…rive

Attach the vehicle node directly under the scene root node when the
vehicle is created (parent.attachChild(child)), so it is visible
immediately. Physics stays off until 'test vehicle': the BulletAppState
is attached on test and detached on stop instead of at scene open.
The EditorWorld uses the scene root node as parent directly; re-attaching
the already-attached vehicle node is a no-op and setPhysicsSpace is
idempotent, so addToWorld is safe. On stop, removeFromWorld detaches the
vehicle and it is re-attached to the scene root (visible, no physics).
sceneRoot/sceneHost fields are gone.

Co-authored-by: mindbotbot <mindbotbot@users.noreply.github.com>
Vehicle.addToWorld attaches five app states. TireSmokeEmitter casts the
application to SimpleApplication (ClassCastException under the SDK's
SceneApplication) and SkidMarksState needs a DecalManager plus the
SkidMark material, neither of which the preview provides. EditorWorld now
hands Vehicle a filtering AppStateManager that delegates to the real
state manager but never attaches those two cosmetic states.

Also set the gears' redline speeds (previously 0, which made
AutomaticGearboxState compute NaN engine revs) and name the wheel visual
'wheel' as WheelSpinState requires.

Co-authored-by: mindbotbot <mindbotbot@users.noreply.github.com>
Three fixes for the vehicle creator's test drive:

1. Place the suspension connection points at the bottom of the model's
   bounding box instead of at its center height. The wheels (0.35
   radius, 0.2 rest length) could never reach below the chassis
   collision box, so the vehicle settled on the box and the wheels spun
   without traction, making it immobile.

2. Start the test drive from the vehicle's current pose in the scene.
   MaVehicles' warp() derives the drop point from a downward ray test
   and moves the vehicle far away (about y=-9000) when nothing is below
   it. The pose captured when testing starts is now applied directly
   with warpAllBodies(), and restored when testing stops or the reset
   key is pressed (physics body, vehicle node and wheel nodes).

3. Forward keyboard input to the test drive. The embedded preview
   canvas is not focusable, so jME's InputManager never sees keyboard
   events; the scene viewer forwards them only to the active camera
   controller. The driving keys are now forwarded from Swing in the
   editor window and from the camera controller (when the scene viewer
   has focus) into the editor's input handling.

Also adds a visible box for the generated chassis and a shared
WHEEL_DIAMETER constant.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
Vendor the hatchback example from the jme-vehicles project's MavCommon
library (tag library-v0.7.2): the HatchBack vehicle with its engine,
sounds, tires and wheels, the modern_hatchback model with PBR textures,
and the engine and horn audio. The driver/passenger setup is omitted.

The editor's test-drive controls now drive the hatchback:
- S engages the reverse gear instead of sending a negative accelerate
  signal, which MaVehicles rejects; W re-engages a forward gear.
- The accelerate signal is refreshed every frame while testing and
  withdrawn at the gearbox's speed limits, as in MaVehicles' own demo,
  capping reverse at the reverse gear's top speed.
- Steering keys assign the steering value directly, so a missed key
  release can no longer leave the wheels steered.
- Stopping a test drive also re-engages a forward gear.

Also pin jme3-testdata to a version that provides the Racetrack model
used by the preview.

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
@neph1

neph1 commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Some tweaks left. Steering. Scene loading

* while the vehicles' forward is +Z, so a camera node must be flipped
* to look forward
*/
private static final Quaternion flipYaw

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This quaternion is described and used as a 180° yaw to make the dash camera look along the vehicle’s +Z forward axis, but an angle of 0 creates the identity rotation. As written, first-person mode leaves the camera facing the vehicle’s -Z direction. Could you rotate by π here?

Suggested change
private static final Quaternion flipYaw
= new Quaternion().fromAngleAxis(FastMath.PI, Vector3f.UNIT_Y);

public void setCreateNode(boolean createNode) {
this.createNode = createNode;
public void loadFromWheel(Wheel wheel) {
Suspension suspension = wheel.getSuspension();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loadFromWheel copies the other suspension settings but leaves maxTravelCm unchanged. This means loading a wheel and then applying these settings can silently replace that wheel’s travel with the default (or a stale value), rather than preserving the loaded configuration. Please load the travel value here as well, and consider round-tripping the tire coefficients for the same reason.

@jaime-jmebot jaime-jmebot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for putting together this substantial migration. Moving the editor onto MaVehicles while keeping its existing UI shell is a useful direction, and the dependency routing through baselibs is clearly motivated by the module classloader constraints. I reviewed the editor/controller changes, tuning settings, camera handling, dependency setup, and the vendored example vehicle; the CI build is still in progress, so I have not treated it as verified yet.

I found one camera behavior issue in the new first-person mode: the purported 180° yaw currently uses a zero-angle quaternion, so the camera remains pointed opposite the vehicle’s +Z forward direction. I also noted that loadFromWheel does not read back maximum suspension travel, meaning a load-and-reapply round trip can overwrite a wheel’s existing value with the settings default. I left inline comments on both points.

The separation of tuning values into SuspensionSettings and the shared application methods make the new editor model straightforward to follow. Once those round-trip and orientation details are addressed, this will be in good shape; please also check the pending CI result before merging. Thanks for the careful work on this migration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants