X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Flighting.cpp;h=20c812fe58cfd3e6ee7434bef5f10707db67f01c;hb=5008778dbb1840bf7c6d479800d2b932f8386fb2;hp=3bbc01a3fa8e4bd4d51fd0fafc924b95651b492d;hpb=b9d8d358aab136fb1d1242360fe4f3c3711bde11;p=libs%2Fgl.git diff --git a/source/materials/lighting.cpp b/source/materials/lighting.cpp index 3bbc01a3..20c812fe 100644 --- a/source/materials/lighting.cpp +++ b/source/materials/lighting.cpp @@ -1,56 +1,30 @@ #include #include #include -#include "error.h" +#include +#include +#include #include "light.h" #include "lighting.h" -#include "matrix.h" -#include "misc.h" using namespace std; namespace Msp { namespace GL { -Lighting::Lighting(): - zenith_direction(0, 0, 1), - horizon_angle(Geometry::Angle::zero()) +Lighting::Lighting() { set_ambient(0.2f); set_fog_color(Color(0.0f, 0.0f, 0.0f, 0.0f)); set_fog_density(0.0f); } -Lighting::~Lighting() -{ - for(vector::iterator i=owned_data.begin(); i!=owned_data.end(); ++i) - delete *i; -} - void Lighting::set_ambient(const Color &a) { ambient = a; shdata.uniform("ambient_color", ambient); } -void Lighting::set_sky_color(const Color &s) -{ - sky_color = s; - shdata.uniform("sky_color", sky_color); -} - -void Lighting::set_zenith_direction(const Vector3 &d) -{ - zenith_direction = d; - shdata.uniform("world_zenith_dir", zenith_direction); -} - -void Lighting::set_horizon_angle(const Geometry::Angle &a) -{ - horizon_angle = a; - shdata.uniform("horizon_limit", horizon_angle.radians()); -} - void Lighting::set_fog_color(const Color &c) { fog_color = c; @@ -79,38 +53,11 @@ void Lighting::attach(const Light &l) void Lighting::detach(const Light &l) { - vector::iterator i = find_member(lights, &l, &AttachedLight::light); + auto i = find_member(lights, &l, &AttachedLight::light); if(i!=lights.end()) lights.erase(i); } -void Lighting::detach(unsigned i) -{ - if(i>=lights.size()) - return; - - detach(*lights[i].light); -} - -const Light *Lighting::get_attached_light(unsigned i) const -{ - return iupdate_shader_data(sd, i); -} - const ProgramData &Lighting::get_shader_data() const { for(unsigned i=0; i::from_degrees(a)); -} -#pragma GCC diagnostic pop - void Lighting::Loader::light(const string &name) { obj.attach(get_collection().get(name)); @@ -200,27 +133,9 @@ void Lighting::Loader::light_inline() { RefPtr lgt = new Light; load_sub(*lgt); - obj.attach(*lgt); - obj.owned_data.push_back(lgt.release()); -} - -void Lighting::Loader::light_inline_index(unsigned) -{ - light_inline(); -} - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wdeprecated-declarations" -void Lighting::Loader::sky_color(float r, float g, float b) -{ - obj.set_sky_color(Color(r, g, b)); -} - -void Lighting::Loader::zenith_direction(float x, float y, float z) -{ - obj.set_zenith_direction(Vector3(x, y, z)); + get_collection().add(format("%s/%d.light", FS::basename(get_source()), obj.lights.size()), lgt.get()); + obj.attach(*lgt.release()); } -#pragma GCC diagnostic pop } // namespace GL } // namespace Msp