OpenWalnut
1.2.5
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #include <string> 00026 00027 #include <osg/Geode> 00028 00029 #include "WGEOffscreenRenderNode.h" 00030 00031 WGEOffscreenRenderNode::WGEOffscreenRenderNode( osg::ref_ptr< osg::Camera > reference, size_t width, size_t height, bool noHud ): 00032 WGEGroupNode(), 00033 m_referenceCamera( reference ), 00034 m_hud(), 00035 m_textureWidth( width ), 00036 m_textureHeight( height ), 00037 m_nextPassNum( 0 ) 00038 { 00039 // initialize members 00040 m_hud = new WGETextureHud(); 00041 if( !noHud ) 00042 { 00043 m_hud->addUpdateCallback( new WGEViewportCallback< WGETextureHud >( m_referenceCamera ) ); 00044 m_hud->coupleViewportWithTextureViewport(); 00045 insert( m_hud ); 00046 } 00047 } 00048 00049 WGEOffscreenRenderNode::~WGEOffscreenRenderNode() 00050 { 00051 // cleanup 00052 } 00053 00054 osg::ref_ptr< WGEOffscreenRenderPass > WGEOffscreenRenderNode::addGeometryRenderPass( osg::ref_ptr< osg::Node > node, std::string name ) 00055 { 00056 // create a plain render pass and add some geometry 00057 osg::ref_ptr< WGEOffscreenRenderPass > pass = addRenderPass< WGEOffscreenRenderPass >( name ); 00058 pass->addChild( node ); 00059 return pass; 00060 } 00061 00062 osg::ref_ptr< WGEOffscreenRenderPass > WGEOffscreenRenderNode::addGeometryRenderPass( osg::ref_ptr< osg::Node > node, 00063 osg::ref_ptr< WGEShader > shader, 00064 std::string name ) 00065 { 00066 // create a plain render pass and add some geometry 00067 osg::ref_ptr< WGEOffscreenRenderPass > pass = addRenderPass< WGEOffscreenRenderPass >( name ); 00068 pass->addChild( node ); 00069 shader->apply( pass ); 00070 return pass; 00071 } 00072 00073 osg::ref_ptr< WGEOffscreenTexturePass > WGEOffscreenRenderNode::addTextureProcessingPass( std::string name ) 00074 { 00075 osg::ref_ptr< WGEOffscreenTexturePass > pass = addRenderPass< WGEOffscreenTexturePass >( name ); 00076 return pass; 00077 } 00078 00079 osg::ref_ptr< WGEOffscreenTexturePass > WGEOffscreenRenderNode::addTextureProcessingPass( osg::ref_ptr< WGEShader > shader, std::string name ) 00080 { 00081 osg::ref_ptr< WGEOffscreenTexturePass > pass = addRenderPass< WGEOffscreenTexturePass >( name ); 00082 shader->apply( pass ); 00083 return pass; 00084 } 00085 00086 osg::ref_ptr< WGEOffscreenFinalPass > WGEOffscreenRenderNode::addFinalOnScreenPass( std::string name ) 00087 { 00088 osg::ref_ptr< WGEOffscreenFinalPass > pass = addRenderPass< WGEOffscreenFinalPass >( name ); 00089 return pass; 00090 } 00091 00092 osg::ref_ptr< WGEOffscreenFinalPass > WGEOffscreenRenderNode::addFinalOnScreenPass( osg::ref_ptr< WGEShader > shader, std::string name ) 00093 { 00094 osg::ref_ptr< WGEOffscreenFinalPass > pass = addRenderPass< WGEOffscreenFinalPass >( name ); 00095 shader->apply( pass ); 00096 return pass; 00097 } 00098 00099 osg::ref_ptr< WGETextureHud > WGEOffscreenRenderNode::getTextureHUD() const 00100 { 00101 return m_hud; 00102 } 00103