X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Feffects%2Fenvironmentmap.cpp;h=419f402b8d22287c89bfb89549190ed6a5ae8b07;hp=782a3d2ab0845b4815520852de8436b8b86c0fb5;hb=083a8227715fa32c841fc2b8126e4ab8d2840ba0;hpb=54fdd850d1e657bc357d859a532497905ded741a diff --git a/source/effects/environmentmap.cpp b/source/effects/environmentmap.cpp index 782a3d2a..419f402b 100644 --- a/source/effects/environmentmap.cpp +++ b/source/effects/environmentmap.cpp @@ -2,6 +2,7 @@ #include #include #include "environmentmap.h" +#include "error.h" #include "mesh.h" #include "renderer.h" #include "resources.h" @@ -199,5 +200,47 @@ void EnvironmentMap::set_debug_name(const string &name) #endif } + +EnvironmentMap *EnvironmentMap::Template::create(const map &renderables) const +{ + Renderable *content = get_item(renderables, content_name); + Renderable *environment = get_item(renderables, environment_name); + if(!content || !environment) + throw invalid_operation("EnvironmentMap::Template::create"); + + RefPtr env_map = new EnvironmentMap(size, format, roughness_levels, *content, *environment); + if(use_fixed_position) + env_map->set_fixed_position(fixed_position); + env_map->set_depth_clip(near_clip, far_clip); + + return env_map.release(); +} + + +DataFile::Loader::ActionMap EnvironmentMap::Template::Loader::shared_actions; + +EnvironmentMap::Template::Loader::Loader(Template &t, Collection &c): + DerivedObjectLoader(t, c) +{ + set_actions(shared_actions); +} + +void EnvironmentMap::Template::Loader::init_actions() +{ + Effect::Template::Loader::init_actions(); + add("depth_clip", &Template::near_clip, &Template::far_clip); + add("environment", &Template::environment_name); + add("fixed_position", &Loader::fixed_position); + add("format", &Template::format); + add("roughness_levels", &Template::roughness_levels); + add("size", &Template::size); +} + +void EnvironmentMap::Template::Loader::fixed_position(float x, float y, float z) +{ + obj.fixed_position = Vector3(x, y, z); + obj.use_fixed_position = true; +} + } // namespace GL } // namespace Msp