#pragma once #include 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