1 // loader.cxx - implement SSG model and texture loaders.
7 #include <simgear/compiler.h>
8 #include <simgear/misc/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 &path)
66 // FIXME: normalize path to
68 std::map<string, ssgBase *>::iterator it = _table.find(path);
69 if (it == _table.end()) {
70 _table[path] = fgLoad3DModel((char *)path.c_str());
71 it = _table.find(path);
72 it->second->ref(); // add one reference to keep it around
74 return (ssgEntity *)it->second;
79 ////////////////////////////////////////////////////////////////////////
80 // Implementation of FGTextureLoader.
81 ////////////////////////////////////////////////////////////////////////
83 FGTextureLoader::FGTextureLoader ()
87 FGTextureLoader::~FGTextureLoader ()
92 FGTextureLoader::load_texture (const string &path)
94 std::map<string, ssgBase *>::iterator it = _table.find(path);
95 if (it == _table.end()) {
96 _table[path] = new ssgTexture((char *)path.c_str()); // FIXME wrapu/v
97 it = _table.find(path);
98 it->second->ref(); // add one reference to keep it around
100 return (ssgTexture *)it->second;