18 #ifndef AGXOSG_DEPTHPEELING_H 19 #define AGXOSG_DEPTHPEELING_H 21 #include <osg/Version> 22 #ifdef OSG_VERSION_GREATER_OR_EQUAL 23 #if OSG_VERSION_GREATER_OR_EQUAL(3,0,0) 24 # define AGX_HAVE_DEPTHPEELING 1 28 #ifdef AGX_HAVE_DEPTHPEELING 33 #include <osg/Referenced> 35 #include <osg/TextureRectangle> 36 #include <osgViewer/ViewerEventHandlers> 40 #define USE_TEXTURE_RECTANGLE 42 #define USE_PACKED_DEPTH_STENCIL 46 # pragma warning(push) 48 # pragma warning( disable : 4251 ) 64 DepthPeeling(
unsigned width,
unsigned height);
66 void setScene(osg::Node* scene);
70 void resize(
int width,
int height);
72 void setNumPasses(
unsigned numPasses);
73 unsigned getNumPasses()
const {
return m_numPasses; }
75 void setTexUnit(
unsigned texUnit);
77 void setShowAllLayers(
bool showAllLayers);
78 bool getShowAllLayers()
const;
80 void setEnable(
bool depthPeelingEnabled);
81 bool getEnable()
const {
return m_depthPeelingEnabled; }
82 bool isEnabled()
const {
return m_depthPeelingEnabled; }
84 void setOffsetValue(
unsigned offsetValue);
86 unsigned getOffsetValue()
const {
return m_offsetValue; }
88 class EventHandler :
public osgGA::GUIEventHandler {
90 EventHandler(DepthPeeling* depthPeeling);
92 bool handle(
const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&, osg::Object*, osg::NodeVisitor*);
93 using osgGA::GUIEventHandler::handle;
94 osg::ref_ptr<DepthPeeling> m_depthPeeling;
100 osg::Node*createQuad(
unsigned layerNumber,
unsigned numTiles);
102 class CullCallback :
public osg::NodeCallback {
104 CullCallback(
unsigned texUnit,
unsigned texWidth,
unsigned texHeight,
unsigned offsetValue);
106 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
111 unsigned m_texHeight;
112 unsigned m_offsetValue;
115 void createPeeling();
119 unsigned m_numPasses;
122 unsigned m_texHeight;
123 bool m_showAllLayers;
124 bool m_depthPeelingEnabled;
125 unsigned m_offsetValue;
128 osg::ref_ptr<osg::Group> m_root;
131 osg::ref_ptr<osg::Group> m_scene;
134 osg::ref_ptr<osg::Camera> m_compositeCamera;
136 #ifdef USE_TEXTURE_RECTANGLE 137 osg::ref_ptr<osg::TextureRectangle> m_depthTextures[2];
138 std::vector<osg::ref_ptr<osg::TextureRectangle> > m_colorTextures;
140 osg::ref_ptr<osg::Texture2D> m_depthTextures[2];
141 std::vector<osg::ref_ptr<osg::Texture2D> > m_colorTextures;
149 # pragma warning(pop)
The agxOSG namespace provides functionality for visualizing AGX simulations with OpenSceneGraph.