diff --git a/include/osg/Geode b/include/osg/Geode index 1a3a857eb..c09686892 100644 --- a/include/osg/Geode +++ b/include/osg/Geode @@ -38,6 +38,8 @@ class OSG_EXPORT Geode : public Node META_Node(osg, Geode); + virtual Geode* asGeode() { return this; } + virtual const Geode* asGeode() const { return this; } /** Add a \c Drawable to the \c Geode. * If \c drawable is not \c NULL and is not contained in the \c Geode diff --git a/include/osg/Node b/include/osg/Node index 2dc0a9967..f2be03e72 100644 --- a/include/osg/Node +++ b/include/osg/Node @@ -29,6 +29,8 @@ class NodeVisitor; class Group; class Transform; class Node; +class Switch; +class Geode; /** A vector of Nodes pointers which is used to describe the path from a root node to a descendant.*/ typedef std::vector< Node* > NodePath; @@ -96,6 +98,22 @@ class OSG_EXPORT Node : public Object * Equivalent to dynamic_cast(this).*/ virtual const Transform* asTransform() const { return 0; } + /** Convert 'this' into a Switch pointer if Node is a Switch, otherwise return 0. + * Equivalent to dynamic_cast(this).*/ + virtual Switch* asSwitch() { return 0; } + + /** convert 'const this' into a const Switch pointer if Node is a Switch, otherwise return 0. + * Equivalent to dynamic_cast(this).*/ + virtual const Switch* asSwitch() const { return 0; } + + /** Convert 'this' into a Geode pointer if Node is a Geode, otherwise return 0. + * Equivalent to dynamic_cast(this).*/ + virtual Geode* asGeode() { return 0; } + + /** convert 'const this' into a const Geode pointer if Node is a Geode, otherwise return 0. + * Equivalent to dynamic_cast(this).*/ + virtual const Geode* asGeode() const { return 0; } + /** Visitor Pattern : calls the apply method of a NodeVisitor with this node's type.*/ virtual void accept(NodeVisitor& nv); /** Traverse upwards : calls parents' accept method with NodeVisitor.*/ diff --git a/include/osg/Switch b/include/osg/Switch index e8c998f7a..d8c0ca431 100644 --- a/include/osg/Switch +++ b/include/osg/Switch @@ -33,6 +33,10 @@ class OSG_EXPORT Switch : public Group /** Copy constructor using CopyOp to manage deep vs shallow copy. */ Switch(const Switch&,const CopyOp& copyop=CopyOp::SHALLOW_COPY); + virtual Switch* asSwitch() { return this; } + virtual const Switch* asSwitch() const { return this; } + + META_Node(osg, Switch); virtual void traverse(NodeVisitor& nv);