openscenegraph
SceneView
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 OSGUTIL_SCENEVIEW
15#define OSGUTIL_SCENEVIEW 1
16
17#include <osg/Node>
18#include <osg/StateSet>
19#include <osg/Light>
20#include <osg/FrameStamp>
21#include <osg/DisplaySettings>
22#include <osg/CollectOccludersVisitor>
23#include <osg/CullSettings>
24#include <osg/Camera>
25
26#include <osgUtil/CullVisitor>
27
28namespace osgUtil {
29
30/**
31 * SceneView is deprecated, and is now just kept for backwards compatibility.
32 * It is recommend that you use osgViewer::Viewer/Composite in combination
33 * with osgViewer::GraphicsWindowEmbedded for embedded rendering support as
34 * this provides a greater range of functionality and consistency of API.
35*/
36class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
37{
38 public:
39
40 /** Construct a default scene view.*/
41 SceneView(osg::DisplaySettings* ds=NULL);
42
43 SceneView(const SceneView& sceneview, const osg::CopyOp& copyop = osg::CopyOp());
44
45 META_Object(osgUtil, SceneView);
46
47 enum Options
48 {
49 NO_SCENEVIEW_LIGHT = 0x0,
50 HEADLIGHT = 0x1,
51 SKY_LIGHT = 0x2,
52 COMPILE_GLOBJECTS_AT_INIT = 0x4,
53 APPLY_GLOBAL_DEFAULTS = 0x8,
54 CLEAR_GLOBAL_STATESET = 0x10,
55 STANDARD_SETTINGS = HEADLIGHT |
56 COMPILE_GLOBJECTS_AT_INIT |
57 APPLY_GLOBAL_DEFAULTS |
58 CLEAR_GLOBAL_STATESET
59
60 };
61
62 /* Set defaults. */
63 virtual void setDefaults() { setDefaults(STANDARD_SETTINGS); }
64
65 /** Set scene view to use default global state, light, camera
66 * and render visitor.
67 */
68 virtual void setDefaults(unsigned int options);
69
70 /** Set the camera used to represent the camera view of this SceneView.*/
71 void setCamera(osg::Camera* camera, bool assumeOwnershipOfCamera = true);
72
73 /** Get the camera used to represent the camera view of this SceneView.*/
74 osg::Camera* getCamera() { return _camera.get(); }
75
76 /** Get the const camera used to represent the camera view of this SceneView.*/
77 const osg::Camera* getCamera() const { return _camera.get(); }
78
79 /** Set the data to view. The data will typically be
80 * an osg::Scene but can be any osg::Node type.
81 */
82 void setSceneData(osg::Node* node);
83
84 /** Get the scene data to view. The data will typically be
85 * an osg::Scene but can be any osg::Node type.
86 */
87 osg::Node* getSceneData(unsigned int childNo=0) { return (_camera->getNumChildren()>childNo) ? _camera->getChild(childNo) : 0; }
88
89 /** Get the const scene data which to view. The data will typically be
90 * an osg::Scene but can be any osg::Node type.
91 */
92 const osg::Node* getSceneData(unsigned int childNo=0) const { return (_camera->getNumChildren()>childNo) ? _camera->getChild(childNo) : 0; }
93
94 /** Get the number of scene data subgraphs added to the SceneView's camera.*/
95 unsigned int getNumSceneData() const { return _camera->getNumChildren(); }
96
97 /** Set the viewport of the scene view to use specified osg::Viewport. */
98 void setViewport(osg::Viewport* viewport) { _camera->setViewport(viewport); }
99
100 /** Set the viewport of the scene view to specified dimensions. */
101 void setViewport(int x,int y,int width,int height) { _camera->setViewport(x,y,width,height); }
102
103
104 /** Get the viewport. */
105 osg::Viewport* getViewport() { return (_camera->getViewport()!=0) ? _camera->getViewport() : 0; }
106
107 /** Get the const viewport. */
108 const osg::Viewport* getViewport() const { return (_camera->getViewport()!=0) ? _camera->getViewport() : 0; }
109
110 /** Set the DisplaySettings. */
111 inline void setDisplaySettings(osg::DisplaySettings* vs) { _displaySettings = vs; }
112
113 /** Get the const DisplaySettings */
114 inline const osg::DisplaySettings* getDisplaySettings() const { return _displaySettings.get(); }
115
116 /** Get the DisplaySettings */
117 inline osg::DisplaySettings* getDisplaySettings() { return _displaySettings.get(); }
118
119
120 /** Set the color used in glClearColor().
121 Defaults to an off blue color.*/
122 void setClearColor(const osg::Vec4& color) { _camera->setClearColor(color); }
123
124 /** Get the color used in glClearColor.*/
125 const osg::Vec4& getClearColor() const { return _camera->getClearColor(); }
126
127
128 /** Manually set the redraw interlaced stereo stencil mask request flag to control whether to redraw the stencil buffer on the next frame.*/
129 void setRedrawInterlacedStereoStencilMask(bool flag) { _redrawInterlacedStereoStencilMask = flag; }
130
131 /** Get the redraw interlaced stereo stencil mask request flag.*/
132 bool getRedrawInterlacedStereoStencilMask() const { return _redrawInterlacedStereoStencilMask; }
133
134
135 void setGlobalStateSet(osg::StateSet* state) { _globalStateSet = state; }
136 osg::StateSet* getGlobalStateSet() { return _globalStateSet.get(); }
137 const osg::StateSet* getGlobalStateSet() const { return _globalStateSet.get(); }
138
139 void setSecondaryStateSet(osg::StateSet* state) { _secondaryStateSet = state; }
140 osg::StateSet* getSecondaryStateSet() { return _secondaryStateSet.get(); }
141 const osg::StateSet* getSecondaryStateSet() const { return _secondaryStateSet.get(); }
142
143 void setLocalStateSet(osg::StateSet* state) { _localStateSet = state; }
144 osg::StateSet* getLocalStateSet() { return _localStateSet.get(); }
145 const osg::StateSet* getLocalStateSet() const { return _localStateSet.get(); }
146
147 enum ActiveUniforms
148 {
149 FRAME_NUMBER_UNIFORM = 1,
150 FRAME_TIME_UNIFORM = 2,
151 DELTA_FRAME_TIME_UNIFORM = 4,
152 SIMULATION_TIME_UNIFORM = 8,
153 DELTA_SIMULATION_TIME_UNIFORM = 16,
154 VIEW_MATRIX_UNIFORM = 32,
155 VIEW_MATRIX_INVERSE_UNIFORM = 64,
156 DEFAULT_UNIFORMS = FRAME_NUMBER_UNIFORM |
157 FRAME_TIME_UNIFORM |
158 DELTA_FRAME_TIME_UNIFORM |
159 SIMULATION_TIME_UNIFORM |
160 DELTA_SIMULATION_TIME_UNIFORM |
161 VIEW_MATRIX_UNIFORM |
162 VIEW_MATRIX_INVERSE_UNIFORM,
163 ALL_UNIFORMS = 0x7FFFFFFF
164 };
165
166 /** Set the uniforms that SceneView should set set up on each frame.*/
167 void setActiveUniforms(int activeUniforms) { _activeUniforms = activeUniforms; }
168
169 /** Get the uniforms that SceneView should set set up on each frame.*/
170 int getActiveUniforms() const { return _activeUniforms; }
171
172 void updateUniforms();
173
174
175 typedef Options LightingMode;
176
177 void setLightingMode(LightingMode mode);
178 LightingMode getLightingMode() const { return _lightingMode; }
179
180 void setLight(osg::Light* light) { _light = light; }
181 osg::Light* getLight() { return _light.get(); }
182 const osg::Light* getLight() const { return _light.get(); }
183
184 void setState(osg::State* state) { _renderInfo.setState(state); }
185 osg::State* getState() { return _renderInfo.getState(); }
186 const osg::State* getState() const { return _renderInfo.getState(); }
187
188 void setView(osg::View* view) { _camera->setView(view); }
189 osg::View* getView() { return _camera->getView(); }
190 const osg::View* getView() const { return _camera->getView(); }
191
192 void setRenderInfo(osg::RenderInfo& renderInfo) { _renderInfo = renderInfo; }
193 osg::RenderInfo& getRenderInfo() { return _renderInfo; }
194 const osg::RenderInfo& getRenderInfo() const { return _renderInfo; }
195
196
197
198 /** Set the projection matrix. Can be thought of as setting the lens of a camera. */
199 inline void setProjectionMatrix(const osg::Matrixf& matrix) { _camera->setProjectionMatrix(matrix); }
200
201 /** Set the projection matrix. Can be thought of as setting the lens of a camera. */
202 inline void setProjectionMatrix(const osg::Matrixd& matrix) { _camera->setProjectionMatrix(matrix); }
203
204 /** Set to an orthographic projection. See OpenGL glOrtho documentation for further details.*/
205 void setProjectionMatrixAsOrtho(double left, double right,
206 double bottom, double top,
207 double zNear, double zFar);
208
209 /** Set to a 2D orthographic projection. See OpenGL glOrtho2D documentation for further details.*/
210 void setProjectionMatrixAsOrtho2D(double left, double right,
211 double bottom, double top);
212
213 /** Set to a perspective projection. See OpenGL glFrustum documentation for further details.*/
214 void setProjectionMatrixAsFrustum(double left, double right,
215 double bottom, double top,
216 double zNear, double zFar);
217
218 /** Create a symmetrical perspective projection, See OpenGL gluPerspective documentation for further details.
219 * Aspect ratio is defined as width/height.*/
220 void setProjectionMatrixAsPerspective(double fovy,double aspectRatio,
221 double zNear, double zFar);
222
223 /** Get the projection matrix.*/
224 osg::Matrixd& getProjectionMatrix() { return _camera->getProjectionMatrix(); }
225
226 /** Get the const projection matrix.*/
227 const osg::Matrixd& getProjectionMatrix() const { return _camera->getProjectionMatrix(); }
228
229 /** Get the orthographic settings of the orthographic projection matrix.
230 * Returns false if matrix is not an orthographic matrix, where parameter values are undefined.*/
231 bool getProjectionMatrixAsOrtho(double& left, double& right,
232 double& bottom, double& top,
233 double& zNear, double& zFar) const;
234
235 /** Get the frustum setting of a perspective projection matrix.
236 * Returns false if matrix is not a perspective matrix, where parameter values are undefined.*/
237 bool getProjectionMatrixAsFrustum(double& left, double& right,
238 double& bottom, double& top,
239 double& zNear, double& zFar) const;
240
241 /** Get the frustum setting of a symmetric perspective projection matrix.
242 * Returns false if matrix is not a perspective matrix, where parameter values are undefined.
243 * Note, if matrix is not a symmetric perspective matrix then the shear will be lost.
244 * Asymmetric matrices occur when stereo, power walls, caves and reality center display are used.
245 * In these configurations one should use the 'getProjectionMatrixAsFrustum' method instead.*/
246 bool getProjectionMatrixAsPerspective(double& fovy,double& aspectRatio,
247 double& zNear, double& zFar) const;
248
249
250 /** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
251 inline void setViewMatrix(const osg::Matrixf& matrix) { _camera->setViewMatrix(matrix); }
252
253 /** Set the view matrix. Can be thought of as setting the position of the world relative to the camera in camera coordinates. */
254 inline void setViewMatrix(const osg::Matrixd& matrix) { _camera->setViewMatrix(matrix); }
255
256 /** Set the position and orientation components of the view matrix, using the same convention as gluLookAt. */
257 void setViewMatrixAsLookAt(const osg::Vec3& eye,const osg::Vec3& center,const osg::Vec3& up);
258
259 /** Get the view matrix. */
260 osg::Matrixd& getViewMatrix() { return _camera->getViewMatrix(); }
261
262 /** Get the const view matrix. */
263 const osg::Matrixd& getViewMatrix() const { return _camera->getViewMatrix(); }
264
265 /** Get the position and orientation components of a modelview matrix, using the same convention as gluLookAt. */
266 void getViewMatrixAsLookAt(osg::Vec3& eye,osg::Vec3& center,osg::Vec3& up,float lookDistance=1.0f) const;
267
268
269
270
271 void setInitVisitor(osg::NodeVisitor* av) { _initVisitor = av; }
272 osg::NodeVisitor* getInitVisitor() { return _initVisitor.get(); }
273 const osg::NodeVisitor* getInitVisitor() const { return _initVisitor.get(); }
274
275
276 void setUpdateVisitor(osg::NodeVisitor* av) { _updateVisitor = av; }
277 osg::NodeVisitor* getUpdateVisitor() { return _updateVisitor.get(); }
278 const osg::NodeVisitor* getUpdateVisitor() const { return _updateVisitor.get(); }
279
280
281 void setCullVisitor(osgUtil::CullVisitor* cv) { _cullVisitor = cv; }
282 osgUtil::CullVisitor* getCullVisitor() { return _cullVisitor.get(); }
283 const osgUtil::CullVisitor* getCullVisitor() const { return _cullVisitor.get(); }
284
285 void setCullVisitorLeft(osgUtil::CullVisitor* cv) { _cullVisitorLeft = cv; }
286 osgUtil::CullVisitor* getCullVisitorLeft() { return _cullVisitorLeft.get(); }
287 const osgUtil::CullVisitor* getCullVisitorLeft() const { return _cullVisitorLeft.get(); }
288
289 void setCullVisitorRight(osgUtil::CullVisitor* cv) { _cullVisitorRight = cv; }
290 osgUtil::CullVisitor* getCullVisitorRight() { return _cullVisitorRight.get(); }
291 const osgUtil::CullVisitor* getCullVisitorRight() const { return _cullVisitorRight.get(); }
292
293 void setCollectOccludersVisitor(osg::CollectOccludersVisitor* cov) { _collectOccludersVisitor = cov; }
294 osg::CollectOccludersVisitor* getCollectOccludersVisitor() { return _collectOccludersVisitor.get(); }
295 const osg::CollectOccludersVisitor* getCollectOccludersVisitor() const { return _collectOccludersVisitor.get(); }
296
297
298 void setStateGraph(osgUtil::StateGraph* rg) { _stateGraph = rg; }
299 osgUtil::StateGraph* getStateGraph() { return _stateGraph.get(); }
300 const osgUtil::StateGraph* getStateGraph() const { return _stateGraph.get(); }
301
302 void setStateGraphLeft(osgUtil::StateGraph* rg) { _stateGraphLeft = rg; }
303 osgUtil::StateGraph* getStateGraphLeft() { return _stateGraphLeft.get(); }
304 const osgUtil::StateGraph* getStateGraphLeft() const { return _stateGraphLeft.get(); }
305
306 void setStateGraphRight(osgUtil::StateGraph* rg) { _stateGraphRight = rg; }
307 osgUtil::StateGraph* getStateGraphRight() { return _stateGraphRight.get(); }
308 const osgUtil::StateGraph* getStateGraphRight() const { return _stateGraphRight.get(); }
309
310
311 void setRenderStage(osgUtil::RenderStage* rs) { _renderStage = rs; }
312 osgUtil::RenderStage* getRenderStage() { return _renderStage.get(); }
313 const osgUtil::RenderStage* getRenderStage() const { return _renderStage.get(); }
314
315 void setRenderStageLeft(osgUtil::RenderStage* rs) { _renderStageLeft = rs; }
316 osgUtil::RenderStage* getRenderStageLeft() { return _renderStageLeft.get(); }
317 const osgUtil::RenderStage* getRenderStageLeft() const { return _renderStageLeft.get(); }
318
319 void setRenderStageRight(osgUtil::RenderStage* rs) { _renderStageRight = rs; }
320 osgUtil::RenderStage* getRenderStageRight() { return _renderStageRight.get(); }
321 const osgUtil::RenderStage* getRenderStageRight() const { return _renderStageRight.get(); }
322
323 /** search through any pre and post RenderStages that reference a Camera, and take a reference to each of these cameras to prevent them being deleted while they are still be used by the drawing thread.*/
324 void collateReferencesToDependentCameras();
325
326 /** clear the reference to any any dependent cameras.*/
327 void clearReferencesToDependentCameras();
328
329
330 /** Set the draw buffer value used at the start of each frame draw. Note, overridden in quad buffer stereo mode */
331 void setDrawBufferValue( GLenum drawBufferValue ) { _camera->setDrawBuffer(drawBufferValue); }
332
333 /** Get the draw buffer value used at the start of each frame draw. */
334 GLenum getDrawBufferValue() const { return _camera->getDrawBuffer(); }
335
336
337 /** FusionDistanceMode is used only when working in stereo.*/
338 enum FusionDistanceMode
339 {
340 /** Use fusion distance from the value set on the SceneView.*/
341 USE_FUSION_DISTANCE_VALUE,
342 /** Compute the fusion distance by multiplying the screen distance by the fusion distance value.*/
343 PROPORTIONAL_TO_SCREEN_DISTANCE
344 };
345
346 /** Set the FusionDistanceMode and Value. Note, is used only when working in stereo.*/
347 void setFusionDistance(FusionDistanceMode mode,float value=1.0f)
348 {
349 _fusionDistanceMode = mode;
350 _fusionDistanceValue = value;
351 }
352
353 /** Get the FusionDistanceMode.*/
354 FusionDistanceMode getFusionDistanceMode() const { return _fusionDistanceMode; }
355
356 /** Get the FusionDistanceValue. Note, only used for USE_FUSION_DISTANCE_VALUE & PROPORTIONAL_TO_SCREEN_DISTANCE modes.*/
357 float getFusionDistanceValue() const { return _fusionDistanceValue; }
358
359
360 /** Set whether the draw method should call renderer->prioritizeTexture.*/
361 void setPrioritizeTextures(bool pt) { _prioritizeTextures = pt; }
362
363 /** Get whether the draw method should call renderer->prioritizeTexture.*/
364 bool getPrioritizeTextures() const { return _prioritizeTextures; }
365
366 /** Callback for overidding the default method for compute the offset projection and view matrices.*/
367 struct ComputeStereoMatricesCallback : public osg::Referenced
368 {
369 virtual osg::Matrixd computeLeftEyeProjection(const osg::Matrixd& projection) const = 0;
370 virtual osg::Matrixd computeLeftEyeView(const osg::Matrixd& view) const = 0;
371
372 virtual osg::Matrixd computeRightEyeProjection(const osg::Matrixd& projection) const = 0;
373 virtual osg::Matrixd computeRightEyeView(const osg::Matrixd& view) const = 0;
374 };
375
376 void setComputeStereoMatricesCallback(ComputeStereoMatricesCallback* callback) { _computeStereoMatricesCallback=callback; }
377 ComputeStereoMatricesCallback* getComputeStereoMatricesCallback() { return _computeStereoMatricesCallback.get(); }
378 const ComputeStereoMatricesCallback* getComputeStereoMatricesCallback() const { return _computeStereoMatricesCallback.get(); }
379
380 /** Calculate the object coordinates of a point in window coordinates.
381 Note, current implementation requires that SceneView::draw() has been previously called
382 for projectWindowIntoObject to produce valid values. Consistent with OpenGL,
383 window coordinates are calculated relative to the bottom left of the window.
384 Returns true on successful projection.
385 */
386 bool projectWindowIntoObject(const osg::Vec3& window,osg::Vec3& object) const;
387
388 /** Calculate the object coordinates of a window x,y when projected onto the near and far planes.
389 Note, current implementation requires that SceneView::draw() has been previously called
390 for projectWindowIntoObject to produce valid values. Consistent with OpenGL,
391 window coordinates are calculated relative to the bottom left of the window.
392 Returns true on successful projection.
393 */
394 bool projectWindowXYIntoObject(int x,int y,osg::Vec3& near_point,osg::Vec3& far_point) const;
395
396 /** Calculate the window coordinates of a point in object coordinates.
397 Note, current implementation requires that SceneView::draw() has been previously called
398 for projectWindowIntoObject to produce valid values. Consistent with OpenGL,
399 window coordinates are calculated relative to the bottom left of the window,
400 whereas window API's normally have the top left as the origin,
401 so you may need to pass in (mouseX,window_height-mouseY,...).
402 Returns true on successful projection.
403 */
404 bool projectObjectIntoWindow(const osg::Vec3& object,osg::Vec3& window) const;
405
406
407 /** Set the frame stamp for the current frame.*/
408 inline void setFrameStamp(osg::FrameStamp* fs) { _frameStamp = fs; }
409
410 /** Get the frame stamp for the current frame.*/
411 inline osg::FrameStamp* getFrameStamp() { return _frameStamp.get(); }
412
413 /** Get the const frame stamp for the current frame.*/
414 inline const osg::FrameStamp* getFrameStamp() const { return _frameStamp.get(); }
415
416
417 inline osg::Matrixd computeLeftEyeProjection(const osg::Matrixd& projection) const
418 {
419 if (_computeStereoMatricesCallback.valid()) return _computeStereoMatricesCallback->computeLeftEyeProjection(projection);
420 else return computeLeftEyeProjectionImplementation(projection);
421 }
422
423 inline osg::Matrixd computeLeftEyeView(const osg::Matrixd& view) const
424 {
425 if (_computeStereoMatricesCallback.valid()) return _computeStereoMatricesCallback->computeLeftEyeView(view);
426 else return computeLeftEyeViewImplementation(view);
427 }
428
429 inline osg::Matrixd computeRightEyeProjection(const osg::Matrixd& projection) const
430 {
431 if (_computeStereoMatricesCallback.valid()) return _computeStereoMatricesCallback->computeRightEyeProjection(projection);
432 else return computeRightEyeProjectionImplementation(projection);
433 }
434
435 inline osg::Matrixd computeRightEyeView(const osg::Matrixd& view) const
436 {
437 if (_computeStereoMatricesCallback.valid()) return _computeStereoMatricesCallback->computeRightEyeView(view);
438 else return computeRightEyeViewImplementation(view);
439 }
440
441 /** helper function for computing the left eye projection matrix.*/
442 virtual osg::Matrixd computeLeftEyeProjectionImplementation(const osg::Matrixd& projection) const;
443
444 /** helper function for computing the left eye view matrix.*/
445 virtual osg::Matrixd computeLeftEyeViewImplementation(const osg::Matrixd& view) const;
446
447 /** helper function for computing the right eye view matrix.*/
448 virtual osg::Matrixd computeRightEyeProjectionImplementation(const osg::Matrixd& projection) const;
449
450 /** helper function for computing the right eye view matrix.*/
451 virtual osg::Matrixd computeRightEyeViewImplementation(const osg::Matrixd& view) const;
452
453
454 /** Inherit the local cull settings variable from a specified CullSettings object, according to the inheritance mask.*/
455 virtual void inheritCullSettings(const osg::CullSettings& settings) { inheritCullSettings(settings, _inheritanceMask); }
456
457 /** Inherit the local cull settings variable from a specified CullSettings object, according to the inheritance mask.*/
458 virtual void inheritCullSettings(const osg::CullSettings& settings, unsigned int inheritanceMask);
459
460
461 /** Do init traversal of the attached scene graph using Init NodeVisitor.
462 * The init traversal is called once for each SceneView, and should
463 * be used to compile display lists, texture objects and initialize data
464 * not otherwise initialized during scene graph loading. Note, is
465 * called automatically by update & cull if it hasn't already been called
466 * elsewhere. Also init() should only ever be called within a valid
467 * graphics context.*/
468 virtual void init();
469
470 /** Do app traversal of the attached scene graph using App NodeVisitor.*/
471 virtual void update();
472
473 /** Do cull traversal of the attached scene graph using Cull NodeVisitor.*/
474 virtual void cull();
475
476 /** Do draw traversal of draw bins generated by cull traversal.*/
477 virtual void draw();
478
479 /** Compute the number of dynamic objects that will be held in the rendering backend */
480 unsigned int getDynamicObjectCount() const { return _dynamicObjectCount; }
481
482 /** Release all OpenGL objects from the scene graph, such as texture objects, display lists, etc.
483 * These released scene graphs are placed in the respective delete GLObjects cache, and
484 * then need to be deleted in OpenGL by SceneView::flushAllDeleteGLObjects(). */
485 virtual void releaseAllGLObjects();
486
487 virtual void resizeGLObjectBuffers(unsigned int maxSize);
488 virtual void releaseGLObjects(osg::State* = 0) const;
489
490 /** Flush all deleted OpenGL objects, such as texture objects, display lists, etc.*/
491 virtual void flushAllDeletedGLObjects();
492
493 /** Flush deleted OpenGL objects, such as texture objects, display lists, etc., within the specified available time.*/
494 virtual void flushDeletedGLObjects(double& availableTime);
495
496 /** Extract stats for current draw list. */
497 bool getStats(Statistics& primStats);
498
499 /** Set whether the SceneView should automatically call flushDeletedObjects() on each new frame.*/
500 void setAutomaticFlush(bool automaticFlush) { _automaticFlush = automaticFlush; }
501 bool getAutomaticFlush() const { return _automaticFlush; }
502
503 void setResetColorMaskToAllOn(bool enable) { _resetColorMaskToAllEnabled = enable; }
504 bool getResetColorMaskToAllOn() const { return _resetColorMaskToAllEnabled; }
505
506 protected:
507
508 virtual ~SceneView();
509
510 /** Do cull traversal of attached scene graph using Cull NodeVisitor. Return true if computeNearFar has been done during the cull traversal.*/
511 virtual bool cullStage(const osg::Matrixd& projection,const osg::Matrixd& modelview,osgUtil::CullVisitor* cullVisitor, osgUtil::StateGraph* rendergraph, osgUtil::RenderStage* renderStage, osg::Viewport *viewport);
512
513 void computeLeftEyeViewport(const osg::Viewport *viewport);
514 void computeRightEyeViewport(const osg::Viewport *viewport);
515
516 const osg::Matrix computeMVPW() const;
517
518 void clearArea(int x,int y,int width,int height,const osg::Vec4& color);
519
520 osg::ref_ptr<osg::StateSet> _localStateSet;
521 osg::RenderInfo _renderInfo;
522
523 bool _initCalled;
524 osg::ref_ptr<osg::NodeVisitor> _initVisitor;
525 osg::ref_ptr<osg::NodeVisitor> _updateVisitor;
526 osg::ref_ptr<osgUtil::CullVisitor> _cullVisitor;
527 osg::ref_ptr<osgUtil::StateGraph> _stateGraph;
528 osg::ref_ptr<osgUtil::RenderStage> _renderStage;
529
530 osg::ref_ptr<ComputeStereoMatricesCallback> _computeStereoMatricesCallback;
531
532 osg::ref_ptr<osgUtil::CullVisitor> _cullVisitorLeft;
533 osg::ref_ptr<osgUtil::StateGraph> _stateGraphLeft;
534 osg::ref_ptr<osgUtil::RenderStage> _renderStageLeft;
535 osg::ref_ptr<osg::Viewport> _viewportLeft;
536
537 osg::ref_ptr<osgUtil::CullVisitor> _cullVisitorRight;
538 osg::ref_ptr<osgUtil::StateGraph> _stateGraphRight;
539 osg::ref_ptr<osgUtil::RenderStage> _renderStageRight;
540 osg::ref_ptr<osg::Viewport> _viewportRight;
541
542 osg::ref_ptr<osg::CollectOccludersVisitor> _collectOccludersVisitor;
543
544 osg::ref_ptr<osg::FrameStamp> _frameStamp;
545
546 osg::observer_ptr<osg::Camera> _camera;
547 osg::ref_ptr<osg::Camera> _cameraWithOwnership;
548
549 osg::ref_ptr<osg::StateSet> _globalStateSet;
550 osg::ref_ptr<osg::Light> _light;
551 osg::ref_ptr<osg::DisplaySettings> _displaySettings;
552
553 osg::ref_ptr<osg::StateSet> _secondaryStateSet;
554
555 FusionDistanceMode _fusionDistanceMode;
556 float _fusionDistanceValue;
557
558 LightingMode _lightingMode;
559
560 bool _prioritizeTextures;
561
562 bool _automaticFlush;
563 bool _requiresFlush;
564
565 int _activeUniforms;
566 double _previousFrameTime;
567 double _previousSimulationTime;
568
569 bool _redrawInterlacedStereoStencilMask;
570 int _interlacedStereoStencilWidth;
571 int _interlacedStereoStencilHeight;
572
573 unsigned int _dynamicObjectCount;
574
575 bool _resetColorMaskToAllEnabled;
576};
577
578}
579
580#endif
581