Program Listing for File SceneFraming.ixx#
↰ Return to documentation for file (Src/GraphicsEngineVulkan/scene/SceneFraming.ixx)
module;
#include <glm/glm.hpp>
#include <optional>
#include <string>
#include <vector>
export module kataglyphis.vulkan.scene_framing;
export namespace Kataglyphis {
struct SceneCamera
{
std::string name;
glm::vec3 eye{ 0.0F };
glm::vec3 forward{ 0.0F, 0.0F, -1.0F };
float yfovRadians = 0.0F;
};
struct SceneBounds
{
bool valid = false;
glm::vec3 min{ 0.0F };
glm::vec3 max{ 0.0F };
};
struct SceneMetadata
{
std::vector<SceneCamera> cameras;
int activeCamera = -1;
std::string credit;
SceneBounds bounds;
};
struct CameraPose
{
glm::vec3 eye{ 0.0F };
float yaw = -90.0F;
float pitch = 0.0F;
float fov = 45.0F;
float nearPlane = 0.1F;
float farPlane = 100.0F;
float movementSpeed = 10.0F;
float shadowDistance = 60.0F;
};
enum class FramingSource : int {
FixedPose = 0,
ActiveCamera = 1,
FirstCamera = 2,
Bounds = 3,
};
struct SceneFraming
{
bool framed = false;
FramingSource source = FramingSource::FixedPose;
CameraPose pose;
};
SceneFraming frameScene(const SceneMetadata &metadata, const CameraPose &fixed);
std::optional<CameraPose> startPose(const SceneFraming &framing, const CameraPose &fixed, bool previousFramed)
{
if (framing.framed) { return framing.pose; }
if (previousFramed) { return fixed; }
return std::nullopt;
}
}// namespace Kataglyphis