Okay … for the rotation problem … here’s my rotation code.
//shipObj is our PhysicsObject
public void performAction(InputActionEvent evt) {
Quaternion temp = new Quaternion(shipObj.getjMEGeometry().getLocalRotation());
incr.loadIdentity();
if (lockAxis == null) {
incr.fromAxisAngle(shipObj.getjMEGeometry().getLocalRotation().getRotationColumn(1,
tempVa), -speed * evt.getTime());
} else {
incr.fromAxisAngle(lockAxis, -speed * evt.getTime());
}
shipObj.getjMEGeometry().getLocalRotation().fromRotationMatrix(
incr.mult(shipObj.getjMEGeometry().getLocalRotation().toRotationMatrix(tempMa),
tempMb));
shipObj.getjMEGeometry().getLocalRotation().normalize();
shipObj.syncToGraphical(false);
}
The above code is pretty much taken verbatim from Mojo's KeyNodeRotateRightAction class.
Here's my simpleInitGame() class
protected void simpleInitGame() {
// Set up the PhysicsWorld. It's set with default values, e.g. Earths
// gravity.
PhysicsWorld.create();
PhysicsWorld.getInstance().setGravity(new Vector3f(0,0,0));
// Here we tell the PhysicsWorld how many times per second we would like to
// update it. It'll make the PhysicsWorlds internal timer govern the frequency
// of update calls, thus obtaining frame rate independance. We set it to
// 100 updates per second - the default is no restriction.
PhysicsWorld.getInstance().setUpdateRate(100);
// Here we tell the PhysicsWorld how much should change with each update.
// A bigger value = faster animation. A step size of 2/UPS (updates/sec)
// seem to give a rather nice simulation/result.
PhysicsWorld.getInstance().setStepSize(2/100f);
// Create a PhysicsObject from it. Note that we pass a mass by 1, thus making
// it dynamic.
shipObj = new PhysicsObject(ship, 50f);
lightState.setEnabled(false);
Map map = new Map(display);
// Add the graphical representations to the rootNode. You can also get
// a reference to it by calling PhysicsObject.getjMEGeometry().
rootNode.attachChild(ship);
rootNode.attachChild(map);
// And the physical representations to the PhysicsWorld.
PhysicsWorld.getInstance().addObject(shipObj);
//Pass a reference to the input handlers for the ship so they can manipulate the geometry and forces
shipMovementInput.init(shipObj);
}
finally here's my update method
protected final void update(float interpolation) {
/** Recalculate the framerate. */
timer.update();
/** Update tpf to time per frame according to the Timer. */
tpf = timer.getTimePerFrame();
/** Check for key/mouse updates. */
shipMovementInput.update(tpf);
keyInput.update(tpf);
//Update Physics Objects
PhysicsWorld.getInstance().update();
updateBuffer.setLength(0);
updateBuffer.append("FPS: ").append((int)timer.getFrameRate()).append(" - ");
updateBuffer.append(display.getRenderer().getStatistics(tempBuffer));
/** Send the fps to our fps bar at the bottom. */
fps.print(updateBuffer);
//Move camera above the ship
cam.setLocation(new Vector3f(ship.getLocalTranslation().x, 40, ship.getLocalTranslation().z));
/** Update controllers/render states/transforms/bounds for rootNode. */
rootNode.updateGeometricState(tpf, true);
//Checks to see if any keys have been pressed in the key binding manager
checkKeyBindingManager();
}
Changing to synchToGraphical(true) isn't what I want since that will reset all the forces acting on the ship. That means whenever you turn, your ship screeches to a halt. With the current terminal velocity being seemingly close to the speed of light if you're gonna turn you'd better have your seat belt on. ;)
I'll give your suggestion for the terminal velocity a shot and will be sure to let you know how it goes.
By the way ... great work with the Physics stuff. Even with the problems it's been a breeze to use so far and my code will be much cleaner. [/code]