OpenSceneGraph 3.6.5
Geode
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
21namespace osg {
22
28class OSG_EXPORT Geode : public Group
29{
30 public:
31
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
52 template<class T> bool addDrawable( const ref_ptr<T>& drawable ) { return addDrawable(drawable.get()); }
53
60 virtual bool removeDrawable( Drawable *drawable );
61
62 template<class T> bool removeDrawable( const ref_ptr<T>& drawable ) { return removeDrawable( drawable.get() ); }
63
72 virtual bool removeDrawables(unsigned int i,unsigned int numDrawablesToRemove=1);
73
78 virtual bool replaceDrawable( Drawable *origDraw, Drawable *newDraw );
79
80 template<class T, class R> bool replaceDrawable( const ref_ptr<T>& origDraw, const ref_ptr<R>& newDraw ) { return replaceDrawable(origDraw.get(), newDraw.get()); }
81
92 virtual bool setDrawable( unsigned int i, Drawable* drawable );
93
94 template<class T> bool setDrawable( unsigned int i, const ref_ptr<T>& drawable ) { return setDrawable(i, drawable.get()); }
95
99 inline unsigned int getNumDrawables() const { return getNumChildren(); }
100
102 inline Drawable* getDrawable( unsigned int i ) { return _children[i].valid() ? _children[i]->asDrawable() : 0; }
103
105 inline const Drawable* getDrawable( unsigned int i ) const { return _children[i].valid() ? _children[i]->asDrawable() : 0; }
106
108 inline bool containsDrawable(const Drawable* drawable) const
109 {
110 for (NodeList::const_iterator itr=_children.begin();
111 itr!=_children.end();
112 ++itr)
113 {
114 if (itr->get() == drawable) return true;
115 }
116 return false;
117 }
118
119 template<class T> bool containsDrawable(const ref_ptr<T>& drawable) const { return containsDrawable(drawable.get()); }
120
126 inline unsigned int getDrawableIndex( const Drawable* drawable ) const
127 {
128 return getChildIndex(drawable);
129 }
130
131 template<class T> unsigned int getDrawableIndex( const ref_ptr<T>& drawable ) const { return getDrawableIndex(drawable.get()); }
132
134 void compileDrawables(RenderInfo& renderInfo);
135
138 inline const BoundingBox& getBoundingBox() const
139 {
141 return _bbox;
142 }
143
145
146
147 protected:
148
149 virtual ~Geode();
150
152
153};
154
155}
156
157#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
BoundingBoxd BoundingBox
Definition BoundingBox:257
BoundingSphered BoundingSphere
Definition BoundingSphere:308
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Pure virtual base class for drawable geometry.
Definition Drawable:89
virtual Geode * asGeode()
Convert 'this' into a Geode pointer if Node is a Geode, otherwise return 0.
Definition Geode:39
osg::BoundingBox _bbox
Definition Geode:151
virtual bool replaceDrawable(Drawable *origDraw, Drawable *newDraw)
Replace specified Drawable with another Drawable.
virtual ~Geode()
bool containsDrawable(const Drawable *drawable) const
Return true if a given Drawable is contained within Geode.
Definition Geode:108
unsigned int getDrawableIndex(const Drawable *drawable) const
Get the index number of drawable.
Definition Geode:126
bool containsDrawable(const ref_ptr< T > &drawable) const
Definition Geode:119
virtual bool removeDrawable(Drawable *drawable)
Remove a Drawable from the Geode.
virtual bool setDrawable(unsigned int i, Drawable *drawable)
Set Drawable at position i.
virtual bool addDrawable(Drawable *drawable)
Add a Drawable to the Geode.
bool setDrawable(unsigned int i, const ref_ptr< T > &drawable)
Definition Geode:94
const Drawable * getDrawable(unsigned int i) const
Return the Drawable at position i.
Definition Geode:105
unsigned int getNumDrawables() const
Return the number of Drawables currently attached to the Geode.
Definition Geode:99
void compileDrawables(RenderInfo &renderInfo)
Compile OpenGL Display List for each drawable.
Geode(const Geode &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
Copy constructor using CopyOp to manage deep vs shallow copy.
bool addDrawable(const ref_ptr< T > &drawable)
Definition Geode:52
virtual const Geode * asGeode() const
convert 'const this' into a const Geode pointer if Node is a Geode, otherwise return 0.
Definition Geode:40
META_Node(osg, Geode)
unsigned int getDrawableIndex(const ref_ptr< T > &drawable) const
Definition Geode:131
Drawable * getDrawable(unsigned int i)
Return the Drawable at position i.
Definition Geode:102
bool replaceDrawable(const ref_ptr< T > &origDraw, const ref_ptr< R > &newDraw)
Definition Geode:80
virtual BoundingSphere computeBound() const
Compute the bounding sphere around Node's geometry or children.
virtual bool removeDrawables(unsigned int i, unsigned int numDrawablesToRemove=1)
Remove Drawable(s) from the specified position in Geode's drawable list.
bool removeDrawable(const ref_ptr< T > &drawable)
Definition Geode:62
const BoundingBox & getBoundingBox() const
Return the Geode's bounding box, which is the union of all the bounding boxes of the geode's drawable...
Definition Geode:138
virtual unsigned int getNumChildren() const
Return the number of children nodes.
unsigned int getChildIndex(const Node *node) const
Get the index number of child, return a value between 0 and _children.size()-1 if found,...
Definition Group:141
NodeList _children
Definition Group:170
bool _boundingSphereComputed
Definition Node:497
const BoundingSphere & getBound() const
Definition Node:425
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
Definition RenderInfo:28
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.