1 // Copyright (C) 2008 Timothy Moore timoore@redhat.com
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.
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.
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.
17 #ifndef SIMGEAR_EFFECT_GEODE_HXX
18 #define SIMGEAR_EFFECT_GEODE_HXX 1
21 #include <osg/Version>
23 #include <boost/iterator/iterator_adaptor.hpp>
30 class EffectGeode : public osg::Geode
34 #if OSG_VERSION_LESS_THAN(3,3,2)
35 typedef DrawableList::iterator DrawablesIterator;
37 class DrawablesIterator:
38 public boost::iterator_adaptor<
40 osg::NodeList::iterator,
41 osg::ref_ptr<osg::Drawable>,
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.
54 explicit DrawablesIterator(osg::NodeList::iterator const& node_it):
55 DrawablesIterator::iterator_adaptor_(node_it)
59 friend class boost::iterator_core_access;
60 osg::ref_ptr<osg::Drawable> dereference() const
62 return base_reference()->get()->asDrawable();
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;
78 #if OSG_VERSION_LESS_THAN(3,3,2)
79 DrawablesIterator drawablesBegin() { return _drawables.begin(); }
80 DrawablesIterator drawablesEnd() { return _drawables.end(); }
82 DrawablesIterator drawablesBegin() { return DrawablesIterator(_children.begin()); }
83 DrawablesIterator drawablesEnd() { return DrawablesIterator(_children.end()); }
86 void runGenerators(osg::Geometry *geometry);
88 osg::ref_ptr<Effect> _effect;
89 SGMaterial* _material;