![]() |
vkmEngine 1.0.15
A C++ game engine · vkmengine.com
|
The 3D view a game draws through: where it sits in the window, and the scene's active camera filling it. More...
#include <screen_view.h>
Public Member Functions | |
| std::optional< Math::Ray > | rayThrough (const glm::vec2 &windowPoint) const |
| The ray from the camera through a point of the window. | |
| std::optional< glm::vec2 > | toCanvas (const glm::vec3 &world, const UICanvas &canvas) const |
| Where a point of the world lands on a canvas, in the canvas's own pixels. | |
Static Public Member Functions | |
| static ScreenView | of (const Scene &scene, const WindowManager &window, const HostChrome &chrome) |
| The view as it stands now. | |
The 3D view a game draws through: where it sits in the window, and the scene's active camera filling it.
What a game needs to turn the pointer into a ray into the world, or a point of the world into a place on a canvas, the way the renderer and the UI themselves see them. The view is the HostChrome's rect, not the window: in the editor's Play panel the two differ, and a game that divided by the window would pick beside the cursor and draw its labels off their targets. A host's own view (HostView) is the host's, and not asked.
|
static |
The view as it stands now.
| scene | Where the active camera is (findActiveCamera). |
| window | The window drawn into; its framebuffer scale converts the pointer. |
| chrome | The host's rect for the scene inside it. |
| std::optional< Math::Ray > Vkm::Engine::ScreenView::rayThrough | ( | const glm::vec2 & | windowPoint | ) | const |
The ray from the camera through a point of the window.
| windowPoint | In window pixels, as InputMap::pointer() reports the cursor. |
| std::optional< glm::vec2 > Vkm::Engine::ScreenView::toCanvas | ( | const glm::vec3 & | world, |
| const UICanvas & | canvas ) const |
Where a point of the world lands on a canvas, in the canvas's own pixels.
Those are the units a UIElement inside it is placed in, measured from the canvas's top left, so an element anchored there at this offset sits over the point.
| world | The point. |
| canvas | The canvas, whose scaling the answer is in. |