本文整理汇总了C++中TileNode::getOrCreateStateSet方法的典型用法代码示例。如果您正苦于以下问题:C++ TileNode::getOrCreateStateSet方法的具体用法?C++ TileNode::getOrCreateStateSet怎么用?C++ TileNode::getOrCreateStateSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileNode
的用法示例。
在下文中一共展示了TileNode::getOrCreateStateSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TileNode
TileNode*
TileGroupFactory::createTileNode(TerrainTileModel* model,
ProgressCallback* progress)
{
TileNode* tileNode = new TileNode(model);
for(TerrainTileImageLayerModelVector::const_iterator i = model->colorLayers().begin();
i != model->colorLayers().end();
++i)
{
const TerrainTileLayerModel* layer = i->get();
if ( layer->getTexture() )
{
osg::StateSet* stateSet = tileNode->getOrCreateStateSet();
stateSet->setTextureAttribute(
_renderBindings.color().unit(),
layer->getTexture() );
// (note: sampler uniform is set at the top level by the engine)
}
if ( layer->getMatrix() )
{
osg::StateSet* stateSet = tileNode->getOrCreateStateSet();
stateSet->addUniform( new osg::Uniform(
_renderBindings.color().matrixName().c_str(),
*(layer->getMatrix())) );
}
}
if ( model->elevationModel() )
{
const TerrainTileElevationModel* em = model->elevationModel();
if ( em->getTexture() )
{
osg::StateSet* stateSet = tileNode->getOrCreateStateSet();
stateSet->setTextureAttribute(
_renderBindings.elevation().unit(),
em->getTexture() );
osg::Matrixf elevMatrix;
if ( em->getMatrix() )
elevMatrix = *(em->getMatrix());
stateSet->addUniform( new osg::Uniform(
_renderBindings.elevation().matrixName().c_str(),
elevMatrix ));
// (note: sampler uniform is set at the top level by the engine)
}
}
for(TerrainTileImageLayerModelVector::const_iterator i = model->sharedLayers().begin();
i != model->sharedLayers().end();
++i)
{
const TerrainTileImageLayerModel* layerModel = i->get();
const ImageLayer* imageLayer = layerModel->getImageLayer();
if ( imageLayer )
{
if ( layerModel->getTexture() )
{
osg::StateSet* stateSet = tileNode->getOrCreateStateSet();
stateSet->setTextureAttribute(
imageLayer->shareImageUnit().get(),
layerModel->getTexture() );
//TODO: don't really need this if we set it up in the Engine
// once at the top level when adding the layer.
stateSet->addUniform( new osg::Uniform(
imageLayer->shareSamplerName()->c_str(),
imageLayer->shareImageUnit().get() ));
}
if ( layerModel->getMatrix() )
{
osg::StateSet* stateSet = tileNode->getOrCreateStateSet();
stateSet->addUniform( new osg::Uniform(
imageLayer->shareMatrixName()->c_str(),
*(layerModel->getMatrix())) );
}
}
}
return tileNode;
}