当前位置: 首页>>代码示例>>C++>>正文


C++ ref_ptr::getNumColumns方法代码示例

本文整理汇总了C++中osg::ref_ptr::getNumColumns方法的典型用法代码示例。如果您正苦于以下问题:C++ ref_ptr::getNumColumns方法的具体用法?C++ ref_ptr::getNumColumns怎么用?C++ ref_ptr::getNumColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在osg::ref_ptr的用法示例。


在下文中一共展示了ref_ptr::getNumColumns方法的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;

}
开发者ID:ClementCvl,项目名称:CppMasterRace_50yIUT,代码行数:46,代码来源:main.cpp

示例2: if


//.........这里部分代码省略.........
            out_result = HeightFieldUtils::createReferenceHeightField( keyToUse.getExtent(), defElevSize, defElevSize );                
            return true;
        }
        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) )
开发者ID:JohnDr,项目名称:osgearth,代码行数:67,代码来源:ElevationLayer.cpp


注:本文中的osg::ref_ptr::getNumColumns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。