Strategy game camera

Hello everyone.



I'm currently working on some kind of strategy game. My idea was to have a camera that moves along a dome. The camera position is defined by two angles and the distance from the center of the world, because the camera always looks at (0;0;0). This might change later. I now have to restrict the camera not to move up to (0;distance;0) because that is where it flips over and I also need to have a limit, so that it cannot look at the world from below.



My first approach was mostly vector-algebra based and didn't seem to work at all. I then thought about using lookAt, but the camera acts kinda strange.



Here is the code (the constraints are still missing):

      // Position on the sphere

      Vector3f pos = new Vector3f((float)(distance * Math.sin(angleX) * Math.cos(angleY)),

            (float)(distance * Math.sin(angleX) * Math.sin(angleY)),

            (float)(distance * Math.cos(angleX)));

      // Update the camera

      cam.setLocation(pos);

      cam.lookAt(new Vector3f(), new Vector3f(0.0f, 1.0f, 0.0f));

      cam.update();      



Is there maybe another camera class, that could deal with this problems easier?



thank you.

Hmm,…for that I could give you the hint that there is already a strategichandler that was made for your case. But that is an addon and not part of jME.



Have a look here:



http://www.jmonkeyengine.com/wiki/doku.php?id=strategichandler

I just tried the demo. This is very promissing. Thanks a lot  :smiley: