]> git.tdb.fi Git - libs/gl.git/blobdiff - source/effects/environmentmap.cpp
Support effects and subordinate sequences inside sequence templates
[libs/gl.git] / source / effects / environmentmap.cpp
index 782a3d2ab0845b4815520852de8436b8b86c0fb5..419f402b8d22287c89bfb89549190ed6a5ae8b07 100644 (file)
@@ -2,6 +2,7 @@
 #include <cmath>
 #include <msp/strings/format.h>
 #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<string, Renderable *> &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<EnvironmentMap> 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<Template, Effect::Template::Loader>(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