27 #include "../WGETextureHud.h"
28 #include "../WGEGeodeUtils.h"
30 #include "WGEOffscreenTexturePass.h"
56 osg::Vec3( 1.0, 0.0, 0.0 ),
57 osg::Vec3( 0.0, 1.0, 0.0 ) );
58 geode->setName(
"Offscreen Rendering Proxy Plane" );
65 this->addChild( geode );
68 osg::StateSet* state = this->getOrCreateStateSet();
69 state->setMode( GL_DEPTH_TEST, osg::StateAttribute::OFF );
70 state->setMode( GL_LIGHTING, osg::StateAttribute::PROTECTED );
71 state->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
72 state->setMode( GL_BLEND, osg::StateAttribute::PROTECTED );
73 state->setMode( GL_BLEND, osg::StateAttribute::OFF );
76 setCullingActive(
false );
79 this->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
80 this->setProjectionMatrixAsOrtho2D( 0.0, 1.0, 0.0, 1.0 );
81 this->setViewMatrix( osg::Matrixd::identity() );
85 m_texMat->setMatrix( osg::Matrixd::identity() );
86 state->setTextureAttributeAndModes( 0,
m_texMat, osg::StateAttribute::ON );
95 unsigned int screenWidth =
m_pass->getViewport()->width();
96 unsigned int screenHeight =
m_pass->getViewport()->height();
98 texMat->setMatrix( osg::Matrixd::scale(
static_cast< float >( screenWidth ) /
static_cast< float >(
m_pass->
getTextureWidth() ),
102 traverse( node, nv );
This class encapsulates an OSG Camera and a corresponding framebuffer object.
size_t getTextureWidth() const
Get the size of the underlying texture.
size_t getTextureHeight() const
Get the size of the underlying texture.
Callback which aligns and renders the textures.
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
operator () - called during the update traversal.
WGEOffscreenTexturePass * m_pass
The pass used in conjunction with this callback.
osg::ref_ptr< osg::TexMat > m_texMat
The texture matrix for this pass.
virtual ~WGEOffscreenTexturePass()
Destructor.
void setup()
Sets the whole node up.
WGEOffscreenTexturePass(size_t textureWidth, size_t textureHeight, int num=0)
Creates a new offscreen rendering instance.
osg::ref_ptr< osg::Geode > genFinitePlane(double xSize, double ySize, const WPlane &p, const WColor &color=WColor(0.0, 0.7, 0.7, 1.0), bool border=false)
Generates a geode out of a Plane with a fixed size in direction of the vectors which span that plane.