From John Vidar Larring, "Added vertical scale as a property of osgTerrain::Terrain. Lets you configure vertical scale when initializing the terrain model. E.g:
osgTerrain::Terrain* terrain = findTopMostNodeOfType<osgTerrain::Terrain>(model.get());
if (!terrain)
{
terrain = new osgTerrain::Terrain;
terrain->addChild(model.get());
terrain->setVerticalScale(2.0f);
model = terrain;
}
viewerWindow->setSceneData(model.get());
"
This commit is contained in:
@@ -278,7 +278,7 @@ void GeometryTechnique::generateGeometry(Locator* masterLocator, const osg::Vec3
|
||||
|
||||
|
||||
float minHeight = 0.0;
|
||||
float scaleHeight = 1.0;
|
||||
float scaleHeight = _terrainTile->getTerrain() ? _terrainTile->getTerrain()->getVerticalScale() : 1.0f;
|
||||
|
||||
// allocate and assign tex coords
|
||||
typedef std::pair< osg::ref_ptr<osg::Vec2Array>, Locator* > TexCoordLocatorPair;
|
||||
@@ -341,7 +341,7 @@ void GeometryTechnique::generateGeometry(Locator* masterLocator, const osg::Vec3
|
||||
float value = 0.0f;
|
||||
validValue = elevationLayer->getValidValue(i_equiv,j_equiv, value);
|
||||
// osg::notify(osg::INFO)<<"i="<<i<<" j="<<j<<" z="<<value<<std::endl;
|
||||
ndc.z() = value;
|
||||
ndc.z() = value*scaleHeight;
|
||||
}
|
||||
|
||||
if (validValue)
|
||||
@@ -373,7 +373,7 @@ void GeometryTechnique::generateGeometry(Locator* masterLocator, const osg::Vec3
|
||||
|
||||
if (elevations.valid())
|
||||
{
|
||||
(*elevations).push_back((ndc.z()-minHeight)*scaleHeight);
|
||||
(*elevations).push_back(ndc.z());
|
||||
}
|
||||
|
||||
// compute the local normal
|
||||
|
||||
@@ -18,13 +18,15 @@ using namespace osg;
|
||||
using namespace osgTerrain;
|
||||
|
||||
Terrain::Terrain():
|
||||
_sampleRatio(1.0)
|
||||
_sampleRatio(1.0),
|
||||
_verticalScale(1.0)
|
||||
{
|
||||
}
|
||||
|
||||
Terrain::Terrain(const Terrain& ts, const osg::CopyOp& copyop):
|
||||
osg::Group(ts,copyop),
|
||||
_sampleRatio(ts._sampleRatio)
|
||||
_sampleRatio(ts._sampleRatio),
|
||||
_verticalScale(ts._verticalScale)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -69,6 +71,25 @@ const TerrainTile* Terrain::getTile(const TileID& tileID) const
|
||||
return itr->second;
|
||||
}
|
||||
|
||||
void Terrain::dirtyRegisteredTiles()
|
||||
{
|
||||
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
|
||||
|
||||
for(TerrainTileSet::iterator itr = _terrainTileSet.begin();
|
||||
itr != _terrainTileSet.end();
|
||||
++itr)
|
||||
{
|
||||
TerrainTechnique* tt = const_cast<TerrainTile*>(*itr)->getTerrainTechnique();
|
||||
if(tt)
|
||||
{
|
||||
tt->dirty();
|
||||
|
||||
// Force recreation of Geometry
|
||||
// const_cast<TerrainTile*>(*itr)->init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned int s_maxNumTiles = 0;
|
||||
void Terrain::registerTerrainTile(TerrainTile* tile)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user