root/OpenSceneGraph/trunk/examples/osgdepthpartition/DepthPartitionNode.h @ 5757

Revision 5757, 2.9 kB (checked in by robert, 7 years ago)

Renamed osg::CameraNode? to osg::Camera, cleaned up osg::View.

Added beginnings of new osgViewer::Scene,View,Viewer,CompositeViewer? and GraphicsWindowProxy? files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1#ifndef _OF_DEPTHPARTITIONNODE_
2#define _OF_DEPTHPARTITIONNODE_
3
4#include "DistanceAccumulator.h"
5#include <osg/Camera>
6
7#define CURRENT_CLASS DepthPartitionNode
8/**********************************************************
9 * Ravi Mathur
10 * OpenFrames API, class DepthPartitionNode
11 * A type of osg::Group that analyzes a scene, then partitions it into
12 * several segments that can be rendered separately. Each segment
13 * is small enough in the z-direction to avoid depth buffer problems
14 * for very large scenes.
15**********************************************************/
16class CURRENT_CLASS : public osg::Group
17{
18  public:
19        CURRENT_CLASS();
20        CURRENT_CLASS(const CURRENT_CLASS& dpn,
21                      const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
22
23        META_Node( OpenFrames, CURRENT_CLASS ); // Common Node functions
24
25        /** Set the active state. If not active, this node will simply add the
26            specified scene as it's child, without analyzing it at all. */
27        void setActive(bool active);
28        inline bool getActive() const { return _active; }
29
30        /** Specify whether the color buffer should be cleared before the first
31            Camera draws it's scene. */
32        void setClearColorBuffer(bool clear);
33        inline bool getClearColorBuffer() const { return _clearColorBuffer; }
34
35        /** Specify the render order for each Camera */
36        void setRenderOrder(osg::Camera::RenderOrder order);
37        inline osg::Camera::RenderOrder getRenderOrder() const
38        { return _renderOrder; }
39
40        /** Set/get the maximum depth that the scene will be traversed to.
41            Defaults to UINT_MAX. */
42        void setMaxTraversalDepth(unsigned int depth)
43        { _distAccumulator->setMaxDepth(depth); }
44
45        inline unsigned int getMaxTraversalDepth() const
46        { return _distAccumulator->getMaxDepth(); }
47
48        /** Override update and cull traversals */
49        virtual void traverse(osg::NodeVisitor &nv);
50
51        /** Catch child management functions so the Cameras can be informed
52            of added or removed children. */
53        virtual bool addChild(osg::Node *child);
54        virtual bool insertChild(unsigned int index, osg::Node *child);
55        virtual bool removeChildren(unsigned int pos, unsigned int numRemove = 1);
56        virtual bool setChild(unsigned int i, osg::Node *node);
57
58  protected:
59        typedef std::vector< osg::ref_ptr<osg::Camera> > CameraList;
60
61        ~CURRENT_CLASS();
62
63        void init();
64
65        // Creates a new Camera object with default settings
66        osg::Camera* createOrReuseCamera(const osg::Matrix& proj,
67                                double znear, double zfar,
68                                const unsigned int &camNum);
69
70        bool _active; // Whether partitioning is active on the scene
71
72        // The NodeVisitor that computes cameras for the scene
73        osg::ref_ptr<DistanceAccumulator> _distAccumulator;
74
75        osg::Camera::RenderOrder _renderOrder;
76        bool _clearColorBuffer;
77
78        // Cameras that should be used to draw the scene.  These cameras
79        // will be reused on every frame in order to save time and memory.
80        CameraList _cameraList;
81        unsigned int _numCameras; // Number of Cameras actually being used
82};
83#undef CURRENT_CLASS
84
85#endif
Note: See TracBrowser for help on using the browser.