25#include <simgear/simgear_config.h>
29#include <simgear/scene/material/mat.hxx>
30#include <simgear/scene/util/SGReaderWriterOptions.hxx>
46 _scenery_loaded(
fgGetNode(
"/sim/sceneryloaded", true)),
47 _scenery_override(
fgGetNode(
"/sim/sceneryloaded-override", true))
62 SG_LOG(SG_TERRAIN, SG_INFO,
"FGPgtTerrain::init");
65 terrain_branch = terrain;
69 osg::ref_ptr<simgear::SGReaderWriterOptions>
options;
72 options =
new simgear::SGReaderWriterOptions;
75 osgDB::FilePathList &fp =
options->getDatabasePathList();
78 PathList::const_iterator it;
79 for (it = sc.begin(); it != sc.end(); ++it) {
80 fp.push_back(it->local8BitStr());
85 options->setPluginStringData(
"SimGear::BARE_LOD_RANGE",
87 std::to_string(SG_OBJECT_RANGE_BARE)));
88 options->setPluginStringData(
"SimGear::ROUGH_LOD_RANGE",
89 fgGetString(
"/sim/rendering/static-lod/rough-delta",
90 std::to_string(SG_OBJECT_RANGE_ROUGH)));
91 options->setPluginStringData(
"SimGear::ROUGH_LOD_DETAILED",
93 std::to_string(SG_OBJECT_RANGE_DETAILED)));
94 options->setPluginStringData(
"SimGear::RENDER_BUILDING_MESH",
fgGetBool(
"/sim/rendering/building-mesh",
false) ?
"true" :
"false");
96 options->setPluginStringData(
"SimGear::FG_EARTH",
"ON");
99 options->setPluginStringData(
"SimGear::SPT_PAGE_LEVELS",
fgGetString(
"/sim/scenery/lod-levels",
"1 3 5 7 9" ));
100 options->setPluginStringData(
"SimGear::SPT_RANGE_MULTIPLIER",
fgGetString(
"/sim/scenery/lod-range-mult",
"2" ));
101 options->setPluginStringData(
"SimGear::SPT_MESH_RESOLUTION",
fgGetString(
"/sim/scenery/lod-res",
"1" ));
102 options->setPluginStringData(
"SimGear::SPT_LOD_TEXTURING",
fgGetString(
"/sim/scenery/lod-texturing",
"bluemarble" ));
109 for (osgDB::FilePathList::const_iterator
i = fp.begin();
i != fp.end(); ++
i) {
111 demPath.append(
"DEM");
113 int numLevels = _dem->addRoot(demPath);
115 SG_LOG(SG_TERRAIN, SG_INFO,
"Terrain init - dem path " << demPath <<
" has " << numLevels <<
" LOD Levels " );
117 SG_LOG(SG_TERRAIN, SG_INFO,
"Terrain init - dem path " << demPath <<
" has NO LOD Levels " );
123 SG_LOG(SG_TERRAIN, SG_INFO,
"Terrain init - Load w180s90-360x180.pgt" );
124 osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFile(
"w180s90-360x180.pgt",
options.get());
127 terrain_branch->addChild( loadedModel.get() );
142 terrain_branch = NULL;
152 if (!_scenery_loaded->getBoolValue())
154 bool fdmInited =
fgGetBool(
"sim/fdm-initialized");
155 bool positionFinalized =
fgGetBool(
"sim/position-finalized");
156 bool sceneryOverride = _scenery_override->getBoolValue();
160 if (positionFinalized && (sceneryOverride || fdmInited))
162 _scenery_loaded->setBoolValue(
true);
167 if (!positionFinalized) {
174 SGTimeStamp::sleepForMSec(50);
192 const simgear::BVHMaterial** material,
193 const osg::Node* butNotFrom)
195 SGGeod geod = SGGeod::fromCart(pos);
196 geod.setElevationM(geod.getElevationM() + max_altoff);
201static simgear::BVHMaterial def_mat;
205 const simgear::BVHMaterial** material,
206 const osg::Node* butNotFrom)
210 *material = &def_mat;
220 const osg::Node* butNotFrom)
240 if (!position.isValid()) {
241 SG_LOG(SG_TERRAIN, SG_INFO,
"FGSptTerrain::schedule_scenery - position invalid");
bool options(int, char **)
SGPropertyNode * get_props()
const PathList & get_fg_scenery() const
const SGPath & get_fg_root() const
SGMaterialLib * get_matlib() const
bool scenery_available(const SGGeod &position, double range_m)
Returns true if scenery is available for the given lat, lon position within a range of range_m.
bool get_cart_ground_intersection(const SGVec3d &start, const SGVec3d &dir, SGVec3d &nearestHit, const osg::Node *butNotFrom=0)
Compute the nearest intersection point of the line starting from start going in direction dir with th...
void init(osg::Group *terrain)
bool schedule_scenery(const SGGeod &position, double range_m, double duration=0.0)
bool get_elevation_m(const SGGeod &geod, double &alt, const simgear::BVHMaterial **material, const osg::Node *butNotFrom=0)
Compute the elevation of the scenery at geodetic latitude lat, geodetic longitude lon and not higher ...
bool get_cart_elevation_m(const SGVec3d &pos, double max_altoff, double &elevation, const simgear::BVHMaterial **material, const osg::Node *butNotFrom=0)
Compute the elevation of the scenery below the cartesian point pos.
void materialLibChanged()
std::string fgGetString(const char *name, const char *defaultValue)
Get a string value for a property.
std::vector< SGPath > PathList
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
bool fgGetBool(char const *name, bool def)
Get a bool value for a property.
SGPropertyNode * fgGetNode(const char *path, bool create)
Get a property node.
void fgSplashProgress(const char *identifier, unsigned int percent)
Set progress information.