本文整理汇总了C++中NodeIterator::get方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeIterator::get方法的具体用法?C++ NodeIterator::get怎么用?C++ NodeIterator::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NodeIterator
的用法示例。
在下文中一共展示了NodeIterator::get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LayoutAsGrid
void LayoutAsGrid()
{
// calculate bounding box
osg::BoundingBox bbox;
for (NodeIterator node = nodes.begin(); node != nodes.end(); ++node)
bbox.expandBy((*node)->getBound());
// setup grid information
osg::Group ** groups = new osg::Group*[GridX * GridY];
int i;
for (i = 0; i < GridX * GridY; i++)
groups[i] = new osg::Group();
float xGridStart = bbox.xMin();
float xGridSize = (bbox.xMax() - bbox.xMin()) / GridX;
float yGridStart = bbox.yMin();
float yGridSize = (bbox.yMax() - bbox.yMin()) / GridY;
// arrange buildings into right grid
for (NodeIterator nodeIter = nodes.begin(); nodeIter != nodes.end(); ++nodeIter)
{
osg::Node * node = nodeIter->get();
osg::Vec3 center = node->getBound().center();
int x = (int)floor((center.x() - xGridStart) / xGridSize);
int z = (int)floor((center.y() - yGridStart) / yGridSize);
groups[z * GridX + x]->addChild(node);
}
// add nodes to building root
for (i = 0; i < GridX * GridY; i++)
{
osg::StateSet * stateset = new osg::StateSet();
osg::Material * material = new osg::Material();
osg::Vec4 color = osg::Vec4(
0.5f + (static_cast<double> (rand()) / (2.0*static_cast<double> (RAND_MAX))),
0.5f + (static_cast<double> (rand()) / (2.0*static_cast<double> (RAND_MAX))),
0.5f + (static_cast<double> (rand()) / ( 2.0*static_cast<double>(RAND_MAX))),
1.0f);
material->setAmbient(osg::Material::FRONT_AND_BACK, color);
material->setDiffuse(osg::Material::FRONT_AND_BACK, color);
stateset->setAttributeAndModes(material, osg::StateAttribute::ON);
groups[i]->setStateSet(stateset);
if (UseImpostor)
{
osgSim::Impostor * impostor = new osgSim::Impostor();
impostor->setImpostorThreshold(static_cast<float> (Threshold));
impostor->addChild(groups[i]);
impostor->setRange(0, 0.0f, 1e7f);
impostor->setCenter(groups[i]->getBound().center());
Root->addChild(impostor);
}
else
{
Root->addChild(groups[i]);
}
}
delete[] groups;
}