From 89fdc9fa37bd69bc8b0de12b71bd7d0edd6718fe Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 16 Feb 2007 13:17:04 +0000 Subject: [PATCH] Removed debugging readImageFile, and done further work on RTT setup. --- src/osgShadow/ShadowTexture.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/osgShadow/ShadowTexture.cpp b/src/osgShadow/ShadowTexture.cpp index 9d332b0d7..647352220 100644 --- a/src/osgShadow/ShadowTexture.cpp +++ b/src/osgShadow/ShadowTexture.cpp @@ -15,8 +15,6 @@ #include #include -#include - using namespace osgShadow; class CameraCullCallback : public osg::NodeCallback @@ -59,6 +57,7 @@ ShadowTexture::ShadowTexture(const ShadowTexture& copy, const osg::CopyOp& copyo void ShadowTexture::init() { + if (!_shadowedScene) return; unsigned int tex_width = 512; unsigned int tex_height = 512; @@ -72,8 +71,6 @@ void ShadowTexture::init() _texture->setWrap(osg::Texture2D::WRAP_T,osg::Texture2D::CLAMP_TO_BORDER); _texture->setBorderColor(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); - _texture->setImage(osgDB::readImageFile("Images/road.png")); - // set up the render to texture camera. { // create the camera @@ -90,7 +87,8 @@ void ShadowTexture::init() _camera->setRenderOrder(osg::Camera::PRE_RENDER); // tell the camera to use OpenGL frame buffer object where supported. - _camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); + //_camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); + _camera->setRenderTargetImplementation(osg::Camera::SEPERATE_WINDOW); // attach the texture and use it as the color buffer. _camera->attach(osg::Camera::COLOR_BUFFER, _texture.get()); @@ -113,11 +111,14 @@ void ShadowTexture::init() _stateset->setTextureMode(_textureUnit,GL_TEXTURE_GEN_R,osg::StateAttribute::ON); _stateset->setTextureMode(_textureUnit,GL_TEXTURE_GEN_Q,osg::StateAttribute::ON); } + + _dirty = false; } -void ShadowTexture::update(osg::NodeVisitor&) +void ShadowTexture::update(osg::NodeVisitor& nv) { + _shadowedScene->osg::Group::traverse(nv); } void ShadowTexture::cull(osgUtil::CullVisitor& cv) @@ -125,8 +126,6 @@ void ShadowTexture::cull(osgUtil::CullVisitor& cv) // record the traversal mask on entry so we can reapply it later. unsigned int traversalMask = cv.getTraversalMask(); - // do RTT camera traversal - // _camera->accept(cv); // do traversal of shadow casting scene which does not need to be decorated by the shadow texture { @@ -149,6 +148,11 @@ void ShadowTexture::cull(osgUtil::CullVisitor& cv) } + + // do RTT camera traversal + _camera->accept(cv); + + // reapply the original traversal mask cv.setTraversalMask( traversalMask ); }