X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Flighting.cpp;h=70b819cec8c3101b5379f1cb26b284e4a5d8bd98;hb=82282de52e8e8f3bbafefaf92bf76f53f2c2495e;hp=bcf2bb0e2645772555b2f1bbc2eaa4b6ea3959b2;hpb=a8383f1163cd020e2ce2c030e93defd2f9909a1d;p=libs%2Fgl.git diff --git a/source/materials/lighting.cpp b/source/materials/lighting.cpp index bcf2bb0e..70b819ce 100644 --- a/source/materials/lighting.cpp +++ b/source/materials/lighting.cpp @@ -94,14 +94,11 @@ void Lighting::update_shader_data(ProgramData &shdata, const Matrix &view_matrix { shdata.uniform("ambient_color", ambient); shdata.uniform("sky_color", sky_color); - shdata.uniform("eye_zenith_dir", view_matrix.block<3, 3>(0, 0)*zenith_direction); + shdata.uniform("world_zenith_dir", zenith_direction); shdata.uniform("horizon_limit", horizon_angle.radians()); shdata.uniform("fog_color", fog_color); shdata.uniform("fog_density", fog_density); - // For backwards compatibility - shdata.uniform("eye_sky_dir", view_matrix.block<3, 3>(0, 0)*zenith_direction); - for(unsigned i=0; iupdate_shader_data(shdata, view_matrix, i); @@ -111,7 +108,13 @@ void Lighting::update_shader_data(ProgramData &shdata, const Matrix &view_matrix DataFile::Loader::ActionMap Lighting::Loader::shared_actions; Lighting::Loader::Loader(Lighting &l): - DataFile::ObjectLoader(l) + CollectionObjectLoader(l, 0) +{ + set_actions(shared_actions); +} + +Lighting::Loader::Loader(Lighting &l, Collection &c): + CollectionObjectLoader(l, &c) { set_actions(shared_actions); } @@ -124,11 +127,12 @@ void Lighting::Loader::init_actions() add("fog_half_distance", &Loader::fog_half_distance); add("horizon_angle", &Loader::horizon_angle); add("light", &Loader::light); + add("light", &Loader::light_inline); add("sky_color", &Loader::sky_color); add("zenith_direction", &Loader::zenith_direction); // Deprecated - add("light", &Loader::light_index); + add("light", &Loader::light_inline_index); } void Lighting::Loader::ambient(float r, float g, float b) @@ -156,7 +160,12 @@ void Lighting::Loader::horizon_angle(float a) obj.set_horizon_angle(Geometry::Angle::from_degrees(a)); } -void Lighting::Loader::light() +void Lighting::Loader::light(const string &name) +{ + obj.attach(get_collection().get(name)); +} + +void Lighting::Loader::light_inline() { RefPtr lgt = new Light; load_sub(*lgt); @@ -164,7 +173,7 @@ void Lighting::Loader::light() obj.owned_data.push_back(lgt.release()); } -void Lighting::Loader::light_index(unsigned) +void Lighting::Loader::light_inline_index(unsigned) { light_inline(); }