本文整理汇总了C++中osg::ref_ptr::getNumRows方法的典型用法代码示例。如果您正苦于以下问题:C++ ref_ptr::getNumRows方法的具体用法?C++ ref_ptr::getNumRows怎么用?C++ ref_ptr::getNumRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::ref_ptr
的用法示例。
在下文中一共展示了ref_ptr::getNumRows方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: creation_terrain
osg::Node* creation_terrain(){
osg::Image* heightMap = osgDB::readImageFile("terrain.tga");
osg::HeightField* terrain = new osg::HeightField();
terrain->allocate(heightMap->s(), heightMap->t());
terrain->setOrigin(osg::Vec3(-heightMap->s() / 2, -heightMap->t() / 2, 0));
terrain->setXInterval(10.0f);
terrain->setYInterval(10.0f);
for (unsigned int r = 0; r < terrain->getNumRows(); r++)
for (unsigned int c = 0; c < terrain->getNumColumns(); c++)
terrain->setHeight(c, r, ((*heightMap->data(c, r)) / 255.0f) * 300.0f);
osg::Geode* geode = new osg::Geode();
geode->addDrawable(new osg::ShapeDrawable(terrain));
osg::Material* mat = new osg::Material;
mat->setAmbient (osg::Material::FRONT_AND_BACK, osg::Vec4(0.5, 0.5, 0.5, 1.0));
mat->setDiffuse (osg::Material::FRONT_AND_BACK, osg::Vec4(0.9, 0.9, 0.9, 1.0));
mat->setSpecular(osg::Material::FRONT_AND_BACK, osg::Vec4(0.0, 0.0, 0.0, 1.0));
mat->setShininess(osg::Material::FRONT_AND_BACK, 64);
geode->getOrCreateStateSet()->setAttributeAndModes(mat);
osg::Texture2D* tex = new osg::Texture2D(osgDB::readImageFile("herbe.tga"));
tex->setFilter(osg::Texture2D::MIN_FILTER, osg::Texture2D::LINEAR_MIPMAP_LINEAR);
tex->setFilter(osg::Texture2D::MAG_FILTER, osg::Texture2D::LINEAR);
tex->setWrap(osg::Texture::WRAP_S, osg::Texture::REPEAT);
tex->setWrap(osg::Texture::WRAP_T, osg::Texture::REPEAT);
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, tex);
osg::Matrixd matrix;
matrix.makeScale(osg::Vec3(10, 10, 1.0));
osg::ref_ptr<osg::TexMat> matTexture = new osg::TexMat;
matTexture->setMatrix(matrix);
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0,
matTexture.get(), osg::StateAttribute::ON);
return geode;
}
示例2: if
//.........这里部分代码省略.........
}
else
{
//We weren't requested to fallback so just return.
return false;
}
}
else if (heightFields.size() == 1)
{
if ( lowestLOD == key.getLevelOfDetail() )
{
//If we only have on heightfield, just return it.
out_result = heightFields[0].takeHeightField();
}
else
{
GeoHeightField geoHF = heightFields[0].createSubSample( key.getExtent(), interpolation);
out_result = geoHF.takeHeightField();
hfInitialized = true;
}
}
else
{
//If we have multiple heightfields, we need to composite them together.
unsigned int width = 0;
unsigned int height = 0;
for (GeoHeightFieldVector::const_iterator i = heightFields.begin(); i < heightFields.end(); ++i)
{
if (i->getHeightField()->getNumColumns() > width)
width = i->getHeightField()->getNumColumns();
if (i->getHeightField()->getNumRows() > height)
height = i->getHeightField()->getNumRows();
}
out_result = new osg::HeightField();
out_result->allocate( width, height );
//Go ahead and set up the heightfield so we don't have to worry about it later
double minx, miny, maxx, maxy;
key.getExtent().getBounds(minx, miny, maxx, maxy);
double dx = (maxx - minx)/(double)(out_result->getNumColumns()-1);
double dy = (maxy - miny)/(double)(out_result->getNumRows()-1);
const SpatialReference* keySRS = keyToUse.getProfile()->getSRS();
//Create the new heightfield by sampling all of them.
for (unsigned int c = 0; c < width; ++c)
{
double x = minx + (dx * (double)c);
for (unsigned r = 0; r < height; ++r)
{
double y = miny + (dy * (double)r);
//Collect elevations from all of the layers. Iterate BACKWARDS because the last layer
// is the highest priority.
std::vector<float> elevations;
for( GeoHeightFieldVector::reverse_iterator itr = heightFields.rbegin(); itr != heightFields.rend(); ++itr )
{
const GeoHeightField& geoHF = *itr;
float elevation = 0.0f;
if ( geoHF.getElevation(keySRS, x, y, interpolation, keySRS, elevation) )
{
if (elevation != NO_DATA_VALUE)