I am working on a RTS/Citybuilder game and today I added a minimap to the game. The map itself works but it is not that helpful if you cant see where on this map the camera is. What I want is a way to mark the visible terrain on the minimap (which has changing sizes since the camera’s rotation is not fixed) that is not too heavy for the performance.
In one sentence: What’s the best way to find out if a position (Vector3f) is inside the camera frustrum?
Is there a way to use Spatial.getCulling(Camera) for this? I thought of creating a massive amount of invisible Spatials over the map but this did not sound like a very good idea to me… I am pretty sure someone has done this before and might share his way to do it I Did this with a 2D game before but there I did no have the problem with camera rotation (around x and y axis).
Just as an add, i am not sure what you actually need. but you might come away cheaper if you go the opposite way.
*Calculate the 8 world positions of the camera frustum.
At least that would keep the cost constant and might give you all required informations you need to draw a frustum like object on the minimap
I assume you want something like: (the yellow trapezoid) ?
That’s indeed what I want. The camera frustrum thing was the first I tried but I did not work as I expected it. Biggest problem is that I have a variable terrain height and so I don’t have collision if the map borders are visible. The ability to rotate the camera in two different axes did not make it easier… Since the way I have now has no feelable impact on the performance I guess I leave it like that for now. Maybe I will look on it later…