ThreeLab/Engine/Components/LightComponent.h

40 lines
974 B
C
Raw Normal View History

2025-04-01 20:03:18 +00:00
#ifndef LIGHT_COMPONENT_H
#define LIGHT_COMPONENT_H
#include <glm/glm.hpp>
2025-04-02 00:19:53 +00:00
#include <yaml-cpp/yaml.h>
2025-04-01 20:03:18 +00:00
class LightComponent {
public:
LightComponent();
~LightComponent();
// Light properties.
glm::vec3 color;
float intensity;
2025-04-02 00:19:53 +00:00
// Save this light to a YAML node.
YAML::Node Save() const {
YAML::Node node;
node["color"] = YAML::Node();
node["color"].push_back(color.x);
node["color"].push_back(color.y);
node["color"].push_back(color.z);
node["intensity"] = intensity;
return node;
}
// Load this light from a YAML node.
void Load(const YAML::Node &node) {
if (node["color"]) {
color.x = node["color"][0].as<float>();
color.y = node["color"][1].as<float>();
color.z = node["color"][2].as<float>();
}
if (node["intensity"])
intensity = node["intensity"].as<float>();
}
2025-04-01 20:03:18 +00:00
};
#endif // LIGHT_COMPONENT_H