| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- #pragma once
- #include "WallpaperEngine/Render/Wallpapers/CScene.h"
- #include <glm/mat4x4.hpp>
- #include <glm/vec2.hpp>
- #include <glm/vec3.hpp>
- #include "WallpaperEngine/Data/Model/Wallpaper.h"
- namespace WallpaperEngine::Render::Wallpapers {
- class CScene;
- }
- namespace WallpaperEngine::Render {
- using namespace WallpaperEngine::Data::Model;
- class Camera {
- public:
- Camera (Wallpapers::CScene& scene, const SceneData::Camera& camera);
- ~Camera ();
- // width/height is the layout objects are positioned in, canvas the rendered size centered on it (0 = layout size)
- void setOrthogonalProjection (float width, float height, float canvasWidth = 0.0f, float canvasHeight = 0.0f);
- // 3D scenes: the scene camera becomes perspective, getProjection/getLookAt stay screen space for 2D layers
- void setPerspectiveProjection (float width, float height);
- [[nodiscard]] const glm::vec3& getCenter () const;
- [[nodiscard]] const glm::vec3& getEye () const;
- [[nodiscard]] const glm::vec3& getConfiguredEye () const;
- [[nodiscard]] const glm::vec3& getUp () const;
- [[nodiscard]] const glm::mat4& getProjection () const;
- [[nodiscard]] const glm::mat4& getLookAt () const;
- [[nodiscard]] const glm::mat4& getFullscreenProjection () const;
- [[nodiscard]] Wallpapers::CScene& getScene () const;
- [[nodiscard]] bool isOrthogonal () const;
- [[nodiscard]] bool isPerspective () const;
- [[nodiscard]] const glm::mat4& getPerspective () const;
- [[nodiscard]] const glm::mat4& getView () const;
- [[nodiscard]] float getWidth () const;
- [[nodiscard]] float getHeight () const;
- [[nodiscard]] float getCanvasWidth () const;
- [[nodiscard]] float getCanvasHeight () const;
- [[nodiscard]] float getFov () const;
- [[nodiscard]] float getNearZ () const;
- [[nodiscard]] float getFarZ () const;
- // per frame view from a camera object in WE's world space (y up, origin bottom left); identity without one in 2D
- void setWorldView (const glm::mat4& view);
- /** 2D scenes: general zoom times the camera object's zoom, scales around the scene center (sub_14017FA70) */
- void setZoom (float zoom);
- void setPerspectiveView (const glm::mat4& view, float fov);
- [[nodiscard]] const glm::mat4& getWorldView () const;
- [[nodiscard]] float getViewFov () const;
- // the canvas part the output shows as margins (left, right, bottom, top, y up, negative for letterboxing) and its
- // aspect; 2D scenes project it onto the scene buffer (sub_140183A70), 3D ones use the aspect; also rebuilds
- // "perspective" layers (sub_1401E5B60)
- void setVisibleRegion (const glm::vec4& margins, float outputAspect);
- void updatePerspectiveLayers ();
- /** View projection of "perspective" layers, same space as getProjection () * getLookAt () in 2D scenes, WE's world
- * in 3D ones */
- [[nodiscard]] const glm::mat4& getPerspectiveLayerViewProjection () const;
- private:
- float m_width;
- float m_height;
- glm::vec3 m_eye;
- float m_canvasWidth = 0.0f;
- float m_canvasHeight = 0.0f;
- bool m_isOrthogonal = false;
- bool m_isPerspective = false;
- glm::mat4 m_perspective = {};
- glm::mat4 m_view = {};
- glm::mat4 m_projection = {};
- glm::mat4 m_lookat = {};
- glm::mat4 m_worldView = glm::mat4 (1.0f);
- glm::mat4 m_orthogonal = {};
- glm::mat4 m_fullscreen = {};
- glm::vec4 m_margins = {};
- float m_outputAspect = 0.0f;
- float m_zoom = 1.0f;
- float m_viewFov = 0.0f;
- glm::mat4 m_perspectiveLayer = {};
- const SceneData::Camera& m_camera;
- Wallpapers::CScene& m_scene;
- };
- }
|