OpenSceneGraph 3.6.5
View
Go to the documentation of this file.
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 OSG_VIEW
15#define OSG_VIEW 1
16
17#include <osg/Camera>
18#include <osg/Light>
19#include <osg/Stats>
20
21#include <OpenThreads/Mutex>
22
23namespace osg {
24
29class OSG_EXPORT View : public virtual osg::Object
30{
31 public :
32
34
35 View(const osg::View& view, const osg::CopyOp& copyop=CopyOp::SHALLOW_COPY);
36
38
40 virtual void take(View& rhs);
41
42
44 void setStats(osg::Stats* stats) { _stats = stats; }
45
47 osg::Stats* getStats() { return _stats.get(); }
48
50 const osg::Stats* getStats() const { return _stats.get(); }
51
52
60
63 void setLightingMode(LightingMode lightingMode);
64
67
69 void setLight(osg::Light* light) { _light = light; }
70
72 osg::Light* getLight() { return _light.get(); }
73
75 const osg::Light* getLight() const { return _light.get(); }
76
78 void setCamera(osg::Camera* camera);
79
81 osg::Camera* getCamera() { return _camera.get(); }
82
84 const osg::Camera* getCamera() const { return _camera.get(); }
85
88
91
93 const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
94
95
98 {
99 Slave(bool useMastersSceneData=true):
100 _useMastersSceneData(useMastersSceneData) {}
101
102 Slave(osg::Camera* camera, const osg::Matrixd& projectionOffset, const osg::Matrixd& viewOffset, bool useMastersSceneData=true):
103 _camera(camera),
104 _projectionOffset(projectionOffset),
105 _viewOffset(viewOffset),
106 _useMastersSceneData(useMastersSceneData) {}
107
114
115 virtual ~Slave() {}
116
117 Slave& operator = (const Slave& rhs)
118 {
119 _camera = rhs._camera;
124 return *this;
125 }
126
127 struct UpdateSlaveCallback : public virtual Referenced
128 {
129 virtual void updateSlave(osg::View& view, osg::View::Slave& slave) = 0;
130 };
131
132 void updateSlave(View& view)
133 {
134 if (_updateSlaveCallback.valid()) _updateSlaveCallback->updateSlave(view, *this);
135 else updateSlaveImplementation(view);
136 }
137
138 virtual void updateSlaveImplementation(View& view);
139
145 };
146
147 bool addSlave(osg::Camera* camera, bool useMastersSceneData=true) { return addSlave(camera, osg::Matrix::identity(), osg::Matrix::identity(), useMastersSceneData); }
148
149 bool addSlave(osg::Camera* camera, const osg::Matrix& projectionOffset, const osg::Matrix& viewOffset, bool useMastersSceneData=true);
150
151 bool removeSlave(unsigned int pos);
152
153 unsigned int getNumSlaves() const { return static_cast<unsigned int>(_slaves.size()); }
154
155 Slave& getSlave(unsigned int pos) { return _slaves[pos]; }
156 const Slave& getSlave(unsigned int pos) const { return _slaves[pos]; }
157
158 unsigned int findSlaveIndexForCamera(osg::Camera* camera) const;
159
161
163
164 virtual void resizeGLObjectBuffers(unsigned int maxSize);
165 virtual void releaseGLObjects(osg::State* = 0) const;
166
167 protected :
168
169 virtual ~View();
170
172
174
177
179
180 typedef std::vector<Slave> Slaves;
182
184};
185
186}
187
188#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Matrixd Matrix
Definition Matrix:27
Camera - is a subclass of Transform which represents encapsulates the settings of a Camera.
Definition Camera:45
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Class which encapsulates the frame number, reference time and calendar time of specific frame,...
Definition FrameStamp:35
Definition GraphicsThread:36
Light state class which encapsulates OpenGL glLight() functionality.
Definition Light:40
Definition Matrixd:27
static Matrixd identity(void)
Definition Matrixd:444
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Definition Stats:29
View - maintains a master camera view and a list of slave cameras that are relative to this master ca...
Definition View:30
unsigned int getNumSlaves() const
Definition View:153
const osg::Camera * getCamera() const
Get the const master camera of the view.
Definition View:84
unsigned int findSlaveIndexForCamera(osg::Camera *camera) const
const osg::Stats * getStats() const
Get the Viewers Stats object.
Definition View:50
Slave & getSlave(unsigned int pos)
Definition View:155
virtual osg::GraphicsOperation * createRenderer(osg::Camera *)
Definition View:171
virtual void take(View &rhs)
Take all the settings, Camera and Slaves from the passed in view, leaving it empty.
LightingMode getLightingMode() const
Get the global lighting used for this view.
Definition View:66
void setFrameStamp(osg::FrameStamp *fs)
Set the frame stamp of the view.
Definition View:87
osg::Stats * getStats()
Get the Viewers Stats object.
Definition View:47
LightingMode
Options for controlling the global lighting used for the view.
Definition View:55
@ HEADLIGHT
Definition View:57
@ SKY_LIGHT
Definition View:58
@ NO_LIGHT
Definition View:56
LightingMode _lightingMode
Definition View:175
bool addSlave(osg::Camera *camera, const osg::Matrix &projectionOffset, const osg::Matrix &viewOffset, bool useMastersSceneData=true)
osg::Light * getLight()
Get the global lighting if assigned.
Definition View:72
osg::ref_ptr< osg::Stats > _stats
Definition View:173
const osg::FrameStamp * getFrameStamp() const
Get the frame stamp of the view.
Definition View:93
virtual void releaseGLObjects(osg::State *=0) const
If State is non-zero, this function releases any associated OpenGL objects for the specified graphics...
const osg::Light * getLight() const
Get the const global lighting if assigned.
Definition View:75
void updateSlaves()
bool addSlave(osg::Camera *camera, bool useMastersSceneData=true)
Definition View:147
View(const osg::View &view, const osg::CopyOp &copyop=CopyOp::SHALLOW_COPY)
bool removeSlave(unsigned int pos)
Slave * findSlaveForCamera(osg::Camera *camera)
void setStats(osg::Stats *stats)
Set the Stats object used to collect various frame related timing and scene graph stats.
Definition View:44
const Slave & getSlave(unsigned int pos) const
Definition View:156
virtual ~View()
void setCamera(osg::Camera *camera)
Set the master camera of the view.
Slaves _slaves
Definition View:181
osg::ref_ptr< osg::FrameStamp > _frameStamp
Definition View:183
osg::Camera * getCamera()
Get the master camera of the view.
Definition View:81
META_Object(osg, View)
void setLightingMode(LightingMode lightingMode)
Set the global lighting to use for this view.
osg::ref_ptr< osg::Camera > _camera
Definition View:178
virtual void resizeGLObjectBuffers(unsigned int maxSize)
Resize any per context GLObject buffers to specified size.
void setLight(osg::Light *light)
Get the global light.
Definition View:69
osg::ref_ptr< osg::Light > _light
Definition View:176
std::vector< Slave > Slaves
Definition View:180
osg::FrameStamp * getFrameStamp()
Get the frame stamp of the view.
Definition View:90
Slave allows one to up a camera that follows the master with a local offset to the project and view m...
Definition View:98
bool _useMastersSceneData
Definition View:143
osg::Matrixd _projectionOffset
Definition View:141
osg::ref_ptr< osg::Camera > _camera
Definition View:140
void updateSlave(View &view)
Definition View:132
Slave(bool useMastersSceneData=true)
Definition View:99
osg::Matrixd _viewOffset
Definition View:142
Slave(osg::Camera *camera, const osg::Matrixd &projectionOffset, const osg::Matrixd &viewOffset, bool useMastersSceneData=true)
Definition View:102
osg::ref_ptr< UpdateSlaveCallback > _updateSlaveCallback
Definition View:144
Slave(const Slave &rhs)
Definition View:108
virtual ~Slave()
Definition View:115
virtual void updateSlaveImplementation(View &view)
virtual void updateSlave(osg::View &view, osg::View::Slave &slave)=0
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.