i implement already a small ViewPort, that give me an overview of the whole 3D-scene. Now i will implement a red rectangle in this small ViewPort like in Visio (see figure) to navigate in this overview.
How can i calculate the size and the position of the rectangle, so that it shows the current camera position in the scene. Means, i need to show with the rectangle in the small ViewPort, which part of the scene is now displaying by the camera.
You could get the frustum from the camera and calculate from that. Don’t remember from the top of my head what you need to do but if you look at the javadoc for Camera it might get you started.
the Camera has methods that returns the the position in world space of a screen coordinates position. getWorldCoordinates
And it also has a method that do that the other way around : world coordinates to screenCoordinates, getScreenCoordinates
I assume that you have another camera for your overview viewport, so what you have to do is just to compute the world coordinates of the corners of the main viewport (0,0; width,0; width,height; 0,height) and then get the screen coordinates of those position in the overview viewport with the overview Camera.
the idea with WorldCoordinates of the default camera and transformation to the ScreenCoordinates with the overview camera work for me very good.
Thanks for the support!!