Lugdunum  0.1.0
Light.cpp
Go to the documentation of this file.
2 
4 
5 namespace lug {
6 namespace Graphics {
7 namespace Render {
8 
9 Light::Light(const std::string& name, Type type) : Resource(Resource::Type::Light, name), _type(type) {}
10 
11 void Light::getData(Light::Data& lightData, Scene::Node& node) {
12  lightData.type = static_cast<uint32_t>(_type);
13  lightData.color = _color;
14 
15  if (_type != Type::Ambient) {
16  lightData.position = node.getAbsolutePosition();
17  }
18 
19  if (_type == Type::Directional || _type == Type::Spot) {
20  lightData.direction = node.getAbsoluteRotation().transform() * _direction;
21  }
22 
23  if (_type == Type::Point || _type == Type::Spot) {
25  lightData.distance = _distance;
28  }
29 
30  if (_type == Type::Spot) {
31  lightData.falloffAngle = _falloffAngle;
33  }
34 }
35 
36 } // Render
37 } // Graphics
38 } // lug
Light(const Light &)=delete
const Math::Vec3f & getAbsolutePosition()
Definition: Node.inl:14
Class for resource.
Definition: Resource.hpp:17
const Math::Quatf & getAbsoluteRotation()
Definition: Node.inl:22
void getData(Light::Data &lightData, Scene::Node &node)
Definition: Light.cpp:11
Class for Light.
Definition: Light.hpp:26