fix for issue #1127 ("Reset" action in TestHoveringTank)

accellbaker
Stephen Gold 6 years ago
parent a4b22e4b37
commit a91bcfd678
  1. 21
      jme3-examples/src/main/java/jme3test/bullet/TestHoveringTank.java

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2012 jMonkeyEngine
* Copyright (c) 2009-2019 jMonkeyEngine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -80,6 +80,15 @@ public class TestHoveringTank extends SimpleApplication implements AnalogListene
PointLight pl;
Geometry lightMdl;
Geometry collisionMarker;
/**
* initial location of the tank (in world/physics-space coordinates)
*/
final private Vector3f startLocation = new Vector3f(-140f, 50f, -23f);
/**
* initial orientation of the tank (in world/physics-space coordinates)
*/
final private Quaternion startOrientation
= new Quaternion(new float[]{0f, 0.01f, 0f});
public static void main(String[] args) {
TestHoveringTank app = new TestHoveringTank();
@ -143,8 +152,8 @@ public class TestHoveringTank extends SimpleApplication implements AnalogListene
spaceCraft = assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
CollisionShape colShape = CollisionShapeFactory.createDynamicMeshShape(spaceCraft);
spaceCraft.setShadowMode(ShadowMode.CastAndReceive);
spaceCraft.setLocalTranslation(new Vector3f(-140, 50, -23));
spaceCraft.setLocalRotation(new Quaternion(new float[]{0, 0.01f, 0}));
spaceCraft.setLocalTranslation(startLocation);
spaceCraft.setLocalRotation(startOrientation);
hoverControl = new PhysicsHoverControl(colShape, 500);
@ -206,8 +215,10 @@ public class TestHoveringTank extends SimpleApplication implements AnalogListene
} else if (binding.equals("Reset")) {
if (value) {
System.out.println("Reset");
hoverControl.setPhysicsLocation(new Vector3f(-140, 14, -23));
hoverControl.setPhysicsRotation(new Matrix3f());
hoverControl.setPhysicsLocation(startLocation);
hoverControl.setPhysicsRotation(startOrientation);
hoverControl.setAngularVelocity(Vector3f.ZERO);
hoverControl.setLinearVelocity(Vector3f.ZERO);
hoverControl.clearForces();
} else {
}

Loading…
Cancel
Save