vkmEngine 1.0.15
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
Vkm::Engine::ScreenView Class Reference

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.

Detailed Description

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.

Member Function Documentation

◆ of()

ScreenView Vkm::Engine::ScreenView::of ( const Scene & scene,
const WindowManager & window,
const HostChrome & chrome )
static

The view as it stands now.

Parameters
sceneWhere the active camera is (findActiveCamera).
windowThe window drawn into; its framebuffer scale converts the pointer.
chromeThe host's rect for the scene inside it.
Returns
A view; valid() is false with no camera or an empty rect.

◆ rayThrough()

std::optional< Math::Ray > Vkm::Engine::ScreenView::rayThrough ( const glm::vec2 & windowPoint) const

The ray from the camera through a point of the window.

Parameters
windowPointIn window pixels, as InputMap::pointer() reports the cursor.
Returns
The ray, its origin on the near plane; nothing when the point is outside the view or there is no view.

◆ toCanvas()

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.

Parameters
worldThe point.
canvasThe canvas, whose scaling the answer is in.
Returns
The place; nothing for a point behind the camera, or with no view.

The documentation for this class was generated from the following file: