Esempio n. 1
0
void LODDrawCallback::drawImplementation( osg::State& state, const osg::Drawable* p_drawable ) const
{
    assert( _p_lodMesh && "lod mesh data not available!" );

    const GLuint groupname  = _p_lodMesh->getGroupName();
    const GLuint objectname = _p_lodMesh->getObjectName();
    const GLuint numpatches = _p_lodMesh->getNumPatches();

    // need for LOD adaptation?
    if ( _p_lodMesh->adaptLOD() )
    {
        glodBindObjectXform( objectname, GL_PROJECTION_MATRIX | GL_MODELVIEW_MATRIX );
        glodAdaptGroup( groupname );
        // reset the adaptation flag after every adaptation
        // the adaptation is triggered by update callback
        _p_lodMesh->setAdaptLOD( false );
    }

    // apply drawable's state
    state.apply( p_drawable->getStateSet() );
    
    // draw the object patches
    for( GLuint patch = 0; patch < numpatches; ++patch )
        glodDrawPatch( objectname, patch );
}
Esempio n. 2
0
void PositionalStateContainer::draw(osg::State& state,RenderLeaf*& previous, const osg::Matrix* postMultMatrix)
{

    if (previous)
    {
        StateGraph::moveToRootStateGraph(state,previous->_parent);
        state.apply();
        previous = NULL;
    }

    // apply the light list.
    for(AttrMatrixList::iterator litr=_attrList.begin();
        litr!=_attrList.end();
        ++litr)
    {
        if (postMultMatrix)
        {
            if ((*litr).second.valid())
                state.applyModelViewMatrix(new osg::RefMatrix( (*((*litr).second)) * (*postMultMatrix)));
            else
                state.applyModelViewMatrix(new osg::RefMatrix( *postMultMatrix));
        }

        else
        {
            state.applyModelViewMatrix((*litr).second.get());
        }

        // apply the light source.
        litr->first->apply(state);

        // tell state about.
        state.haveAppliedAttribute(litr->first.get());

        // set this state as a global default
        state.setGlobalDefaultAttribute(litr->first.get());
    }

    for(TexUnitAttrMatrixListMap::iterator titr=_texAttrListMap.begin();
        titr!=_texAttrListMap.end();
        ++titr)
    {
        state.setActiveTextureUnit(titr->first);

        AttrMatrixList attrList = titr->second;

        for(AttrMatrixList::iterator litr=attrList.begin();
            litr!=attrList.end();
            ++litr)
        {
            if (postMultMatrix)
            {
                if ((*litr).second.valid())
                    state.applyModelViewMatrix(new osg::RefMatrix( (*((*litr).second)) * (*postMultMatrix)));
                else
                    state.applyModelViewMatrix(new osg::RefMatrix( *postMultMatrix));
            }
            else
            {
                state.applyModelViewMatrix((*litr).second.get());
            }

            // apply the light source.
            litr->first->apply(state);

            // tell state about.
            state.haveAppliedTextureAttribute(titr->first, litr->first.get());

            // set this state as a global default
            state.setGlobalDefaultTextureAttribute(titr->first, litr->first.get());
        }

    }
}
Esempio n. 3
0
void ShaderPaint::postPaint(osgNVPR::Extensions* ext, osg::State& state) const {
	state.popStateSet();
	state.apply();
}
Esempio n. 4
0
void ShaderPaint::paint(osgNVPR::Extensions* ext, osg::State& state) const {
	state.apply(_stateSet.get());
}