Added support for controlling the type of destiation database to create into
osgTerrain::DataSet.
This commit is contained in:
@@ -106,7 +106,15 @@ int main( int argc, char **argv )
|
||||
dataset->setDestinationExtents(osg::BoundingBox(x,y,0.0f,x+w,y+h,0.0f));
|
||||
}
|
||||
|
||||
while (arguments.read("--LOD"))
|
||||
{
|
||||
dataset->setDatabaseType(osgTerrain::DataSet::LOD_DATABASE);
|
||||
}
|
||||
|
||||
while (arguments.read("--PagedLOD"))
|
||||
{
|
||||
dataset->setDatabaseType(osgTerrain::DataSet::PagedLOD_DATABASE);
|
||||
}
|
||||
|
||||
dataset->setDestinationTileBaseName("output");
|
||||
dataset->setDestinationTileExtension(".ive");
|
||||
@@ -121,7 +129,6 @@ int main( int argc, char **argv )
|
||||
|
||||
dataset->setDestinationTileBaseName(base);
|
||||
dataset->setDestinationTileExtension(extension);
|
||||
|
||||
}
|
||||
|
||||
float numLevels = 6.0f;
|
||||
@@ -179,7 +186,7 @@ int main( int argc, char **argv )
|
||||
|
||||
dataset->createDestination((unsigned int)numLevels);
|
||||
|
||||
dataset->writeDestination(outputFileName);
|
||||
dataset->writeDestination();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -741,13 +741,13 @@ class DataSet : public osg::Referenced
|
||||
};
|
||||
|
||||
|
||||
typedef std::map<unsigned int,DestinationTile*> Column;
|
||||
typedef std::map<unsigned int,Column> Level;
|
||||
typedef std::map<unsigned int,DestinationTile*> Row;
|
||||
typedef std::map<unsigned int,Row> Level;
|
||||
typedef std::map<unsigned int,Level> QuadMap;
|
||||
|
||||
void insertTileToQuadMap(DestinationTile* tile)
|
||||
{
|
||||
_quadMap[tile->_level][tile->_tileX][tile->_tileY] = tile;
|
||||
_quadMap[tile->_level][tile->_tileY][tile->_tileX] = tile;
|
||||
}
|
||||
|
||||
DestinationTile* getTile(unsigned int level,unsigned int X, unsigned int Y)
|
||||
@@ -755,27 +755,37 @@ class DataSet : public osg::Referenced
|
||||
QuadMap::iterator levelItr = _quadMap.find(level);
|
||||
if (levelItr==_quadMap.end()) return 0;
|
||||
|
||||
Level::iterator columnItr = levelItr->second.find(X);
|
||||
if (columnItr==levelItr->second.end()) return 0;
|
||||
Level::iterator rowItr = levelItr->second.find(Y);
|
||||
if (rowItr==levelItr->second.end()) return 0;
|
||||
|
||||
Column::iterator rowItr = columnItr->second.find(Y);
|
||||
if (rowItr==columnItr->second.end()) return 0;
|
||||
else return rowItr->second;
|
||||
Row::iterator columnItr = rowItr->second.find(X);
|
||||
if (columnItr==rowItr->second.end()) return 0;
|
||||
else return columnItr->second;
|
||||
}
|
||||
|
||||
Row& getRow(unsigned int level,unsigned int Y)
|
||||
{
|
||||
return _quadMap[level][Y];
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
|
||||
DataSet();
|
||||
|
||||
|
||||
void addSource(Source* source);
|
||||
void addSource(CompositeSource* composite);
|
||||
|
||||
void loadSources();
|
||||
|
||||
void setVerticalScale(float verticalScale) { _verticalScale=verticalScale; }
|
||||
float getVerticalScale() const { return _verticalScale; }
|
||||
|
||||
void setVerticalScale(float verticalScale) { _verticalScale = verticalScale; }
|
||||
float getVerticalScale() const { return _verticalScale; }
|
||||
|
||||
void setDefaultColor(const osg::Vec4& defaultColor) { _defaultColor = defaultColor; }
|
||||
const osg::Vec4& getDefaultColor() const { return _defaultColor; }
|
||||
|
||||
void setDestinationCoordinateSystem(const std::string& wellKnownText) { _coordinateSystem = new osgTerrain::CoordinateSystem(wellKnownText); }
|
||||
void setDestinationCoordinateSystem(osgTerrain::CoordinateSystem* cs) { _coordinateSystem = cs; }
|
||||
|
||||
@@ -784,7 +794,7 @@ class DataSet : public osg::Referenced
|
||||
void setDestinationGeoTransform(const osg::Matrixd& geoTransform) { _geoTransform = geoTransform; }
|
||||
|
||||
void setDestinationTileBaseName(const std::string& basename) { _tileBasename = basename; }
|
||||
void setDestinationTileExtension(const std::string& extension) { _tileExtension = _tileExtension; }
|
||||
void setDestinationTileExtension(const std::string& extension) { _tileExtension = extension; }
|
||||
|
||||
CompositeDestination* createDestinationGraph(osgTerrain::CoordinateSystem* cs,
|
||||
const osg::BoundingBox& extents,
|
||||
@@ -802,7 +812,16 @@ class DataSet : public osg::Referenced
|
||||
|
||||
void createDestination(unsigned int numLevels);
|
||||
|
||||
void writeDestination(const std::string& filename);
|
||||
enum DatabaseType
|
||||
{
|
||||
LOD_DATABASE,
|
||||
PagedLOD_DATABASE,
|
||||
};
|
||||
|
||||
void setDatabaseType(DatabaseType type) { _databaseType = type; }
|
||||
DatabaseType getDatabaseType() const { return _databaseType; }
|
||||
|
||||
void writeDestination();
|
||||
|
||||
osg::Node* getDestinationRootNode() { return _rootNode.get(); }
|
||||
|
||||
@@ -826,7 +845,8 @@ class DataSet : public osg::Referenced
|
||||
osg::BoundingBox _extents;
|
||||
std::string _tileBasename;
|
||||
std::string _tileExtension;
|
||||
osg::Vec4 _defaultColour;
|
||||
osg::Vec4 _defaultColor;
|
||||
DatabaseType _databaseType;
|
||||
|
||||
|
||||
osg::ref_ptr<osg::Node> _rootNode;
|
||||
|
||||
@@ -896,7 +896,8 @@ DataSet::Source* DataSet::Source::doReproject(const std::string& filename, osgTe
|
||||
int success = 0;
|
||||
GDALRasterBand* band = _sourceData->_gdalDataSet->GetRasterBand(i+1);
|
||||
double noDataValue = band->GetNoDataValue(&success);
|
||||
double new_noDataValue = noDataValue;
|
||||
//double new_noDataValue = noDataValue;
|
||||
double new_noDataValue = 0;
|
||||
if (success)
|
||||
{
|
||||
std::cout<<"\tassinging no data value "<<noDataValue<<" to band "<<i+1<<std::endl;
|
||||
@@ -1669,6 +1670,8 @@ osg::Node* DataSet::DestinationTile::createScene()
|
||||
}
|
||||
|
||||
osg::Geode* geode = 0;
|
||||
osg::ShapeDrawable* shapeDrawable = 0;
|
||||
|
||||
if (heightFieldPresent)
|
||||
{
|
||||
std::cout<<"--- Have terrain build tile ----"<<std::endl;
|
||||
@@ -1677,7 +1680,9 @@ osg::Node* DataSet::DestinationTile::createScene()
|
||||
|
||||
geode = new osg::Geode;
|
||||
|
||||
geode->addDrawable(new osg::ShapeDrawable(hf));
|
||||
|
||||
shapeDrawable = new osg::ShapeDrawable(hf);
|
||||
geode->addDrawable(shapeDrawable);
|
||||
|
||||
hf->setSkirtHeight(geode->getBound().radius()*0.01f);
|
||||
|
||||
@@ -1694,7 +1699,8 @@ osg::Node* DataSet::DestinationTile::createScene()
|
||||
|
||||
geode = new osg::Geode;
|
||||
|
||||
geode->addDrawable(new osg::ShapeDrawable(hf));
|
||||
osg::ShapeDrawable* shapeDrawable = new osg::ShapeDrawable(hf);
|
||||
geode->addDrawable(shapeDrawable);
|
||||
|
||||
hf->setSkirtHeight(geode->getBound().radius()*0.01f);
|
||||
}
|
||||
@@ -1712,6 +1718,10 @@ osg::Node* DataSet::DestinationTile::createScene()
|
||||
texture->setWrap(osg::Texture::WRAP_T,osg::Texture::CLAMP);
|
||||
stateset->setTextureAttributeAndModes(0,texture,osg::StateAttribute::ON);
|
||||
}
|
||||
else if (shapeDrawable)
|
||||
{
|
||||
shapeDrawable->setColor(_dataSet->getDefaultColor());
|
||||
}
|
||||
|
||||
return geode;
|
||||
|
||||
@@ -1970,7 +1980,9 @@ DataSet::DataSet()
|
||||
{
|
||||
init();
|
||||
|
||||
_defaultColour.set(0.5f,0.5f,1.0f,1.0f);
|
||||
_defaultColor.set(0.5f,0.5f,1.0f,1.0f);
|
||||
_databaseType = PagedLOD_DATABASE;
|
||||
|
||||
}
|
||||
|
||||
void DataSet::init()
|
||||
@@ -2441,19 +2453,27 @@ void DataSet::updateSourcesForDestinationGraphNeeds()
|
||||
}
|
||||
std::cout<<"End of Using Source Iterator itr"<<std::endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void DataSet::populateDestinationGraphFromSources()
|
||||
{
|
||||
// for each DestinationTile populate it.
|
||||
_destinationGraph->readFrom(_sourceGraph.get());
|
||||
|
||||
// for each DestinationTile equalize the boundaries so they all fit each other without gaps.
|
||||
_destinationGraph->equalizeBoundaries();
|
||||
if (_databaseType==LOD_DATABASE)
|
||||
{
|
||||
|
||||
// for each DestinationTile populate it.
|
||||
_destinationGraph->readFrom(_sourceGraph.get());
|
||||
|
||||
// for each DestinationTile equalize the boundaries so they all fit each other without gaps.
|
||||
_destinationGraph->equalizeBoundaries();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// for each level
|
||||
// compute x and y range
|
||||
// from top row down to bottom row equalize boundairies a write out
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2468,15 +2488,31 @@ void DataSet::createDestination(unsigned int numLevels)
|
||||
|
||||
populateDestinationGraphFromSources();
|
||||
|
||||
if (_destinationGraph.valid()) _rootNode = _destinationGraph->createScene();
|
||||
if (_destinationGraph.valid())
|
||||
{
|
||||
if (_databaseType==LOD_DATABASE)
|
||||
{
|
||||
_rootNode = _destinationGraph->createScene();
|
||||
}
|
||||
else
|
||||
{
|
||||
// create top most level?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DataSet::writeDestination(const std::string& filename)
|
||||
void DataSet::writeDestination()
|
||||
{
|
||||
|
||||
std::string filename = _tileBasename+_tileExtension;
|
||||
std::cout<<"DataSet::writeDestination("<<filename<<")"<<std::endl;
|
||||
if (_rootNode.valid())
|
||||
{
|
||||
osgDB::writeNodeFile(*_rootNode,filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout<<"Error: no scene graph to output, no file written."<<std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user