]> git.mxchange.org Git - simgear.git/blob - simgear/scene/material/EffectGeode.hxx
Fix removal of directories.
[simgear.git] / simgear / scene / material / EffectGeode.hxx
1 // Copyright (C) 2008  Timothy Moore timoore@redhat.com
2 //
3 // This program is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU General Public License as
5 // published by the Free Software Foundation; either version 2 of the
6 // License, or (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful, but
9 // WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
16
17 #ifndef SIMGEAR_EFFECT_GEODE_HXX
18 #define SIMGEAR_EFFECT_GEODE_HXX 1
19
20 #include <osg/Geode>
21 #include <osg/Version>
22
23 #include <boost/iterator/iterator_adaptor.hpp>
24
25 #include "Effect.hxx"
26 #include "mat.hxx"
27
28 namespace simgear
29 {
30 class EffectGeode : public osg::Geode
31 {
32   public:
33
34 #if OSG_VERSION_LESS_THAN(3,3,2)
35     typedef DrawableList::iterator DrawablesIterator;
36 #else
37     class DrawablesIterator:
38       public boost::iterator_adaptor<
39         DrawablesIterator,
40         osg::NodeList::iterator,
41         osg::ref_ptr<osg::Drawable>,
42         boost::use_default,
43         osg::ref_ptr<osg::Drawable> // No reference as Reference type.
44                                     // The child list does not contain Drawable
45                                     // ref_ptr so we can not return any
46                                     // references to them.
47       >
48     {
49       public:
50
51         DrawablesIterator()
52         {}
53
54         explicit DrawablesIterator(osg::NodeList::iterator const& node_it):
55           DrawablesIterator::iterator_adaptor_(node_it)
56         {}
57
58       private:
59         friend class boost::iterator_core_access;
60         osg::ref_ptr<osg::Drawable> dereference() const
61         {
62           return base_reference()->get()->asDrawable();
63         }
64     };
65 #endif
66
67     EffectGeode();
68     EffectGeode(const EffectGeode& rhs,
69                 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
70     META_Node(simgear,EffectGeode);
71     Effect* getEffect() const { return _effect.get(); }
72     void setEffect(Effect* effect);
73     SGMaterial* getMaterial() const { return _material; }
74     void setMaterial(SGMaterial* mat) { _material = mat; }
75     virtual void resizeGLObjectBuffers(unsigned int maxSize);
76     virtual void releaseGLObjects(osg::State* = 0) const;
77
78 #if OSG_VERSION_LESS_THAN(3,3,2)
79     DrawablesIterator drawablesBegin() { return _drawables.begin(); }
80     DrawablesIterator drawablesEnd() { return _drawables.end(); }
81 #else
82     DrawablesIterator drawablesBegin() { return DrawablesIterator(_children.begin()); }
83     DrawablesIterator drawablesEnd() { return DrawablesIterator(_children.end()); }
84 #endif
85
86     void runGenerators(osg::Geometry *geometry);
87 private:
88     osg::ref_ptr<Effect> _effect;
89     SGMaterial* _material;
90 };
91 }
92 #endif