#include <plib/ssg.h>
#include <simgear/scene/model/placement.hxx>
-#include <simgear/scene/model/model.hxx>
+#include <simgear/scene/model/modellib.hxx>
+#include <simgear/scene/model/shadowvolume.hxx>
#include <simgear/structure/exception.hxx>
#include <Main/fg_props.hxx>
SG_USING_STD(vector);
+extern SGShadowVolume *shadows;
+
FGModelMgr::FGModelMgr ()
: _models(fgGetNode("/models", true)),
SGModelPlacement *model = new SGModelPlacement;
instance->model = model;
instance->node = node;
- ssgBranch *object
- = sgLoad3DModel( globals->get_fg_root(),
- node->getStringValue("path",
- "Models/Geometry/glider.ac"),
- globals->get_props(),
- globals->get_sim_time_sec() );
+ SGModelLib *model_lib = globals->get_model_lib();
+ ssgBranch *object = (ssgBranch *)model_lib->load_model(
+ globals->get_fg_root(),
+ node->getStringValue("path",
+ "Models/Geometry/glider.ac"),
+ globals->get_props(),
+ globals->get_sim_time_sec(), /*cache_object=*/false);
+
model->init( object );
+ shadows->addOccluder((ssgBranch *)object, SGShadowVolume::occluderTypeTileObject);
// Set position and orientation either
// indirectly through property refs
void
FGModelMgr::Listener::childAdded(SGPropertyNode * parent, SGPropertyNode * child)
{
- if (strcmp(parent->getName(), "model") || strcmp(child->getName(), "add"))
+ if (strcmp(parent->getName(), "model") || strcmp(child->getName(), "load"))
return;
try {
continue;
_mgr->_instances.erase(it);
- globals->get_scenery()->get_scene_graph()
- ->removeKid(instance->model->getSceneGraph());
+ ssgBranch *branch = (ssgBranch *)instance->model->getSceneGraph();
+ shadows->deleteOccluder(branch);
+ globals->get_scenery()->get_scene_graph()->removeKid(branch);
delete instance;
break;