openscenegraph
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 {
140 if(!_boundingSphereComputed) getBound();
141 return _bbox;
142 }
143
145
146
147 protected:
148
149 virtual ~Geode();
150
152
153};
154
155}
156
157#endif
Definition BoundingBox:34
Definition BoundingSphere:35
Definition CopyOp:41
Definition Drawable:89
virtual Drawable * asDrawable()
Definition Drawable:101
Definition Geode:29
virtual Geode * asGeode()
Definition Geode:39
osg::BoundingBox _bbox
Definition Geode:151
virtual bool replaceDrawable(Drawable *origDraw, Drawable *newDraw)
virtual ~Geode()
bool containsDrawable(const Drawable *drawable) const
Definition Geode:108
unsigned int getDrawableIndex(const Drawable *drawable) const
Definition Geode:126
bool containsDrawable(const ref_ptr< T > &drawable) const
Definition Geode:119
virtual bool removeDrawable(Drawable *drawable)
virtual bool setDrawable(unsigned int i, Drawable *drawable)
virtual bool addDrawable(Drawable *drawable)
bool setDrawable(unsigned int i, const ref_ptr< T > &drawable)
Definition Geode:94
const Drawable * getDrawable(unsigned int i) const
Definition Geode:105
unsigned int getNumDrawables() const
Definition Geode:99
void compileDrawables(RenderInfo &renderInfo)
Geode(const Geode &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
bool addDrawable(const ref_ptr< T > &drawable)
Definition Geode:52
virtual const Geode * asGeode() const
Definition Geode:40
META_Node(osg, Geode)
unsigned int getDrawableIndex(const ref_ptr< T > &drawable) const
Definition Geode:131
Drawable * getDrawable(unsigned int i)
Definition Geode:102
bool replaceDrawable(const ref_ptr< T > &origDraw, const ref_ptr< R > &newDraw)
Definition Geode:80
virtual BoundingSphere computeBound() const
virtual bool removeDrawables(unsigned int i, unsigned int numDrawablesToRemove=1)
bool removeDrawable(const ref_ptr< T > &drawable)
Definition Geode:62
const BoundingBox & getBoundingBox() const
Definition Geode:138
Definition Group:29
Definition RenderInfo:28
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSG_EXPORT
Definition osg/Export:39