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::Pass::~Pass()
33 PipelineTemplate::Loader::Loader(PipelineTemplate &t):
34 DataFile::CollectionObjectLoader<PipelineTemplate>(t, 0)
39 PipelineTemplate::Loader::Loader(PipelineTemplate &t, Collection &c):
40 DataFile::CollectionObjectLoader<PipelineTemplate>(t, &c)
45 void PipelineTemplate::Loader::init()
47 add("ambient_occlusion", &Loader::postprocessor<AmbientOcclusion>);
48 add("bloom", &Loader::postprocessor<Bloom>);
49 add("colorcurve", &Loader::postprocessor<ColorCurve>);
50 add("hdr", &PipelineTemplate::hdr);
51 add("multisample", &Loader::multisample);
52 add("multisample", &Loader::multisample_range);
53 add("pass", &Loader::pass);
56 void PipelineTemplate::Loader::multisample(unsigned samples)
58 obj.required_multisample = samples;
59 obj.max_multisample = samples;
62 void PipelineTemplate::Loader::multisample_range(unsigned req, unsigned max)
64 obj.required_multisample = req;
65 obj.max_multisample = max;
68 void PipelineTemplate::Loader::pass(const string &tag, const string &rend)
72 pss.renderable_name = rend;
78 obj.passes.push_back(pss);
82 void PipelineTemplate::Loader::postprocessor()
84 RefPtr<typename T::Template> postproc = new typename T::Template;
86 obj.postprocessors.push_back(postproc.release());
90 PipelineTemplate::Pass::Loader::Loader(Pass &p):
91 DataFile::CollectionObjectLoader<Pass>(p, 0)
96 PipelineTemplate::Pass::Loader::Loader(Pass &p, Collection &c):
97 DataFile::CollectionObjectLoader<Pass>(p, &c)
102 void PipelineTemplate::Pass::Loader::init()
104 add("blend", &Loader::blend);
105 add("blend", &Loader::blend_predefined);
106 add("depth_test", &Loader::depth_test);
107 add("depth_test", &Loader::depth_test_predefined);
108 add("lighting", &Loader::lighting);
109 add("lighting", &Loader::lighting_inline);
112 void PipelineTemplate::Pass::Loader::blend_predefined(const string &name)
114 const Blend *bln = 0;
116 bln = &Blend::alpha();
117 else if(name=="additive")
118 bln = &Blend::additive();
119 else if(name=="additive_alpha")
120 bln = &Blend::additive_alpha();
122 throw key_error(name);
128 void PipelineTemplate::Pass::Loader::blend(BlendFactor src, BlendFactor dest)
130 obj.blend = new Blend(src, dest);
133 void PipelineTemplate::Pass::Loader::depth_test_predefined(const string &name)
135 const DepthTest *dtest = 0;
137 dtest = &DepthTest::lequal();
139 throw key_error(name);
141 obj.depth_test = dtest;
142 obj.depth_test.keep();
145 void PipelineTemplate::Pass::Loader::depth_test(Predicate pred)
147 obj.depth_test = new DepthTest(pred);
150 void PipelineTemplate::Pass::Loader::lighting_inline()
152 RefPtr<Lighting> lightn = new Lighting;
154 obj.lighting = lightn;
157 void PipelineTemplate::Pass::Loader::lighting(const string &name)
159 obj.lighting = &get_collection().get<Lighting>(name);
163 /*void PipelineTemplate::Pass::Loader::scene(const string &name)
165 obj.default_renderable = get_collection().get<Scene>(name);