#include <simgear_config.h>
#endif
-#include <simgear/compiler.h>
-
#include <string.h> // for strcmp()
#include <vector>
}
}
+class sgLoaderOptions : public ssgLoaderOptions {
+public:
+ void endLoad() {} // Avoid clearing the texture cache after every model load
+};
+
+static sgLoaderOptions loaderOptions;
\f
////////////////////////////////////////////////////////////////////////
texturepath = texturepath.dir();
ssgTexturePath((char *)texturepath.c_str());
- model = (ssgBranch *)ssgLoad((char *)modelpath.c_str());
+ model = (ssgBranch *)ssgLoad((char *)modelpath.c_str(), &loaderOptions);
if (model == 0)
throw sg_io_exception("Failed to load 3D model",
sg_location(modelpath.str()));
node->getFloatValue("offsets/z-m", 0.0));
align->setTransform(res_matrix);
- ssgBranch * kid = sgLoad3DModel( fg_root, node->getStringValue("path"),
- prop_root, sim_time_sec, load_panel );
+ ssgBranch * kid;
+ const char * submodel = node->getStringValue("path");
+ try {
+ kid = sgLoad3DModel( fg_root, submodel, prop_root, sim_time_sec, load_panel );
+
+ } catch (const sg_throwable &t) {
+ SG_LOG(SG_INPUT, SG_ALERT, "Failed to load submodel: " << t.getFormattedMessage());
+ throw;
+ }
align->addKid(kid);
align->setName(node->getStringValue("name", ""));
model->addKid(align);
}
if (data) {
- model->setUserData(data);
- data->modelLoaded(path, &props, model);
+ alignmainmodel->setUserData(data);
+ data->modelLoaded(path, &props, alignmainmodel);
}
// Load animations
set<ssgBranch *> ignore_branches;