Esempio n. 1
0
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/");
}
Esempio n. 2
0
void AbstractHimmel::setupNode(osg::StateSet* stateSet)
{
    setCullingActive(false);

    // Only draw at back plane.
    osg::Depth* depth = new osg::Depth(osg::Depth::LEQUAL, 1.0, 1.0);
    stateSet->setAttributeAndModes(depth, osg::StateAttribute::ON);
}
Esempio n. 3
0
SkyBox::SkyBox()
{
    setReferenceFrame( osg::Transform::ABSOLUTE_RF );
    setCullingActive( false );

    osg::StateSet* ss = getOrCreateStateSet();
    ss->setAttributeAndModes( new osg::Depth(osg::Depth::LEQUAL, 1.0f, 1.0f) );
    ss->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
    ss->setMode( GL_CULL_FACE, osg::StateAttribute::OFF );
    ss->setRenderBinDetails( 5, "RenderBin" );
}
Esempio n. 4
0
// create fake layer geometry
void CloudsLayer::_createGeometry()
{
    // dummy bounding box callback
    osg::Drawable::ComputeBoundingBoxCallback * pDummyBBCompute = new osg::Drawable::ComputeBoundingBoxCallback();

    // create OSG geode with 1 drawable node
    setCullingActive(false);
    setDataVariance(osg::Object::STATIC);

    // create tetrahedron around viewer (just to fill the whole volume)
    osg::Geometry * box_geometry = new osg::Geometry;
    box_geometry->setUseDisplayList(true);
    box_geometry->setDataVariance(osg::Object::STATIC);
    box_geometry->setComputeBoundingBoxCallback(pDummyBBCompute);

    const float fSqrt3 = sqrtf(3.0f);

    // create its' vertex
    osg::Vec3Array * paBoxPointsPos = new osg::Vec3Array;
    paBoxPointsPos->resize(4);
    paBoxPointsPos->at(0).set(0.f, 0.f, +2.f);
    paBoxPointsPos->at(1).set(-2.0f * fSqrt3, 0.f, -1.0f);
    paBoxPointsPos->at(2).set(fSqrt3, -3.0f, -1.0f);
    paBoxPointsPos->at(3).set(fSqrt3, +3.0f, -1.0f);
    // set vertex array
    paBoxPointsPos->setDataVariance(osg::Object::STATIC);
    box_geometry->setVertexArray(paBoxPointsPos);

    // draw elements command, that would be executed
    // volume is made looking inside
    osg::DrawElementsUShort * paBoxDrawElem = new osg::DrawElementsUShort(GL_TRIANGLES, 12);
    paBoxDrawElem->at(0)  = 0;
    paBoxDrawElem->at(1)  = 2;
    paBoxDrawElem->at(2)  = 1;
    paBoxDrawElem->at(3)  = 0;
    paBoxDrawElem->at(4)  = 3;
    paBoxDrawElem->at(5)  = 2;
    paBoxDrawElem->at(6)  = 0;
    paBoxDrawElem->at(7)  = 1;
    paBoxDrawElem->at(8)  = 3;
    paBoxDrawElem->at(9)  = 1;
    paBoxDrawElem->at(10) = 2;
    paBoxDrawElem->at(11) = 3;

    // add DIP
    paBoxDrawElem->setDataVariance(osg::Object::STATIC);
    box_geometry->addPrimitiveSet(paBoxDrawElem);

    // all is done, so add box to this geode
    addDrawable(box_geometry);
}