ThreeLab/Engine/Components/LightComponent.h
2025-04-01 19:19:53 -05:00

40 lines
974 B
C++

#ifndef LIGHT_COMPONENT_H
#define LIGHT_COMPONENT_H
#include <glm/glm.hpp>
#include <yaml-cpp/yaml.h>
class LightComponent {
public:
LightComponent();
~LightComponent();
// Light properties.
glm::vec3 color;
float intensity;
// 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>();
}
};
#endif // LIGHT_COMPONENT_H