1
0
Fork 0

Search all resources when adding models at runtime.

geo.put-model / add-model mechanism now supports resolving paths
using all the defined locations, including aircraft dirs and
additional data dirs,
This commit is contained in:
James Turner 2014-01-23 15:02:33 +00:00
parent c6541e9c8f
commit 2a1e33863a

View file

@ -69,13 +69,14 @@ FGModelMgr::add_model (SGPropertyNode * node)
SG_LOG(SG_AIRCRAFT, SG_INFO,
"Adding model " << node->getStringValue("name", "[unnamed]"));
const char *path = node->getStringValue("path", "Models/Geometry/glider.ac");
const char *model_path = node->getStringValue("path", "Models/Geometry/glider.ac");
osg::Node *object;
try {
object = SGModelLib::loadDeferredModel(path, globals->get_props());
std::string fullPath = simgear::SGModelLib::findDataFile(model_path);
object = SGModelLib::loadDeferredModel(fullPath, globals->get_props());
} catch (const sg_throwable& t) {
SG_LOG(SG_AIRCRAFT, SG_ALERT, "Error loading " << path << ":\n "
SG_LOG(SG_AIRCRAFT, SG_ALERT, "Error loading " << model_path << ":\n "
<< t.getFormattedMessage() << t.getOrigin());
return;
}