#ifndef CAMERA_H #define CAMERA_H #include "Component.h" #include #include #include // A simple Camera component that inherits from Component. class Camera : public Component { public: Camera(); virtual ~Camera(); // Override update (if needed, e.g. for smoothing or input handling). virtual void Update(float deltaTime) override; // Set the camera's position. void SetPosition(const glm::vec3& pos); // Set the camera's rotation in degrees. void SetRotation(float yaw, float pitch); // Get the view matrix calculated from position and rotation. glm::mat4 GetViewMatrix() const; // Get the projection matrix. glm::mat4 GetProjectionMatrix() const; // Set perspective projection parameters. void SetPerspective(float fov, float aspect, float nearPlane, float farPlane); // Getters. glm::vec3 GetPosition() const; float GetYaw() const; float GetPitch() const; // Save the camera state to a YAML node. virtual YAML::Node Save() const override { YAML::Node node; node["position"] = YAML::Node(); node["position"].push_back(position.x); node["position"].push_back(position.y); node["position"].push_back(position.z); node["yaw"] = yaw; node["pitch"] = pitch; node["fov"] = fov; node["aspect"] = aspect; node["nearPlane"] = nearPlane; node["farPlane"] = farPlane; return node; } // Load the camera state from a YAML node. virtual void Load(const YAML::Node &node) override { if (node["position"]) { position.x = node["position"][0].as(); position.y = node["position"][1].as(); position.z = node["position"][2].as(); } if (node["yaw"]) yaw = node["yaw"].as(); if (node["pitch"]) pitch = node["pitch"].as(); if (node["fov"]) fov = node["fov"].as(); if (node["aspect"]) aspect = node["aspect"].as(); if (node["nearPlane"]) nearPlane = node["nearPlane"].as(); if (node["farPlane"]) farPlane = node["farPlane"].as(); } // (Other Camera methods remain unchanged.) private: glm::vec3 position; float yaw; float pitch; // Perspective projection parameters. float fov; float aspect; float nearPlane; float farPlane; }; #endif // CAMERA_H