root/OpenSceneGraph/trunk/include/osgSim/VisibilityGroup @ 13041

Revision 13041, 3.0 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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 OSGSIM_VISIBILITYGROUP
15#define OSGSIM_VISIBILITYGROUP 1
16
17#include <osg/Node>
18#include <osg/Group>
19#include <osg/NodeVisitor>
20
21#include <osgSim/Export>
22
23namespace osgSim {
24
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.
29 */
30class OSGSIM_EXPORT VisibilityGroup : public osg::Group
31{
32    public :
33
34        VisibilityGroup();
35
36        /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
37        VisibilityGroup(const VisibilityGroup&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
38
39        META_Node(osgSim, VisibilityGroup);
40
41        virtual void traverse(osg::NodeVisitor& nv);
42
43        /** Set the subgraph that is intersected for the visibility determination.*/
44        void setVisibilityVolume(osg::Node* node) { _visibilityVolume = node; }
45
46        /** Get the subgraph that is intersected for the visibility determination.*/
47        osg::Node* getVisibilityVolume() { return _visibilityVolume.get(); }
48
49        /** Get the const subgraph that is intersected for the visibility determination.*/
50        const osg::Node* getVisibilityVolume() const { return _visibilityVolume.get(); }
51
52        /** Set the traversal mask for the intersection testing.*/
53        void setVolumeIntersectionMask(osg::Node::NodeMask mask) { _volumeIntersectionMask = mask; }
54
55        /** Get the traversal mask for the intersection testing.*/
56        osg::Node::NodeMask getVolumeIntersectionMask() const { return _volumeIntersectionMask; }
57
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; }
62
63        /** Get the length of the intersection segment.*/
64        float getSegmentLength() const { return _segmentLength; }
65
66    protected :
67
68        virtual ~VisibilityGroup() {}
69
70        osg::ref_ptr<osg::Node> _visibilityVolume;
71        osg::Node::NodeMask _volumeIntersectionMask;
72        float _segmentLength;
73};
74
75}
76#endif
Note: See TracBrowser for help on using the browser.