hi,
I've tried to integrate some physics in the flag rush Tutorial just for training. But I don't know why it doesn't work. May you help me? This is my code (Lesson 7, buildPlayer(), but I think there is everything in it you need to know…)
Node model = null;
try {
MaxToJme C1 = new MaxToJme();
ByteArrayOutputStream BO = new ByteArrayOutputStream();
URL maxFile = TestTerrain.class.getClassLoader().getResource("bike.3ds");
C1.convert(new BufferedInputStream(maxFile.openStream()),BO);
JmeBinaryReader jbr = new JmeBinaryReader();
jbr.setProperty("bound", "box");
model = jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
//scale it to be MUCH smaller than it is originally
model.setLocalScale(.0025f);
} catch (IOException e) {
e.printStackTrace();
}
//set the vehicles attributes (these numbers can be thought
//of as Unit/Second).
player = new Vehicle("Player Node", model);
//...think you don't need this stuff...
player.setWeight(25);
//...think you don't need this stuff...
player.setLocalTranslation(new Vector3f(100,0, 100));
scene.attachChild(player);
scene.updateGeometricState(0, true);
player.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
PhysicsObject plpo=new DynamicPhysicsObject(player, player.getWeight()); //line 266
physics.addObject(plpo);
player is extends Node...
This throws a ClassCastException:
java.lang.ClassCastException: com.jme.bounding.BoundingBox
at com.jmex.physics.PhysicsWorld.createNode(PhysicsWorld.java:463)
at com.jmex.physics.PhysicsWorld.createPhysicalEntity(PhysicsWorld.java:366)
at com.jmex.physics.DynamicPhysicsObject.<init>(DynamicPhysicsObject.java:86)
at Lesson7.buildPlayer(Lesson7.java:266)
at Lesson7.initGame(Lesson7.java:215)
at com.jme.app.BaseGame.start(Unknown Source)
at Lesson7.main(Lesson7.java:76)
Thanks for help,
campino