]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/EffectBuilder.cxx
New effects from Till Busch: crops, water, landmass
[simgear.git] / simgear / scene / material / EffectBuilder.cxx
1 #include "EffectBuilder.hxx"
2 #include "Effect.hxx"
3
4 namespace simgear
5 {
6
7 // Given a property node from a pass, get its value either from it or
8 // from the effect parameters.
9 const SGPropertyNode* getEffectPropertyNode(Effect* effect,
10                                             const SGPropertyNode* prop)
11 {
12     if (!prop)
13         return 0;
14     if (prop->nChildren() > 0) {
15         const SGPropertyNode* useProp = prop->getChild("use");
16         if (!useProp || !effect->parametersProp)
17             return prop;
18         return effect->parametersProp->getNode(useProp->getStringValue());
19     }
20     return prop;
21 }
22
23 // Get a named child property from pass parameters or effect
24 // parameters.
25 const SGPropertyNode* getEffectPropertyChild(Effect* effect,
26                                              const SGPropertyNode* prop,
27                                              const char* name)
28 {
29     const SGPropertyNode* child = prop->getChild(name);
30     if (!child)
31         return 0;
32     else
33         return getEffectPropertyNode(effect, child);
34 }
35
36 BuilderException::BuilderException()
37 {
38 }
39
40 BuilderException::BuilderException(const char* message, const char* origin)
41   : sg_exception(message, origin)
42 {
43 }
44
45 BuilderException::BuilderException(const std::string& message,
46                                    const std::string& origin)
47   : sg_exception(message, origin)
48 {
49 }
50
51 BuilderException::~BuilderException() throw()
52 {
53 }
54 }