root/OpenSceneGraph/trunk/include/osgViewer/CompositeViewer @ 13376

Revision 13376, 5.0 kB (checked in by robert, 2 days ago)

Added shaders to support experimental shader based displacement mapping technique osgTerrain::ShaderTerrain?.

  • 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 OSGVIEWER_CompositeViewer
15#define OSGVIEWER_CompositeViewer 1
16
17#include <osg/ArgumentParser>
18#include <osgUtil/UpdateVisitor>
19#include <osgViewer/GraphicsWindow>
20#include <osgViewer/View>
21
22namespace osgViewer {
23
24/** CompositeViewer holds one or more views to one or more scenes.*/
25class OSGVIEWER_EXPORT CompositeViewer : public ViewerBase
26{
27    public:
28
29        CompositeViewer();
30
31        CompositeViewer(const CompositeViewer&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
32
33        CompositeViewer(osg::ArgumentParser& arguments);
34
35        META_Object(osgViewer,CompositeViewer);
36
37        virtual ~CompositeViewer();
38
39        /** Read the viewer configuration from a configuration file.*/
40        bool readConfiguration(const std::string& filename);
41
42
43        /** Set the Stats object used for collect various frame related timing and scene graph stats.*/
44        virtual void setViewerStats(osg::Stats* stats) { _stats = stats; }
45
46        /** Get the Viewers Stats object.*/
47        virtual osg::Stats* getViewerStats() { return _stats.get(); }
48
49        /** Get the Viewers Stats object.*/
50        virtual const osg::Stats* getViewerStats() const { return _stats.get(); }
51
52
53        void addView(osgViewer::View* view);
54        void removeView(osgViewer::View* view);
55
56        osgViewer::View* getView(unsigned i) { return _views[i].get(); }
57        const osgViewer::View* getView(unsigned i) const { return _views[i].get(); }
58
59        unsigned int getNumViews() const { return _views.size(); }
60
61
62        /** Get whether at least of one of this viewer's windows are realized.*/
63        virtual bool isRealized() const;
64
65        /** Set up windows and associated threads.*/
66        virtual void realize();
67
68        virtual void setStartTick(osg::Timer_t tick);
69
70        void setReferenceTime(double time=0.0);
71
72        osg::FrameStamp* getFrameStamp() { return _frameStamp.get(); }
73        const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
74
75        virtual double elapsedTime();
76
77        virtual osg::FrameStamp* getViewerFrameStamp() { return getFrameStamp(); }
78
79
80        /** Execute a main frame loop.
81          * Equivalent to while (!viewer.done()) viewer.frame();
82          * Also calls realize() if the viewer is not already realized,
83          * and installs trackball manipulator if one is not already assigned.
84          */
85        virtual int run();
86
87        /** Check to see if the new frame is required, called by run() when FrameScheme is set to ON_DEMAND.*/
88        virtual bool checkNeedToDoFrame();
89
90        virtual void advance(double simulationTime=USE_REFERENCE_TIME);
91
92        virtual void eventTraversal();
93
94        virtual void updateTraversal();
95
96
97        void setCameraWithFocus(osg::Camera* camera);
98        osg::Camera* getCameraWithFocus() { return _cameraWithFocus.get(); }
99        const osg::Camera* getCameraWithFocus() const { return _cameraWithFocus.get(); }
100
101        osgViewer::View* getViewWithFocus() { return _viewWithFocus.get(); }
102        const osgViewer::View* getViewWithFocus() const { return _viewWithFocus.get(); }
103
104        virtual void getCameras(Cameras& cameras, bool onlyActive=true);
105
106        virtual void getContexts(Contexts& contexts, bool onlyValid=true);
107
108        virtual void getAllThreads(Threads& threads, bool onlyActive=true);
109
110        virtual void getOperationThreads(OperationThreads& threads, bool onlyActive=true);
111
112        virtual void getScenes(Scenes& scenes, bool onlyValid=true);
113
114        virtual void getViews(Views& views, bool onlyValid=true);
115
116
117        /** Get the keyboard and mouse usage of this viewer.*/
118        virtual void getUsage(osg::ApplicationUsage& usage) const;
119
120    protected:
121
122        void constructorInit();
123
124        virtual void viewerInit();
125
126        void generateSlavePointerData(osg::Camera* camera, osgGA::GUIEventAdapter& event);
127        void generatePointerData(osgGA::GUIEventAdapter& event);
128        void reprojectPointerData(osgGA::GUIEventAdapter& source_event, osgGA::GUIEventAdapter& dest_event);
129
130        typedef std::vector< osg::ref_ptr<osgViewer::View> > RefViews;
131        RefViews _views;
132
133        bool _firstFrame;
134
135        osg::ref_ptr<osg::Stats>            _stats;
136
137        osg::Timer_t                        _startTick;
138        osg::ref_ptr<osg::FrameStamp>       _frameStamp;
139
140        osg::observer_ptr<osg::Camera>      _cameraWithFocus;
141        osg::observer_ptr<osgViewer::View>  _viewWithFocus;
142       
143        osg::ref_ptr<osgGA::GUIEventAdapter> _previousEvent;
144
145};
146
147
148}
149
150#endif
Note: See TracBrowser for help on using the browser.