CSulIntersectionWithCamera::CSulIntersectionWithCamera( osg::Node* pNode, CSulIntersectionInfo* pIntersectionInfo ) { m_pos.set( 0, 0, 0 ); m_dir.set( 1, 0, 0 ); // render to texture (RTT) //m_rTexCam = new CSulTexCam( 128, 128, CSulTexCam::ZVALUE_WITH_IMAGE ); m_rTexCam = new CSulTexCam( 128, 128, CSulTexCam::ZVALUE_FROM_DEPTH ); //m_rTexCam->setDataVariance( osg::Object::DYNAMIC ); m_rTexCam->addChild( pNode ); addChild( m_rTexCam ); // set a z position shader on the camera new CSulShaderZ( m_rTexCam ); // the drawcallback is used to notify when the camera/intersection test has rendered a frame m_rDrawCallback = new CSulIntersectionDrawCallback( pIntersectionInfo, m_rTexCam->getImage() ); // m_rTexCam->setFinalDrawCallback( m_rDrawCallback ); m_rTexCam->setPostDrawCallback( m_rDrawCallback ); // we need an update callback to ensure that we don't get threading problems with the drawcallback m_rSulIntersectionWithCameraCallback = new CSulIntersectionWithCameraCallback( m_rDrawCallback ); addUpdateCallback( m_rSulIntersectionWithCameraCallback ); setCullCallback( new CSulIntersectionCullCallback( m_rDrawCallback ) ); }
SilverLiningNode::SilverLiningNode( const char* licenseUser, const char* licenseKey ) : _initialized(false) { _sky = new SkyDrawable(this); _sky->setUseVertexBufferObjects( false ); _sky->setUseDisplayList( false ); _sky->getOrCreateStateSet()->setRenderBinDetails( 98, "RenderBin" ); _sky->getOrCreateStateSet()->setAttributeAndModes( new osg::Depth(osg::Depth::LEQUAL, 0.0, 1.0, false) ); addDrawable( _sky.get() ); _cloud = new CloudDrawable(this); _cloud->setUseVertexBufferObjects( false ); _cloud->setUseDisplayList( false ); _cloud->getOrCreateStateSet()->setRenderBinDetails( 99, "RenderBin" ); _cloud->setCullCallback( new AlwaysKeepCallback ); // This seems to avoid cloud to twinkle sometimes addDrawable( _cloud.get() ); AtmosphereUpdater* updater = new AtmosphereUpdater; setUpdateCallback( updater ); setCullCallback( updater ); setCullingActive( false ); getOrCreateStateSet()->setRenderBinDetails( 100, "RenderBin" ); _atmosphere = new SilverLining::Atmosphere( licenseUser, licenseKey ); _atmosphere->DisableFarCulling( true ); _atmosphere->EnableLensFlare( true ); const char* slPath = getenv( "SILVERLINING_PATH" ); if ( slPath ) _resourcePath = osgDB::convertFileNameToNativeStyle(std::string(slPath) + "/resources/"); }
FlexDrawable::FlexDrawable() : _solver(NULL) { setUseDisplayList( false ); setUseVertexBufferObjects( false ); setCullCallback( FlexUpdater::instance() ); osg::ref_ptr<osg::Program> program = new osg::Program; program->addShader( new osg::Shader(osg::Shader::VERTEX, flexVertCode) ); program->addShader( new osg::Shader(osg::Shader::FRAGMENT, flexFragCode) ); osg::StateSet* ss = getOrCreateStateSet(); ss->setAttributeAndModes( program.get() ); }
TritonNode::TritonNode( const char* licenseUser, const char* licenseKey ) : _resourceLoader(0), _environment(0), _ocean(0), _atmosphere(0), _licenseName(licenseUser), _licenseKey(licenseKey), _initialized(false) { _oceanDrawable = new OceanDrawable(this); _oceanDrawable->setUseVertexBufferObjects( false ); _oceanDrawable->setUseDisplayList( false ); addDrawable( _oceanDrawable.get() ); OceanUpdater* updater = new OceanUpdater; setUpdateCallback( updater ); setCullCallback( updater ); getOrCreateStateSet()->setAttribute( new osg::Program ); const char* slPath = getenv( "TRITON_PATH" ); if ( slPath ) _resourcePath = osgDB::convertFileNameToNativeStyle(std::string(slPath) + "/resources/"); }