Hello I have a space ship facing in a particular direction.
The spaceship responds to up/down, left/right and roll left/right.
I have added a chasecam but I want to fix it so that it looks in the direction which the spaceship is travelling - a sort of padlock view.
How do I go about this??
thanks as I am really stumped !
Ok … for once I found my solution myself … chasecam was not the thing I wanted it was a CameraNode:
[java]
camNode = new CameraNode("CamNode", cam);
camNode.setControlDir(ControlDirection.SpatialToCamera);
ship.attachChild(camNode);
camNode.setLocalTranslation(new Vector3f(0, 0, -2));
camNode.lookAt(ship.getLocalTranslation(), Vector3f.UNIT_Z);
[/java]
Just an update in case anyone is interested. I had a lot of bother with the camera distorting the view and (eventually) tracked it down to the up vector that I was setting the camera.
[java]
camNode = new CameraNode("CamNode", cam);
camNode.setControlDir(ControlDirection.SpatialToCamera);
camNode.setLocalTranslation(new Vector3f(0, 0, 0));
camNode.lookAt(pc.getFacing(), Vector3f.UNIT_Y);
ship.attachChild(camNode);
[/java]
I was using Z and not Y.
the getFacing() method is simply:
[java]
public Vector3f getFacing() {
return shipControl.getPhysicsRotationMatrix().getColumn(2).normalize();
}
[/java]