What's the equivalent of the following code (your car example's camera) for a game on the X/Y plane? I tried switching the Zs and Ys around, but I get weird results. For one thing, my game is of a ship with greater maneuverability than the car and the camera sometimes ends on opposite sides of the ship (sometimes it's under it, sometimes over it).
private void moveCamera() {
SimpleVector oldCamPos=camera.getPosition();
SimpleVector oldestCamPos=new SimpleVector(oldCamPos);
oldCamPos.scalarMul(9f);
SimpleVector carCenter=car.getTransformedCenter();
SimpleVector camPos=new SimpleVector(carCenter);
SimpleVector zOffset=car.getZAxis();
SimpleVector yOffset=new SimpleVector(0, -100, 0);
zOffset.scalarMul(-250f);
camPos.add(zOffset);
camPos.add(yOffset);
camPos.add(oldCamPos);
camPos.scalarMul(0.1f);
SimpleVector delta=camPos.calcSub(oldestCamPos);
float len=delta.length();
if (len!=0) {
/**
* Do a collision detection between the camera and the ground to prevent the camera from
* moving into the ground.
*/
theWorld.checkCameraCollisionEllipsoid(delta.normalize(), new SimpleVector(20, 20, 20), len, 3);
}
/**
* And finally: Look at the car
*/
camera.lookAt(car.getTransformedCenter());
}