@@ -59,7 +59,7 @@ public class TestFancyCar extends SimpleApplication implements ActionListener {
5959 private Node carNode ;
6060
6161 public static void main (String [] args ) {
62- TestFancyCar app = new TestFancyCar ();
62+ TestFancyCar app = new TestFancyCar ();
6363 app .start ();
6464 }
6565
@@ -68,13 +68,11 @@ private void setupKeys() {
6868 inputManager .addMapping ("Rights" , new KeyTrigger (KeyInput .KEY_K ));
6969 inputManager .addMapping ("Ups" , new KeyTrigger (KeyInput .KEY_U ));
7070 inputManager .addMapping ("Downs" , new KeyTrigger (KeyInput .KEY_J ));
71- inputManager .addMapping ("Space" , new KeyTrigger (KeyInput .KEY_SPACE ));
7271 inputManager .addMapping ("Reset" , new KeyTrigger (KeyInput .KEY_RETURN ));
7372 inputManager .addListener (this , "Lefts" );
7473 inputManager .addListener (this , "Rights" );
7574 inputManager .addListener (this , "Ups" );
7675 inputManager .addListener (this , "Downs" );
77- inputManager .addListener (this , "Space" );
7876 inputManager .addListener (this , "Reset" );
7977 }
8078
@@ -86,42 +84,18 @@ public void simpleInitApp() {
8684 flyCam .setMoveSpeed (10 );
8785
8886 setupKeys ();
89- PhysicsTestHelper .createPhysicsTestWorld (rootNode , assetManager , bulletAppState .getPhysicsSpace ());
90- // setupFloor();
87+ PhysicsTestHelper .createPhysicsTestWorld (rootNode , assetManager , getPhysicsSpace ());
9188 buildPlayer ();
9289
9390 DirectionalLight dl = new DirectionalLight ();
9491 dl .setDirection (new Vector3f (-0.5f , -1f , -0.3f ).normalizeLocal ());
9592 rootNode .addLight (dl );
96-
97- dl = new DirectionalLight ();
98- dl .setDirection (new Vector3f (0.5f , -0.1f , 0.3f ).normalizeLocal ());
99- // rootNode.addLight(dl);
10093 }
10194
10295 private PhysicsSpace getPhysicsSpace () {
10396 return bulletAppState .getPhysicsSpace ();
10497 }
10598
106- // public void setupFloor() {
107- // Material mat = assetManager.loadMaterial("Textures/Terrain/BrickWall/BrickWall.j3m");
108- // mat.getTextureParam("DiffuseMap").getTextureValue().setWrap(WrapMode.Repeat);
109- //// mat.getTextureParam("NormalMap").getTextureValue().setWrap(WrapMode.Repeat);
110- //// mat.getTextureParam("ParallaxMap").getTextureValue().setWrap(WrapMode.Repeat);
111- //
112- // Box floor = new Box(Vector3f.ZERO, 140, 1f, 140);
113- // floor.scaleTextureCoordinates(new Vector2f(112.0f, 112.0f));
114- // Geometry floorGeom = new Geometry("Floor", floor);
115- // floorGeom.setShadowMode(ShadowMode.Receive);
116- // floorGeom.setMaterial(mat);
117- //
118- // PhysicsNode tb = new PhysicsNode(floorGeom, new MeshCollisionShape(floorGeom.getMesh()), 0);
119- // tb.setLocalTranslation(new Vector3f(0f, -6, 0f));
120- //// tb.attachDebugShape(assetManager);
121- // rootNode.attachChild(tb);
122- // getPhysicsSpace().add(tb);
123- // }
124-
12599 private Geometry findGeom (Spatial spatial , String name ) {
126100 if (spatial instanceof Node ) {
127101 Node node = (Node ) spatial ;
@@ -147,10 +121,9 @@ private void buildPlayer() {
147121 final float mass = 400 ;
148122
149123 //Load model and get chassis Geometry
150- carNode = (Node )assetManager .loadModel ("Models/Ferrari/Car.scene" );
124+ carNode = (Node ) assetManager .loadModel ("Models/Ferrari/Car.scene" );
151125 carNode .setShadowMode (ShadowMode .Cast );
152126 Geometry chasis = findGeom (carNode , "Car" );
153- BoundingBox box = (BoundingBox ) chasis .getModelBound ();
154127
155128 //Create a hull collision shape for the chassis
156129 CollisionShape carHull = CollisionShapeFactory .createDynamicMeshShape (chasis );
@@ -172,7 +145,7 @@ private void buildPlayer() {
172145
173146 Geometry wheel_fr = findGeom (carNode , "WheelFrontRight" );
174147 wheel_fr .center ();
175- box = (BoundingBox ) wheel_fr .getModelBound ();
148+ BoundingBox box = (BoundingBox ) wheel_fr .getModelBound ();
176149 float wheelRadius = box .getYExtent ();
177150 float back_wheel_h = (wheelRadius * 1.7f ) - 1f ;
178151 float front_wheel_h = (wheelRadius * 1.9f ) - 1f ;
@@ -228,7 +201,6 @@ else if (binding.equals("Ups")) {
228201 accelerationValue += 800 ;
229202 }
230203 player .accelerate (accelerationValue );
231- player .setCollisionShape (CollisionShapeFactory .createDynamicMeshShape (findGeom (carNode , "Car" )));
232204 } else if (binding .equals ("Downs" )) {
233205 if (value ) {
234206 player .brake (40f );
@@ -243,7 +215,6 @@ else if (binding.equals("Ups")) {
243215 player .setLinearVelocity (Vector3f .ZERO );
244216 player .setAngularVelocity (Vector3f .ZERO );
245217 player .resetSuspension ();
246- } else {
247218 }
248219 }
249220 }
0 commit comments