1 // loader.cxx - implement SSG model and texture loaders.
7 #include <simgear/compiler.h>
8 #include <simgear/props/props.hxx>
15 ////////////////////////////////////////////////////////////////////////
16 // Implementation of FGSSGLoader.
17 ////////////////////////////////////////////////////////////////////////
19 FGSSGLoader::FGSSGLoader ()
24 FGSSGLoader::~FGSSGLoader ()
26 std::map<string, ssgBase *>::iterator it = _table.begin();
27 while (it != _table.end()) {
36 std::map<string, ssgBase *>::iterator it = _table.begin();
37 while (it != _table.end()) {
38 ssgBase * item = it->second;
39 // If there is only one reference, it's
40 // ours; no one else is using the item.
41 if (item->getRef() == 1) {
51 ////////////////////////////////////////////////////////////////////////
52 // Implementation of FGModelLoader.
53 ////////////////////////////////////////////////////////////////////////
55 FGModelLoader::FGModelLoader ()
59 FGModelLoader::~FGModelLoader ()
64 FGModelLoader::load_model( const string &fg_root,
66 SGPropertyNode *prop_root,
69 // FIXME: normalize path to
71 std::map<string, ssgBase *>::iterator it = _table.find(path);
72 if (it == _table.end()) {
73 _table[path] = fgLoad3DModel( fg_root, path, prop_root, sim_time_sec );
74 it = _table.find(path);
75 it->second->ref(); // add one reference to keep it around
77 return (ssgEntity *)it->second;
82 ////////////////////////////////////////////////////////////////////////
83 // Implementation of FGTextureLoader.
84 ////////////////////////////////////////////////////////////////////////
86 FGTextureLoader::FGTextureLoader ()
90 FGTextureLoader::~FGTextureLoader ()
95 FGTextureLoader::load_texture( const string &fg_root, const string &path )
97 std::map<string, ssgBase *>::iterator it = _table.find(path);
98 if (it == _table.end()) {
99 _table[path] = new ssgTexture((char *)path.c_str()); // FIXME wrapu/v
100 it = _table.find(path);
101 it->second->ref(); // add one reference to keep it around
103 return (ssgTexture *)it->second;