@@ -59,7 +59,7 @@ public class TestFancyCar extends SimpleApplication implements ActionListener {
59
59
private Node carNode ;
60
60
61
61
public static void main (String [] args ) {
62
- TestFancyCar app = new TestFancyCar ();
62
+ TestFancyCar app = new TestFancyCar ();
63
63
app .start ();
64
64
}
65
65
@@ -68,13 +68,11 @@ private void setupKeys() {
68
68
inputManager .addMapping ("Rights" , new KeyTrigger (KeyInput .KEY_K ));
69
69
inputManager .addMapping ("Ups" , new KeyTrigger (KeyInput .KEY_U ));
70
70
inputManager .addMapping ("Downs" , new KeyTrigger (KeyInput .KEY_J ));
71
- inputManager .addMapping ("Space" , new KeyTrigger (KeyInput .KEY_SPACE ));
72
71
inputManager .addMapping ("Reset" , new KeyTrigger (KeyInput .KEY_RETURN ));
73
72
inputManager .addListener (this , "Lefts" );
74
73
inputManager .addListener (this , "Rights" );
75
74
inputManager .addListener (this , "Ups" );
76
75
inputManager .addListener (this , "Downs" );
77
- inputManager .addListener (this , "Space" );
78
76
inputManager .addListener (this , "Reset" );
79
77
}
80
78
@@ -86,42 +84,18 @@ public void simpleInitApp() {
86
84
flyCam .setMoveSpeed (10 );
87
85
88
86
setupKeys ();
89
- PhysicsTestHelper .createPhysicsTestWorld (rootNode , assetManager , bulletAppState .getPhysicsSpace ());
90
- // setupFloor();
87
+ PhysicsTestHelper .createPhysicsTestWorld (rootNode , assetManager , getPhysicsSpace ());
91
88
buildPlayer ();
92
89
93
90
DirectionalLight dl = new DirectionalLight ();
94
91
dl .setDirection (new Vector3f (-0.5f , -1f , -0.3f ).normalizeLocal ());
95
92
rootNode .addLight (dl );
96
-
97
- dl = new DirectionalLight ();
98
- dl .setDirection (new Vector3f (0.5f , -0.1f , 0.3f ).normalizeLocal ());
99
- // rootNode.addLight(dl);
100
93
}
101
94
102
95
private PhysicsSpace getPhysicsSpace () {
103
96
return bulletAppState .getPhysicsSpace ();
104
97
}
105
98
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
-
125
99
private Geometry findGeom (Spatial spatial , String name ) {
126
100
if (spatial instanceof Node ) {
127
101
Node node = (Node ) spatial ;
@@ -147,10 +121,9 @@ private void buildPlayer() {
147
121
final float mass = 400 ;
148
122
149
123
//Load model and get chassis Geometry
150
- carNode = (Node )assetManager .loadModel ("Models/Ferrari/Car.scene" );
124
+ carNode = (Node ) assetManager .loadModel ("Models/Ferrari/Car.scene" );
151
125
carNode .setShadowMode (ShadowMode .Cast );
152
126
Geometry chasis = findGeom (carNode , "Car" );
153
- BoundingBox box = (BoundingBox ) chasis .getModelBound ();
154
127
155
128
//Create a hull collision shape for the chassis
156
129
CollisionShape carHull = CollisionShapeFactory .createDynamicMeshShape (chasis );
@@ -172,7 +145,7 @@ private void buildPlayer() {
172
145
173
146
Geometry wheel_fr = findGeom (carNode , "WheelFrontRight" );
174
147
wheel_fr .center ();
175
- box = (BoundingBox ) wheel_fr .getModelBound ();
148
+ BoundingBox box = (BoundingBox ) wheel_fr .getModelBound ();
176
149
float wheelRadius = box .getYExtent ();
177
150
float back_wheel_h = (wheelRadius * 1.7f ) - 1f ;
178
151
float front_wheel_h = (wheelRadius * 1.9f ) - 1f ;
@@ -228,7 +201,6 @@ else if (binding.equals("Ups")) {
228
201
accelerationValue += 800 ;
229
202
}
230
203
player .accelerate (accelerationValue );
231
- player .setCollisionShape (CollisionShapeFactory .createDynamicMeshShape (findGeom (carNode , "Car" )));
232
204
} else if (binding .equals ("Downs" )) {
233
205
if (value ) {
234
206
player .brake (40f );
@@ -243,7 +215,6 @@ else if (binding.equals("Ups")) {
243
215
player .setLinearVelocity (Vector3f .ZERO );
244
216
player .setAngularVelocity (Vector3f .ZERO );
245
217
player .resetSuspension ();
246
- } else {
247
218
}
248
219
}
249
220
}
0 commit comments