1 #include "pointlight.h"
2 #include "programdata.h"
9 PointLight::PointLight():
10 position(0.0f, 0.0f, 0.0f),
11 attenuation{1.0f, 0.0f, 0.1f}
14 void PointLight::update_matrix()
16 matrix = Matrix::translation(position);
19 void PointLight::set_matrix(const Matrix &m)
21 Placeable::set_matrix(m);
22 position = matrix.column(3).slice<3>(0);
27 void PointLight::set_position(const Vector3 &p)
34 void PointLight::set_attenuation(float c, float l, float q)
42 void PointLight::update_shader_data(ProgramData &shdata, const string &base) const
44 shdata.uniform(base+".type", 2);
45 shdata.uniform(base+".position", position.x, position.y, position.z, 1.0f);
46 shdata.uniform(base+".color", color.r, color.g, color.b);
50 DataFile::Loader::ActionMap PointLight::Loader::shared_actions;
52 PointLight::Loader::Loader(PointLight &l):
53 DerivedObjectLoader<PointLight, Light::Loader>(l)
55 set_actions(shared_actions);
58 void PointLight::Loader::init_actions()
60 Light::Loader::init_actions();
61 add("attenuation", &Loader::attenuation);
62 add("position", &Loader::position);
65 void PointLight::Loader::attenuation(float c, float l, float q)
67 obj.set_attenuation(c, l, q);
70 void PointLight::Loader::position(float x, float y, float z)
72 obj.set_position(Vector3(x, y, z));