1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
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.
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.
14#ifndef OSGSIM_VISIBILITYGROUP
15#define OSGSIM_VISIBILITYGROUP 1
19#include <osg/NodeVisitor>
21#include <osgSim/Export>
25/** VisibilityGroup renders (traverses) it's children only when the camera is inside a specified visibility volume.
26 * The visibility volume is intersected with a line segment that extends from
27 * the current camera's eye-point along the view vector for a given segment length.
28 * If an intersection is detected then the node's children are traversed.
30class OSGSIM_EXPORT VisibilityGroup : public osg::Group
36 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
37 VisibilityGroup(const VisibilityGroup&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
39 META_Node(osgSim, VisibilityGroup);
41 virtual void traverse(osg::NodeVisitor& nv);
43 /** Set the subgraph that is intersected for the visibility determination.*/
44 void setVisibilityVolume(osg::Node* node) { _visibilityVolume = node; }
46 /** Get the subgraph that is intersected for the visibility determination.*/
47 osg::Node* getVisibilityVolume() { return _visibilityVolume.get(); }
49 /** Get the const subgraph that is intersected for the visibility determination.*/
50 const osg::Node* getVisibilityVolume() const { return _visibilityVolume.get(); }
52 /** Set the traversal mask for the intersection testing.*/
53 void setVolumeIntersectionMask(osg::Node::NodeMask mask) { _volumeIntersectionMask = mask; }
55 /** Get the traversal mask for the intersection testing.*/
56 osg::Node::NodeMask getVolumeIntersectionMask() const { return _volumeIntersectionMask; }
58 /** Set the length of the intersection segment.
59 * The segments extends this many database units from the camera eye-point along the look vector.
60 * If this is left at zero then the diameter of the bounding sphere of the visibility volume is used.*/
61 void setSegmentLength(float length) { _segmentLength = length; }
63 /** Get the length of the intersection segment.*/
64 float getSegmentLength() const { return _segmentLength; }
68 virtual ~VisibilityGroup() {}
70 osg::ref_ptr<osg::Node> _visibilityVolume;
71 osg::Node::NodeMask _volumeIntersectionMask;