VPB: Initial commit
Not for LTS
This commit is contained in:
@@ -184,6 +184,51 @@ void SGBucket::innerSet( double dlon, double dlat )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string SGBucket::gen_vpb_base() const {
|
||||||
|
// long int index;
|
||||||
|
int top_lon, top_lat, main_lon, main_lat;
|
||||||
|
char hem, pole;
|
||||||
|
char raw_path[256];
|
||||||
|
|
||||||
|
top_lon = lon / 10;
|
||||||
|
main_lon = lon;
|
||||||
|
if ((lon < 0) && (top_lon * 10 != lon)) {
|
||||||
|
top_lon -= 1;
|
||||||
|
}
|
||||||
|
top_lon *= 10;
|
||||||
|
if (top_lon >= 0) {
|
||||||
|
hem = 'E';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hem = 'W';
|
||||||
|
top_lon *= -1;
|
||||||
|
}
|
||||||
|
if (main_lon < 0) {
|
||||||
|
main_lon *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
top_lat = lat / 10;
|
||||||
|
main_lat = lat;
|
||||||
|
if ((lat < 0) && (top_lat * 10 != lat)) {
|
||||||
|
top_lat -= 1;
|
||||||
|
}
|
||||||
|
top_lat *= 10;
|
||||||
|
if (top_lat >= 0) {
|
||||||
|
pole = 'N';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pole = 'S';
|
||||||
|
top_lat *= -1;
|
||||||
|
}
|
||||||
|
if (main_lat < 0) {
|
||||||
|
main_lat *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
::snprintf(raw_path, 256, "WS_%c%d%c%2d", hem, main_lon, pole, main_lat);
|
||||||
|
|
||||||
|
return raw_path;
|
||||||
|
}
|
||||||
|
|
||||||
// Build the path name for this bucket
|
// Build the path name for this bucket
|
||||||
std::string SGBucket::gen_base_path() const {
|
std::string SGBucket::gen_base_path() const {
|
||||||
// long int index;
|
// long int index;
|
||||||
|
|||||||
@@ -195,6 +195,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::string gen_base_path() const;
|
std::string gen_base_path() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the base path name for this bucket.
|
||||||
|
* @return base path in string form
|
||||||
|
*/
|
||||||
|
std::string gen_vpb_base() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the center lon of a tile.
|
* @return the center lon of a tile.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -172,7 +172,11 @@ GDALDatasetH SGDemTile::createTile( char **papszSrcFiles, const char *pszFilenam
|
|||||||
&& (pszMethod == NULL || EQUALN(pszMethod,"GCP_",4)) ) {
|
&& (pszMethod == NULL || EQUALN(pszMethod,"GCP_",4)) ) {
|
||||||
pszThisSourceSRS = GDALGetGCPProjection( hSrcDS );
|
pszThisSourceSRS = GDALGetGCPProjection( hSrcDS );
|
||||||
} else if( pszMethod != NULL && EQUAL(pszMethod,"RPC") ) {
|
} else if( pszMethod != NULL && EQUAL(pszMethod,"RPC") ) {
|
||||||
|
#ifndef SRS_WKT_WGS84
|
||||||
|
pszThisSourceSRS = SRS_WKT_WGS84_LAT_LONG;
|
||||||
|
#else
|
||||||
pszThisSourceSRS = SRS_WKT_WGS84;
|
pszThisSourceSRS = SRS_WKT_WGS84;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
pszThisSourceSRS = "";
|
pszThisSourceSRS = "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
#ifdef HAVE_CONFIG_H
|
#ifdef HAVE_CONFIG_H
|
||||||
# include <simgear_config.h>
|
# include <simgear_config.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <algorithm>
|
||||||
#include "ReaderWriterSTG.hxx"
|
#include "ReaderWriterSTG.hxx"
|
||||||
|
|
||||||
#include <osg/LOD>
|
#include <osg/LOD>
|
||||||
@@ -53,6 +53,8 @@
|
|||||||
#include <simgear/scene/material/matlib.hxx>
|
#include <simgear/scene/material/matlib.hxx>
|
||||||
#include <simgear/scene/tgdb/SGBuildingBin.hxx>
|
#include <simgear/scene/tgdb/SGBuildingBin.hxx>
|
||||||
|
|
||||||
|
#include <simgear/scene/util/SGSceneFeatures.hxx>
|
||||||
|
|
||||||
#include "SGOceanTile.hxx"
|
#include "SGOceanTile.hxx"
|
||||||
|
|
||||||
#define BUILDING_ROUGH "OBJECT_BUILDING_MESH_ROUGH"
|
#define BUILDING_ROUGH "OBJECT_BUILDING_MESH_ROUGH"
|
||||||
@@ -376,6 +378,8 @@ struct ReaderWriterSTG::_ModelBin {
|
|||||||
int bucket = atoi(absoluteFileName.file_base().c_str());
|
int bucket = atoi(absoluteFileName.file_base().c_str());
|
||||||
mt_init(&seed, bucket);
|
mt_init(&seed, bucket);
|
||||||
|
|
||||||
|
bool vpb_active = SGSceneFeatures::instance()->getVPBActive();
|
||||||
|
|
||||||
// do only load airport btg files.
|
// do only load airport btg files.
|
||||||
bool onlyAirports = options->getPluginStringData("SimGear::FG_ONLY_AIRPORTS") == "ON";
|
bool onlyAirports = options->getPluginStringData("SimGear::FG_ONLY_AIRPORTS") == "ON";
|
||||||
// do only load terrain btg files
|
// do only load terrain btg files
|
||||||
@@ -409,18 +413,19 @@ struct ReaderWriterSTG::_ModelBin {
|
|||||||
path.append(name);
|
path.append(name);
|
||||||
|
|
||||||
if (token == "OBJECT_BASE") {
|
if (token == "OBJECT_BASE") {
|
||||||
// Load only once (first found)
|
if (!vpb_active) {
|
||||||
SG_LOG( SG_TERRAIN, SG_BULK, " " << token << " " << name );
|
// Load only once (first found)
|
||||||
_foundBase = true;
|
SG_LOG( SG_TERRAIN, SG_BULK, " " << token << " " << name );
|
||||||
if (!onlyAirports || isAirportBtg(name)) {
|
_foundBase = true;
|
||||||
_Object obj;
|
if (!onlyAirports || isAirportBtg(name)) {
|
||||||
obj._errorLocation = absoluteFileName;
|
_Object obj;
|
||||||
obj._token = token;
|
obj._errorLocation = absoluteFileName;
|
||||||
obj._name = path.utf8Str();
|
obj._token = token;
|
||||||
obj._options = staticOptions(filePath, options);
|
obj._name = path.utf8Str();
|
||||||
_objectList.push_back(obj);
|
obj._options = staticOptions(filePath, options);
|
||||||
|
_objectList.push_back(obj);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (token == "OBJECT") {
|
} else if (token == "OBJECT") {
|
||||||
if (!onlyAirports || isAirportBtg(name)) {
|
if (!onlyAirports || isAirportBtg(name)) {
|
||||||
_Object obj;
|
_Object obj;
|
||||||
@@ -430,7 +435,6 @@ struct ReaderWriterSTG::_ModelBin {
|
|||||||
obj._options = staticOptions(filePath, options);
|
obj._options = staticOptions(filePath, options);
|
||||||
_objectList.push_back(obj);
|
_objectList.push_back(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (!onlyTerrain) {
|
} else if (!onlyTerrain) {
|
||||||
// Load non-terrain objects
|
// Load non-terrain objects
|
||||||
|
|
||||||
@@ -566,6 +570,8 @@ struct ReaderWriterSTG::_ModelBin {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::map<std::string, bool> tile_map;
|
||||||
|
|
||||||
osg::Node* load(const SGBucket& bucket, const osgDB::Options* opt)
|
osg::Node* load(const SGBucket& bucket, const osgDB::Options* opt)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<SGReaderWriterOptions> options;
|
osg::ref_ptr<SGReaderWriterOptions> options;
|
||||||
@@ -575,6 +581,19 @@ struct ReaderWriterSTG::_ModelBin {
|
|||||||
terrainGroup->setDataVariance(osg::Object::STATIC);
|
terrainGroup->setDataVariance(osg::Object::STATIC);
|
||||||
terrainGroup->setName("terrain");
|
terrainGroup->setName("terrain");
|
||||||
|
|
||||||
|
bool vpb_active = SGSceneFeatures::instance()->getVPBActive();
|
||||||
|
if (vpb_active) {
|
||||||
|
std::string filename = "vpb/" + bucket.gen_vpb_base() + ".osgb";
|
||||||
|
//std::string filename = "vpb/*.osgb";
|
||||||
|
if (tile_map.count(filename) == 0) {
|
||||||
|
auto vpb_node = osgDB::readRefNodeFile(filename, options);
|
||||||
|
terrainGroup->addChild(vpb_node);
|
||||||
|
tile_map[filename] = true;
|
||||||
|
SG_LOG(SG_TERRAIN, SG_INFO, "Loading: " << filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!vpb_active) {
|
||||||
if (_foundBase) {
|
if (_foundBase) {
|
||||||
for (auto stgObject : _objectList) {
|
for (auto stgObject : _objectList) {
|
||||||
osg::ref_ptr<osg::Node> node;
|
osg::ref_ptr<osg::Node> node;
|
||||||
@@ -599,6 +618,7 @@ struct ReaderWriterSTG::_ModelBin {
|
|||||||
"Warning: failed to generate ocean tile!" );
|
"Warning: failed to generate ocean tile!" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (std::list<_ObjectStatic>::iterator i = _objectStaticList.begin(); i != _objectStaticList.end(); ++i) {
|
for (std::list<_ObjectStatic>::iterator i = _objectStaticList.begin(); i != _objectStaticList.end(); ++i) {
|
||||||
if (!i->_agl)
|
if (!i->_agl)
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ SGSceneFeatures::SGSceneFeatures() :
|
|||||||
_pointSpriteLights(true),
|
_pointSpriteLights(true),
|
||||||
_triangleDirectionalLights(true),
|
_triangleDirectionalLights(true),
|
||||||
_distanceAttenuationLights(true),
|
_distanceAttenuationLights(true),
|
||||||
_textureFilter(1)
|
_textureFilter(1),
|
||||||
|
_VPBActive(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ public:
|
|||||||
UseDXT3Compression,
|
UseDXT3Compression,
|
||||||
UseDXT5Compression
|
UseDXT5Compression
|
||||||
};
|
};
|
||||||
|
|
||||||
int getMaxTextureSize() const { return _MaxTextureSize; }
|
int getMaxTextureSize() const { return _MaxTextureSize; }
|
||||||
void setMaxTextureSize(const int maxTextureSize) { _MaxTextureSize = maxTextureSize; }
|
void setMaxTextureSize(const int maxTextureSize) { _MaxTextureSize = maxTextureSize; }
|
||||||
|
|
||||||
@@ -60,6 +61,9 @@ public:
|
|||||||
// modify the texture compression on the texture parameter
|
// modify the texture compression on the texture parameter
|
||||||
void applyTextureCompression(osg::Texture* texture) const;
|
void applyTextureCompression(osg::Texture* texture) const;
|
||||||
|
|
||||||
|
bool getVPBActive() const { return _VPBActive; }
|
||||||
|
void setVPBActive(const bool val) { _VPBActive = val; }
|
||||||
|
|
||||||
void setEnablePointSpriteLights(bool enable)
|
void setEnablePointSpriteLights(bool enable)
|
||||||
{
|
{
|
||||||
_pointSpriteLights = enable;
|
_pointSpriteLights = enable;
|
||||||
@@ -145,6 +149,7 @@ private:
|
|||||||
bool _triangleDirectionalLights;
|
bool _triangleDirectionalLights;
|
||||||
bool _distanceAttenuationLights;
|
bool _distanceAttenuationLights;
|
||||||
int _textureFilter;
|
int _textureFilter;
|
||||||
|
bool _VPBActive;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user