OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Geode.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_GEODE
15 #define OSG_GEODE 1
16 
17 #include <osg/Node>
18 #include <osg/NodeVisitor>
19 #include <osg/Drawable>
20 
21 namespace osg {
22 
28 class OSG_EXPORT Geode : public Group
29 {
30  public:
31 
32  Geode();
33 
35  Geode(const Geode&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
36 
38 
39  virtual Geode* asGeode() { return this; }
40  virtual const Geode* asGeode() const { return this; }
41 
50  virtual bool addDrawable( Drawable *drawable );
51 
58  virtual bool removeDrawable( Drawable *drawable );
59 
68  virtual bool removeDrawables(unsigned int i,unsigned int numDrawablesToRemove=1);
69 
74  virtual bool replaceDrawable( Drawable *origDraw, Drawable *newDraw );
75 
86  virtual bool setDrawable( unsigned int i, Drawable* drawable );
87 
91  inline unsigned int getNumDrawables() const { return getNumChildren(); }
92 
94  inline Drawable* getDrawable( unsigned int i ) { return _children[i].valid() ? _children[i]->asDrawable() : 0; }
95 
97  inline const Drawable* getDrawable( unsigned int i ) const { return _children[i].valid() ? _children[i]->asDrawable() : 0; }
98 
100  inline bool containsDrawable(const Drawable* drawable) const
101  {
102  for (NodeList::const_iterator itr=_children.begin();
103  itr!=_children.end();
104  ++itr)
105  {
106  if (itr->get() == drawable) return true;
107  }
108  return false;
109  }
110 
116  inline unsigned int getDrawableIndex( const Drawable* drawable ) const
117  {
118  return getChildIndex(drawable);
119  }
120 
122  void compileDrawables(RenderInfo& renderInfo);
123 
126  inline const BoundingBox& getBoundingBox() const
127  {
128  if(!_boundingSphereComputed) getBound();
129  return _bbox;
130  }
131 
132  virtual BoundingSphere computeBound() const;
133 
134 
135  protected:
136 
137  virtual ~Geode();
138 
140 
141 };
142 
143 }
144 
145 #endif
#define OSG_EXPORT
Definition: Export.h:43
const Drawable * getDrawable(unsigned int i) const
Definition: Geode.h:97
const BoundingBox & getBoundingBox() const
Definition: Geode.h:126
#define META_Node(library, name)
Definition: Node.h:59
virtual const Geode * asGeode() const
Definition: Geode.h:40
virtual Drawable * asDrawable()
Definition: Drawable.h:109
bool containsDrawable(const Drawable *drawable) const
Definition: Geode.h:100
osg::BoundingBox _bbox
Definition: Geode.h:139
virtual Geode * asGeode()
Definition: Geode.h:39
Definition: AlphaFunc.h:19
unsigned int getDrawableIndex(const Drawable *drawable) const
Definition: Geode.h:116
Drawable * getDrawable(unsigned int i)
Definition: Geode.h:94
unsigned int getNumDrawables() const
Definition: Geode.h:91