3
\$\begingroup\$

I have a 3D world with some model in it (the XZ-plane grid, some gray boxes and a red box). In the upper-left corner I'm trying to draw a minimap that should represents the whole world in 2D (flat). As you can see I already achieved to draw the grid and the boxes just using their scaled position. With the same logic I drew the camera too so here's my question: how can I draw the "cone" of view for this camera? In the image below I just drew a green shape that should explain what I mean better than words (obviously the green one in the image doesn't represent the actual view for this camera, it's just an example).

map

I'm using LibGDX with a PerspectiveCamera so I got access to all the camera information like the fow, the frustum and so on. Any idea how to implement this?

\$\endgroup\$
  • \$\begingroup\$ So, just taking a mesh shaped like your camera's frustum and transforming it the same way you do for your buildings didn't work? Can you show what the symptoms are when you try that? It might help us diagnose which step is going wrong. \$\endgroup\$ – DMGregory Aug 6 '17 at 11:52
1
\$\begingroup\$

I'm using LibGDX with a PerspectiveCamera so I got access to all the camera information like the fow, the frustum and so on. Any idea how to implement this?

To get the cone, you need to know the horizontal field of view of your 3D camera. If you have that, you just need to take the vector representing the direction in your 2D minimap and add half the field of view to it to get one side and subtract half the field of view to get the other size. Use the near and far plane of the frustum to show how far it extends.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Simply explained and without code, you can get the normalized direction vector of the camera and just convert it to minimap's position exactly the same way you do with the rest of objects.

You have camera position, so you can place your camera in the right point of the minimap.

Then, you use it's direction vector to align/rotate a sprite which would represent that cone of view.

Does it help?

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.