So I’m currently trying to implement a minimap into my design, and it mostly works. I have the viewports set up, and it successfully moves around a birds eye view of the scene. I have a few things I need help with :
How do I draw a circle, or dot or some kind of graphics on the small mini map where the player currently is?
The viewport is in 3D so when moving around mini map it changes slightly in a 3D way. How would I make this 2D?
When I spin round (camera wise) I want the viewport camera to also spin round, but not when I look up or down. WHat quarternion/vectors would I need?
The mini-map in my game has its own scene graph and render. This makes it easy to include object not present in the main scene. Perhaps this approach would work for you.
Another possibility would be to place a marker at the desired screen location using the guiViewPort.
To change the scale of the view, you would change the top, bottom, left, and right planes of the camera’s frustrum. The JME3 interface for doing this is somewhat awkward. You could use this utility I wrote:
[java]
/**
* Increase a camera’s field-of-view tangent by a specified factor.
*
* @param camera camera to alter (not null)
* @param factor amount to reduce the FOV tangent (>0)
*/
public static void zoom(Camera camera, float factor) {
float bottom = camera.getFrustumBottom();
camera.setFrustumBottom(bottom * factor);
float left = camera.getFrustumLeft();
camera.setFrustumLeft(left * factor);
float right = camera.getFrustumRight();
camera.setFrustumRight(right * factor);
float top = camera.getFrustumTop();
camera.setFrustumTop(top * factor);
}
[/java]
Just realised - the mini map is rectangular instead of square? I was playing around with getting the scene size,and it’s 128x128, which confused me as the birds eye view shows it all as rectangular? Ideas?
If the map is a viewport, its dimensions (relative to the main window) are specified using Camera.setViewPort(). If the proportions of object rendered by the camera are squashed, you probably need to adjust the camera frustum’s top and bottom relative to its left and right.