Hi guys,
I’m having some kind of problem with my camera handled by a FirstPersonHandler. When I start my app everything looks just fine - my camera starts at my default position with default orientation etc. and there’s no problem moving around.
But when I save my camera location, direction, left and up vectors, set everything back to default (after setting it to default it works fine) and then setting it back to my saved vectors (i use .clone() every time) it’s like my whole scene is rotated. Viewport shows just the right stuff, but when I start moving after setting camera to my saved values it looks like the scene was rotated to get the right view and not the camera, if you know what I mean.
Start at default position:
Switching to new position:
After saving camera parameters, loading them again and going manually back to the start position:
I think it’s not a big problem, but I just don’t get it…
My default values (got them via System.out.println after getting to a good starting position) and my first camera setup:
private final Vector3f DEFAULT_LOCATION = new Vector3f(7.8894286f, 2.4855723f, -22.402708f);
private final Vector3f DEFAULT_DIRECTION = new Vector3f(-0.08299516f, 0.051177584f, 0.995235f);
private final Vector3f DEFAULT_LEFT = new Vector3f(0.9965409f, 1.7462298E-10f, 0.083104104f);
private final Vector3f DEFAULT_UP = new Vector3f(0.0042530587f, 0.9986896f, 0.05100064f);
mainCam.setFrame(DEFAULT_LOCATION.clone(),DEFAULT_LEFT.clone(),DEFAULT_UP.clone(),DEFAULT_DIRECTION.clone());
mainCam.setFrustumPerspective(45.0f, (float) width / (float) height, 1,10000);
mainCam.update();
And at least my saving and re-loading code (lastView & activeView having local Vector3f's for saving cam parameters):
lastView.setCamDirection(mainCam.getDirection().clone());
lastView.setCamLeft(mainCam.getLeft().clone());
lastView.setCamUp(mainCam.getUp().clone());
lastView.setCamLocation(mainCam.getLocation().clone());
mainCam.setFrame(activeView.getCamLocation().clone(),
activeView.getCamLeft().clone(),
activeView.getCamUp().clone(),
activeView.getCamDirection().clone());
mainCam.update();
P.S.: Just a little sample scene again, but same prob with my real scene.
P.P.S.: Thanks for reading so far and for maybe solving my problem. XD