1 #include <msp/core/maputils.h>
2 #include <msp/datafile/collection.h>
3 #include "ambientocclusion.h"
6 #include "colorcurve.h"
8 #include "pipelinetemplate.h"
16 PipelineTemplate::PipelineTemplate():
18 required_multisample(0),
22 PipelineTemplate::~PipelineTemplate()
24 for(PostProcessorArray::iterator i=postprocessors.begin(); i!=postprocessors.end(); ++i)
29 PipelineTemplate::PostProcessorRegistry &PipelineTemplate::get_postprocessor_registry()
31 static PostProcessorRegistry registry;
32 static bool initialized = false;
35 registry.register_type<AmbientOcclusion>("ambient_occlusion");
36 registry.register_type<Bloom>("bloom");
37 registry.register_type<ColorCurve>("colorcurve");
44 PipelineTemplate::Pass::~Pass()
48 PipelineTemplate::Loader::Loader(PipelineTemplate &t):
49 DataFile::CollectionObjectLoader<PipelineTemplate>(t, 0)
54 PipelineTemplate::Loader::Loader(PipelineTemplate &t, Collection &c):
55 DataFile::CollectionObjectLoader<PipelineTemplate>(t, &c)
60 void PipelineTemplate::Loader::init()
62 add("hdr", &PipelineTemplate::hdr);
63 add("multisample", &Loader::multisample);
64 add("multisample", &Loader::multisample_range);
65 add("pass", &Loader::pass);
67 get_postprocessor_registry().add_all(*this);
70 void PipelineTemplate::Loader::multisample(unsigned samples)
72 obj.required_multisample = samples;
73 obj.max_multisample = samples;
76 void PipelineTemplate::Loader::multisample_range(unsigned req, unsigned max)
78 obj.required_multisample = req;
79 obj.max_multisample = max;
82 void PipelineTemplate::Loader::pass(const string &tag, const string &rend)
86 pss.renderable_name = rend;
92 obj.passes.push_back(pss);
96 PipelineTemplate::Pass::Loader::Loader(Pass &p):
97 DataFile::CollectionObjectLoader<Pass>(p, 0)
102 PipelineTemplate::Pass::Loader::Loader(Pass &p, Collection &c):
103 DataFile::CollectionObjectLoader<Pass>(p, &c)
108 void PipelineTemplate::Pass::Loader::init()
110 add("blend", &Loader::blend);
111 add("blend", &Loader::blend_predefined);
112 add("depth_test", &Loader::depth_test);
113 add("depth_test", &Loader::depth_test_predefined);
114 add("lighting", &Loader::lighting);
115 add("lighting", &Loader::lighting_inline);
118 void PipelineTemplate::Pass::Loader::blend_predefined(const string &name)
120 const Blend *bln = 0;
122 bln = &Blend::alpha();
123 else if(name=="additive")
124 bln = &Blend::additive();
125 else if(name=="additive_alpha")
126 bln = &Blend::additive_alpha();
128 throw key_error(name);
134 void PipelineTemplate::Pass::Loader::blend(BlendFactor src, BlendFactor dest)
136 obj.blend = new Blend(src, dest);
139 void PipelineTemplate::Pass::Loader::depth_test_predefined(const string &name)
141 const DepthTest *dtest = 0;
143 dtest = &DepthTest::lequal();
145 throw key_error(name);
147 obj.depth_test = dtest;
148 obj.depth_test.keep();
151 void PipelineTemplate::Pass::Loader::depth_test(Predicate pred)
153 obj.depth_test = new DepthTest(pred);
156 void PipelineTemplate::Pass::Loader::lighting_inline()
158 RefPtr<Lighting> lightn = new Lighting;
160 obj.lighting = lightn;
163 void PipelineTemplate::Pass::Loader::lighting(const string &name)
165 obj.lighting = &get_collection().get<Lighting>(name);
169 /*void PipelineTemplate::Pass::Loader::scene(const string &name)
171 obj.default_renderable = get_collection().get<Scene>(name);