本文整理汇总了C++中TileNode::getStateSet方法的典型用法代码示例。如果您正苦于以下问题:C++ TileNode::getStateSet方法的具体用法?C++ TileNode::getStateSet怎么用?C++ TileNode::getStateSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileNode
的用法示例。
在下文中一共展示了TileNode::getStateSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool
TileNode::inheritState(EngineContext* context)
{
// Find the parent node. It will only be null if this is a "first LOD" tile.
TileNode* parent = getNumParents() > 0 ? dynamic_cast<TileNode*>(getParent(0)) : 0L;
bool changesMade = false;
// which quadrant is this tile in?
unsigned quadrant = getTileKey().getQuadrant();
// default inheritance of the elevation data for bounding purposes:
osg::ref_ptr<const osg::Image> elevRaster;
osg::Matrixf elevMatrix;
if ( parent )
{
elevRaster = parent->getElevationRaster();
elevMatrix = parent->getElevationMatrix();
elevMatrix.preMult( scaleBias[quadrant] );
}
// Find all the sampler matrix uniforms and scale/bias them to the current quadrant.
// This will inherit textures and use the proper sub-quadrant until new data arrives (later).
for( RenderBindings::const_iterator binding = context->getRenderBindings().begin(); binding != context->getRenderBindings().end(); ++binding )
{
if ( binding->usage().isSetTo(binding->COLOR) )
{
if ( parent && parent->getStateSet() )
{
MPTexture* parentMPTex = parent->getMPTexture();
_mptex->inheritState( parentMPTex, scaleBias[quadrant] );
changesMade = true;
}
}
else if ( binding->usage().isSetTo(binding->COLOR_PARENT) )
{
//nop -- this is handled as part of the COLOR binding
}
else
{
osg::StateAttribute* sa = getStateSet()->getTextureAttribute(binding->unit(), osg::StateAttribute::TEXTURE);
// If the attribute isn't present, that means we are inheriting it from above.
// So construct a new scale/bias matrix.
if ( sa == 0L )
{
osg::Matrixf matrix;
// Find the parent's matrix and scale/bias it to this quadrant:
if ( parent && parent->getStateSet() )
{
const osg::Uniform* matrixUniform = parent->getStateSet()->getUniform( binding->matrixName() );
if ( matrixUniform )
{
matrixUniform->get( matrix );
matrix.preMult( scaleBias[quadrant] );
}
}
// Add a new uniform with the scale/bias'd matrix:
osg::StateSet* stateSet = getOrCreateStateSet();
stateSet->removeUniform( binding->matrixName() );
stateSet->addUniform( context->getOrCreateMatrixUniform(binding->matrixName(), matrix) );
changesMade = true;
}
// If this is elevation data, record the new raster so we can apply it to the node.
else if ( binding->usage().isSetTo(binding->ELEVATION) )
{
osg::Texture* t = static_cast<osg::Texture*>(sa);
elevRaster = t->getImage(0);
elevMatrix = osg::Matrixf::identity();
}
}
}
// If we found one, communicate it to the node and its children.
if (elevRaster.valid())
{
if (elevRaster.get() != getElevationRaster() || elevMatrix != getElevationMatrix() )
{
setElevationRaster( elevRaster.get(), elevMatrix );
changesMade = true;
}
}
// finally, update the uniforms for terrain morphing
updateTileUniforms( context->getSelectionInfo() );
if ( !changesMade )
{
OE_INFO << LC << _key.str() << ", good, no changes :)\n";
}
else
{
dirtyBound();
}
//.........这里部分代码省略.........