- BillboardInstance: per-instance uv sub-rect, feet anchor, turn, dithered alpha, flash; BillboardBatch::sharedTexture; Texture createEmpty/update/cellUV/cellAnchor/nearest - SpriteAtlas: fixed-cell runtime atlas with gutters - hd2d::ui: Octopath-style panels, fonts (Cinzel, EB Garamond), dialogue box with typewriter + portraits + choices, menus, nameplates, toasts, ImGui theme - DayCycle (dawn/day/dusk/night keyframes, sun + moon arcs), Weather overcast/mist/ lightning, night-aware presets, stars and moon in the sky - Hidden-window offscreen captures (Window visible=false, Renderer output FBO, OffscreenTarget); --screenshot never opens a window - Camera::worldToScreen; CMake usable via add_subdirectory (HD2D_BUILD_DEMO, HD2D_ENGINE_ASSET_DIR)
29 lines
1.1 KiB
C++
29 lines
1.1 KiB
C++
#pragma once
|
|
#include <glm/glm.hpp>
|
|
|
|
namespace hd2d {
|
|
|
|
// Orbit camera looking at `target`. HD-2D scenes use a high, narrow-FOV
|
|
// (near telephoto) camera tilted down so the world reads like a diorama.
|
|
struct Camera {
|
|
glm::vec3 target{0.0f};
|
|
float yaw = 0.0f; // radians; 0 looks toward -Z
|
|
float pitch = 0.56f; // radians below horizon
|
|
float distance = 17.0f;
|
|
float fovY = 0.52f; // radians (~30 deg)
|
|
float nearPlane = 0.5f;
|
|
float farPlane = 250.0f;
|
|
|
|
glm::vec3 forward() const; // unit vector camera -> target
|
|
glm::vec3 position() const { return target - forward() * distance; }
|
|
glm::vec3 right() const; // horizontal right vector
|
|
glm::mat4 view() const;
|
|
glm::mat4 projection(float aspect) const;
|
|
// Projects `world` to window pixels (top-left origin) of a `viewportPx`
|
|
// viewport, using view() and projection(viewportPx.x / viewportPx.y).
|
|
// Returns false (outPx untouched) when the point is behind the camera.
|
|
bool worldToScreen(const glm::vec3& world, glm::vec2 viewportPx, glm::vec2& outPx) const;
|
|
};
|
|
|
|
} // namespace hd2d
|