Geode
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_GEODE
#define OSG_GEODE 1
#include <osg/Node>
#include <osg/NodeVisitor>
#include <osg/Drawable>
namespace osg {
class OSG_EXPORT Geode : public Group
{
public:
Geode();
Geode(const Geode&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_Node(osg, Geode);
virtual Geode* asGeode() { return this; }
virtual const Geode* asGeode() const { return this; }
virtual bool addDrawable( Drawable *drawable );
template<class T> bool addDrawable( const ref_ptr<T>& drawable ) { return addDrawable(drawable.get()); }
virtual bool removeDrawable( Drawable *drawable );
template<class T> bool removeDrawable( const ref_ptr<T>& drawable ) { return removeDrawable( drawable.get() ); }
virtual bool removeDrawables(unsigned int i,unsigned int numDrawablesToRemove=1);
virtual bool replaceDrawable( Drawable *origDraw, Drawable *newDraw );
template<class T, class R> bool replaceDrawable( const ref_ptr<T>& origDraw, const ref_ptr<R>& newDraw ) { return replaceDrawable(origDraw.get(), newDraw.get()); }
virtual bool setDrawable( unsigned int i, Drawable* drawable );
template<class T> bool setDrawable( unsigned int i, const ref_ptr<T>& drawable ) { return setDrawable(i, drawable.get()); }
inline unsigned int getNumDrawables() const { return getNumChildren(); }
inline Drawable* getDrawable( unsigned int i ) { return _children[i].valid() ? _children[i]->asDrawable() : 0; }
inline const Drawable* getDrawable( unsigned int i ) const { return _children[i].valid() ? _children[i]->asDrawable() : 0; }
inline bool containsDrawable(const Drawable* drawable) const
{
for (NodeList::const_iterator itr=_children.begin();
itr!=_children.end();
++itr)
{
if (itr->get() == drawable) return true;
}
return false;
}
template<class T> bool containsDrawable(const ref_ptr<T>& drawable) const { return containsDrawable(drawable.get()); }
inline unsigned int getDrawableIndex( const Drawable* drawable ) const
{
return getChildIndex(drawable);
}
template<class T> unsigned int getDrawableIndex( const ref_ptr<T>& drawable ) const { return getDrawableIndex(drawable.get()); }
void compileDrawables(RenderInfo& renderInfo);
inline const BoundingBox& getBoundingBox() const
{
if(!_boundingSphereComputed) getBound();
return _bbox;
}
virtual BoundingSphere computeBound() const;
protected:
virtual ~Geode();
mutable osg::BoundingBox _bbox;
};
}
#endif
Drawable
NodeVisitor
Node
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Drawable
Definition Drawable:89
osg::Geode::asGeode
virtual Geode * asGeode()
Definition Geode:39
osg::Geode::_bbox
osg::BoundingBox _bbox
Definition Geode:151
osg::Geode::replaceDrawable
virtual bool replaceDrawable(Drawable *origDraw, Drawable *newDraw)
osg::Geode::~Geode
virtual ~Geode()
osg::Geode::containsDrawable
bool containsDrawable(const Drawable *drawable) const
Definition Geode:108
osg::Geode::getDrawableIndex
unsigned int getDrawableIndex(const Drawable *drawable) const
Definition Geode:126
osg::Geode::containsDrawable
bool containsDrawable(const ref_ptr< T > &drawable) const
Definition Geode:119
osg::Geode::removeDrawable
virtual bool removeDrawable(Drawable *drawable)
osg::Geode::setDrawable
virtual bool setDrawable(unsigned int i, Drawable *drawable)
osg::Geode::addDrawable
virtual bool addDrawable(Drawable *drawable)
osg::Geode::setDrawable
bool setDrawable(unsigned int i, const ref_ptr< T > &drawable)
Definition Geode:94
osg::Geode::getDrawable
const Drawable * getDrawable(unsigned int i) const
Definition Geode:105
osg::Geode::getNumDrawables
unsigned int getNumDrawables() const
Definition Geode:99
osg::Geode::compileDrawables
void compileDrawables(RenderInfo &renderInfo)
osg::Geode::Geode
Geode(const Geode &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
osg::Geode::Geode
Geode()
osg::Geode::addDrawable
bool addDrawable(const ref_ptr< T > &drawable)
Definition Geode:52
osg::Geode::asGeode
virtual const Geode * asGeode() const
Definition Geode:40
osg::Geode::META_Node
META_Node(osg, Geode)
osg::Geode::getDrawableIndex
unsigned int getDrawableIndex(const ref_ptr< T > &drawable) const
Definition Geode:131
osg::Geode::getDrawable
Drawable * getDrawable(unsigned int i)
Definition Geode:102
osg::Geode::replaceDrawable
bool replaceDrawable(const ref_ptr< T > &origDraw, const ref_ptr< R > &newDraw)
Definition Geode:80
osg::Geode::computeBound
virtual BoundingSphere computeBound() const
osg::Geode::removeDrawables
virtual bool removeDrawables(unsigned int i, unsigned int numDrawablesToRemove=1)
osg::Geode::removeDrawable
bool removeDrawable(const ref_ptr< T > &drawable)
Definition Geode:62
osg::Geode::getBoundingBox
const BoundingBox & getBoundingBox() const
Definition Geode:138
osg::Group::getNumChildren
virtual unsigned int getNumChildren() const
osg::Group::getChildIndex
unsigned int getChildIndex(const Node *node) const
Definition Group:141
osg::Group::Group
Group()
osg::Group::_children
NodeList _children
Definition Group:170
osg::Node::_boundingSphereComputed
bool _boundingSphereComputed
Definition Node:497
osg::Node::getBound
const BoundingSphere & getBound() const
Definition Node:425
osg::RenderInfo
Definition RenderInfo:28
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::get
T * get() const
Definition ref_ptr:117
osg
Definition AlphaFunc:19
osg::BoundingBox
BoundingBoxd BoundingBox
Definition BoundingBox:257
osg::BoundingSphere
BoundingSphered BoundingSphere
Definition BoundingSphere:314
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39