OverlayNode
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGSIM_OVERLAYNODE
#define OSGSIM_OVERLAYNODE 1
#include <osg/buffered_value>
#include <osg/Camera>
#include <osg/Texture2D>
#include <osg/TexGenNode>
#include <osg/Geode>
#include <osgUtil/CullVisitor>
#include <osgSim/Export>
namespace osgSim {
class OSGSIM_EXPORT OverlayNode : public osg::Group
{
public :
enum OverlayTechnique
{
OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY,
VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY,
VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY
};
OverlayNode(OverlayTechnique technique=OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY);
OverlayNode(const OverlayNode& es, const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Node(osgSim, OverlayNode);
virtual void traverse(osg::NodeVisitor& nv);
void setOverlayTechnique(OverlayTechnique technique);
OverlayTechnique getOverlayTechnique() const { return _overlayTechnique; }
void setRenderTargetImplementation(osg::Camera::RenderTargetImplementation impl);
void setOverlaySubgraph(osg::Node* node);
template<class T> void setOverlaySubgraph(const osg::ref_ptr<T>& node) { setOverlaySubgraph(node.get()); }
osg::Node* getOverlaySubgraph() { return _overlaySubgraph.get(); }
const osg::Node* getOverlaySubgraph() const { return _overlaySubgraph.get(); }
void dirtyOverlayTexture();
void setContinuousUpdate(bool update) { _continuousUpdate = update; }
bool getContinuousUpdate() const { return _continuousUpdate; }
void setOverlayBaseHeight(double baseHeight) { _overlayBaseHeight = baseHeight; }
double getOverlayBaseHeight() const { return _overlayBaseHeight; }
void setOverlayClearColor(const osg::Vec4& color) { _overlayClearColor = color; }
const osg::Vec4& getOverlayClearColor() const { return _overlayClearColor; }
void setTexEnvMode(GLenum mode);
GLenum getTexEnvMode() const { return _texEnvMode; }
void setOverlayTextureUnit(unsigned int unit);
unsigned int getOverlayTextureUnit() const { return _textureUnit; }
void setOverlayTextureSizeHint(unsigned int size);
unsigned int getOverlayTextureSizeHint() const { return _textureSizeHint; }
virtual void setThreadSafeRefUnref(bool threadSafe);
virtual void resizeGLObjectBuffers(unsigned int /*maxSize*/);
virtual void releaseGLObjects(osg::State* = 0) const;
protected :
virtual ~OverlayNode() {}
void init();
void init_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY();
void init_VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY();
void init_VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY();
void traverse_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY(osg::NodeVisitor& nv);
void traverse_VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY(osg::NodeVisitor& nv);
void traverse_VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY(osg::NodeVisitor& nv);
void updateMainSubgraphStateSet();
typedef osg::buffered_value< int > TextureObjectValidList;
mutable TextureObjectValidList _textureObjectValidList;
OverlayTechnique _overlayTechnique;
// overlay subgraph is render to a texture
osg::ref_ptr<osg::Node> _overlaySubgraph;
osg::ref_ptr<osg::StateSet> _overlayStateSet;
osg::ref_ptr<osg::StateSet> _mainStateSet;
// texture to render to, and to read from.
GLenum _texEnvMode;
unsigned int _textureUnit;
unsigned int _textureSizeHint;
osg::Vec4 _overlayClearColor;
bool _continuousUpdate;
double _overlayBaseHeight;
bool _updateCamera;
osg::Camera::RenderTargetImplementation _renderTargetImpl;
struct OverlayData : public osg::Referenced
{
void setThreadSafeRefUnref(bool threadSafe);
void resizeGLObjectBuffers(unsigned int maxSize);
void releaseGLObjects(osg::State* state= 0) const;
osg::ref_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::StateSet> _overlayStateSet;
osg::ref_ptr<osg::StateSet> _mainSubgraphStateSet;
osg::ref_ptr<osg::TexGenNode> _texgenNode;
osg::ref_ptr<osg::Texture2D> _texture;
osg::Polytope _textureFrustum;
osg::ref_ptr<osg::Geode> _geode;
osg::ref_ptr<osg::Program> _mainSubgraphProgram;
osg::ref_ptr<osg::Uniform> _y0;
osg::ref_ptr<osg::Uniform> _lightingEnabled;
};
typedef std::map<osgUtil::CullVisitor*, osg::ref_ptr<OverlayData> > OverlayDataMap;
OpenThreads::Mutex _overlayDataMapMutex;
OverlayDataMap _overlayDataMap;
OverlayNode::OverlayData* getOverlayData(osgUtil::CullVisitor* cv);
};
}
#endif
Camera
CullVisitor
Geode
TexGenNode
Texture2D
buffered_value
OpenThreads::Mutex
This class provides an object-oriented thread mutex interface.
Definition Mutex:31
osgSim::OverlayNode::_overlayClearColor
osg::Vec4 _overlayClearColor
Definition OverlayNode:157
osgSim::OverlayNode::_renderTargetImpl
osg::Camera::RenderTargetImplementation _renderTargetImpl
Definition OverlayNode:163
osgSim::OverlayNode::traverse_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
void traverse_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY(osg::NodeVisitor &nv)
osgSim::OverlayNode::setOverlayBaseHeight
void setOverlayBaseHeight(double baseHeight)
Definition OverlayNode:83
osgSim::OverlayNode::_overlayDataMap
OverlayDataMap _overlayDataMap
Definition OverlayNode:189
osgSim::OverlayNode::init_VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY
void init_VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY()
osgSim::OverlayNode::init_VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
void init_VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY()
osgSim::OverlayNode::setContinuousUpdate
void setContinuousUpdate(bool update)
Definition OverlayNode:73
osgSim::OverlayNode::init
void init()
osgSim::OverlayNode::setOverlaySubgraph
void setOverlaySubgraph(osg::Node *node)
osgSim::OverlayNode::OverlayNode
OverlayNode(const OverlayNode &es, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgSim::OverlayNode::_texEnvMode
GLenum _texEnvMode
Definition OverlayNode:154
osgSim::OverlayNode::setOverlayTextureUnit
void setOverlayTextureUnit(unsigned int unit)
osgSim::OverlayNode::releaseGLObjects
virtual void releaseGLObjects(osg::State *=0) const
osgSim::OverlayNode::setOverlayClearColor
void setOverlayClearColor(const osg::Vec4 &color)
Definition OverlayNode:89
osgSim::OverlayNode::traverse_VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY
void traverse_VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY(osg::NodeVisitor &nv)
osgSim::OverlayNode::setTexEnvMode
void setTexEnvMode(GLenum mode)
osgSim::OverlayNode::_overlayBaseHeight
double _overlayBaseHeight
Definition OverlayNode:160
osgSim::OverlayNode::getOverlaySubgraph
osg::Node * getOverlaySubgraph()
Definition OverlayNode:63
osgSim::OverlayNode::setOverlayTechnique
void setOverlayTechnique(OverlayTechnique technique)
osgSim::OverlayNode::getOverlayData
OverlayNode::OverlayData * getOverlayData(osgUtil::CullVisitor *cv)
osgSim::OverlayNode::dirtyOverlayTexture
void dirtyOverlayTexture()
osgSim::OverlayNode::setOverlaySubgraph
void setOverlaySubgraph(const osg::ref_ptr< T > &node)
Definition OverlayNode:60
osgSim::OverlayNode::getTexEnvMode
GLenum getTexEnvMode() const
Definition OverlayNode:98
osgSim::OverlayNode::getOverlayClearColor
const osg::Vec4 & getOverlayClearColor() const
Definition OverlayNode:92
osgSim::OverlayNode::getContinuousUpdate
bool getContinuousUpdate() const
Definition OverlayNode:76
osgSim::OverlayNode::setOverlayTextureSizeHint
void setOverlayTextureSizeHint(unsigned int size)
osgSim::OverlayNode::getOverlayTextureSizeHint
unsigned int getOverlayTextureSizeHint() const
Definition OverlayNode:110
osgSim::OverlayNode::_updateCamera
bool _updateCamera
Definition OverlayNode:161
osgSim::OverlayNode::META_Node
META_Node(osgSim, OverlayNode)
osgSim::OverlayNode::traverse_VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
void traverse_VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY(osg::NodeVisitor &nv)
osgSim::OverlayNode::TextureObjectValidList
osg::buffered_value< int > TextureObjectValidList
Definition OverlayNode:140
osgSim::OverlayNode::_overlaySubgraph
osg::ref_ptr< osg::Node > _overlaySubgraph
Definition OverlayNode:148
osgSim::OverlayNode::_overlayTechnique
OverlayTechnique _overlayTechnique
Definition OverlayNode:144
osgSim::OverlayNode::init_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
void init_OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY()
osgSim::OverlayNode::_overlayDataMapMutex
OpenThreads::Mutex _overlayDataMapMutex
Definition OverlayNode:188
osgSim::OverlayNode::traverse
virtual void traverse(osg::NodeVisitor &nv)
osgSim::OverlayNode::_continuousUpdate
bool _continuousUpdate
Definition OverlayNode:159
osgSim::OverlayNode::_textureUnit
unsigned int _textureUnit
Definition OverlayNode:155
osgSim::OverlayNode::_textureSizeHint
unsigned int _textureSizeHint
Definition OverlayNode:156
osgSim::OverlayNode::_mainStateSet
osg::ref_ptr< osg::StateSet > _mainStateSet
Definition OverlayNode:151
osgSim::OverlayNode::setRenderTargetImplementation
void setRenderTargetImplementation(osg::Camera::RenderTargetImplementation impl)
osgSim::OverlayNode::getOverlaySubgraph
const osg::Node * getOverlaySubgraph() const
Definition OverlayNode:66
osgSim::OverlayNode::_overlayStateSet
osg::ref_ptr< osg::StateSet > _overlayStateSet
Definition OverlayNode:150
osgSim::OverlayNode::getOverlayBaseHeight
double getOverlayBaseHeight() const
Definition OverlayNode:86
osgSim::OverlayNode::getOverlayTechnique
OverlayTechnique getOverlayTechnique() const
Definition OverlayNode:52
osgSim::OverlayNode::_textureObjectValidList
TextureObjectValidList _textureObjectValidList
Definition OverlayNode:142
osgSim::OverlayNode::resizeGLObjectBuffers
virtual void resizeGLObjectBuffers(unsigned int)
osgSim::OverlayNode::OverlayTechnique
OverlayTechnique
Definition OverlayNode:36
osgSim::OverlayNode::OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
@ OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
Definition OverlayNode:37
osgSim::OverlayNode::VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
@ VIEW_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY
Definition OverlayNode:38
osgSim::OverlayNode::VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY
@ VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY
Definition OverlayNode:39
osgSim::OverlayNode::~OverlayNode
virtual ~OverlayNode()
Definition OverlayNode:126
osgSim::OverlayNode::getOverlayTextureUnit
unsigned int getOverlayTextureUnit() const
Definition OverlayNode:104
osgSim::OverlayNode::OverlayDataMap
std::map< osgUtil::CullVisitor *, osg::ref_ptr< OverlayData > > OverlayDataMap
Definition OverlayNode:186
osgSim::OverlayNode::updateMainSubgraphStateSet
void updateMainSubgraphStateSet()
osgSim::OverlayNode::OverlayNode
OverlayNode(OverlayTechnique technique=OBJECT_DEPENDENT_WITH_ORTHOGRAPHIC_OVERLAY)
osgSim::OverlayNode::setThreadSafeRefUnref
virtual void setThreadSafeRefUnref(bool threadSafe)
osgUtil::CullVisitor
Definition CullVisitor:49
osg::Camera::RenderTargetImplementation
RenderTargetImplementation
Definition Camera:290
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Group
Definition Group:29
osg::NodeVisitor
Definition NodeVisitor:82
osg::Node
Definition Node:72
osg::Polytope
Definition Polytope:26
osg::Referenced
Definition Referenced:44
osg::State
Definition State:80
osg::buffered_value< int >
osg::ref_ptr
Definition ref_ptr:32
osg::ref_ptr::get
T * get() const
Definition ref_ptr:117
osgSim
Definition BlinkSequence:27
osg::Vec4
Vec4f Vec4
Definition Vec4:21
Export
OSGSIM_EXPORT
#define OSGSIM_EXPORT
Definition osgSim/Export:38
osgSim::OverlayNode::OverlayData
Definition OverlayNode:166
osgSim::OverlayNode::OverlayData::_mainSubgraphStateSet
osg::ref_ptr< osg::StateSet > _mainSubgraphStateSet
Definition OverlayNode:174
osgSim::OverlayNode::OverlayData::setThreadSafeRefUnref
void setThreadSafeRefUnref(bool threadSafe)
osgSim::OverlayNode::OverlayData::releaseGLObjects
void releaseGLObjects(osg::State *state=0) const
osgSim::OverlayNode::OverlayData::resizeGLObjectBuffers
void resizeGLObjectBuffers(unsigned int maxSize)
osgSim::OverlayNode::OverlayData::_y0
osg::ref_ptr< osg::Uniform > _y0
Definition OverlayNode:182
osgSim::OverlayNode::OverlayData::_lightingEnabled
osg::ref_ptr< osg::Uniform > _lightingEnabled
Definition OverlayNode:183
osgSim::OverlayNode::OverlayData::_geode
osg::ref_ptr< osg::Geode > _geode
Definition OverlayNode:178
osgSim::OverlayNode::OverlayData::_texgenNode
osg::ref_ptr< osg::TexGenNode > _texgenNode
Definition OverlayNode:175
osgSim::OverlayNode::OverlayData::_overlayStateSet
osg::ref_ptr< osg::StateSet > _overlayStateSet
Definition OverlayNode:173
osgSim::OverlayNode::OverlayData::_texture
osg::ref_ptr< osg::Texture2D > _texture
Definition OverlayNode:176
osgSim::OverlayNode::OverlayData::_camera
osg::ref_ptr< osg::Camera > _camera
Definition OverlayNode:172
osgSim::OverlayNode::OverlayData::_mainSubgraphProgram
osg::ref_ptr< osg::Program > _mainSubgraphProgram
Definition OverlayNode:180
osgSim::OverlayNode::OverlayData::_textureFrustum
osg::Polytope _textureFrustum
Definition OverlayNode:177