From 3e0b838324586f123d81404924b68a728b2ddf73 Mon Sep 17 00:00:00 2001 From: Dokthar Date: Sat, 12 Mar 2016 13:50:26 +0100 Subject: [PATCH 1/2] fix NPE when launching the hovering test with native bullet --- .../src/main/java/jme3test/bullet/PhysicsHoverControl.java | 2 +- .../src/main/java/jme3test/bullet/TestHoveringTank.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java b/jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java index 922a7217d..b683b122d 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java +++ b/jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java @@ -94,7 +94,6 @@ public class PhysicsHoverControl extends PhysicsVehicle implements PhysicsContro createWheels(); } - @Override public Control cloneForSpatial(Spatial spatial) { throw new UnsupportedOperationException("Not supported yet."); } @@ -180,6 +179,7 @@ public class PhysicsHoverControl extends PhysicsVehicle implements PhysicsContro } public void setPhysicsSpace(PhysicsSpace space) { + createVehicle(space); if (space == null) { if (this.space != null) { this.space.removeCollisionObject(this); diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java b/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java index 5f058e68b..dea5325eb 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java +++ b/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java @@ -147,13 +147,13 @@ public class TestHoveringTank extends SimpleApplication implements AnalogListene spaceCraft.setLocalRotation(new Quaternion(new float[]{0, 0.01f, 0})); hoverControl = new PhysicsHoverControl(colShape, 500); - hoverControl.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02); spaceCraft.addControl(hoverControl); rootNode.attachChild(spaceCraft); getPhysicsSpace().add(hoverControl); + hoverControl.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_02); ChaseCamera chaseCam = new ChaseCamera(cam, inputManager); spaceCraft.addControl(chaseCam); @@ -168,7 +168,7 @@ public class TestHoveringTank extends SimpleApplication implements AnalogListene Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml"); missile.scale(0.5f); - missile.rotate(0, FastMath.PI, 0); + missile.rotate(FastMath.PI, FastMath.PI, 0); missile.updateGeometricState(); BoundingBox box = (BoundingBox) missile.getWorldBound(); From d9f489d8ddedde9620b7c9d0d773322d099598ec Mon Sep 17 00:00:00 2001 From: Dokthar Date: Sat, 12 Mar 2016 13:55:39 +0100 Subject: [PATCH 2/2] removed unnecessary changes --- .../src/main/java/jme3test/bullet/PhysicsHoverControl.java | 1 + .../src/main/java/jme3test/bullet/TestHoveringTank.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java b/jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java index b683b122d..9cd1849a0 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java +++ b/jme3-examples/src/main/java/jme3test/bullet/PhysicsHoverControl.java @@ -94,6 +94,7 @@ public class PhysicsHoverControl extends PhysicsVehicle implements PhysicsContro createWheels(); } + @Override public Control cloneForSpatial(Spatial spatial) { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java b/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java index dea5325eb..d1def4203 100644 --- a/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java +++ b/jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java @@ -168,7 +168,7 @@ public class TestHoveringTank extends SimpleApplication implements AnalogListene Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml"); missile.scale(0.5f); - missile.rotate(FastMath.PI, FastMath.PI, 0); + missile.rotate(0, FastMath.PI, 0); missile.updateGeometricState(); BoundingBox box = (BoundingBox) missile.getWorldBound();