for o in objs:
obj_res = resources[prototypes[o.name].name+".object"]
- st = scene_res.create_reference_statement("object", obj_res)
+ st = scene_res.create_reference_statement("object", obj_res, o.name)
# XXX Parent relationships screw up the location and rotation
st.sub.append(Statement("position", o.location[0], o.location[1], o.location[2]))
if o.rotation_mode=="AXIS_ANGLE":
Scene::Loader::Loader(Scene &s, Collection &c):
- DataFile::CollectionObjectLoader<Scene>(s, &c)
+ DataFile::CollectionObjectLoader<Scene>(s, &c),
+ content(0)
+{
+ init();
+}
+
+Scene::Loader::Loader(Scene &s, Collection &c, ContentMap &m):
+ DataFile::CollectionObjectLoader<Scene>(s, &c),
+ content(&m)
+{
+ init();
+}
+
+void Scene::Loader::init()
{
add("object", &Loader::object);
+ add("object", &Loader::object_tagged);
}
void Scene::Loader::object(const string &n)
+{
+ object_tagged(n, string());
+}
+
+void Scene::Loader::object_tagged(const string &n, const string &t)
{
RefPtr<AnimatedObject> anob = new AnimatedObject(get_collection().get<GL::Object>(n));
load_sub(*anob);
obj.add(*anob);
+ if(content && !t.empty())
+ (*content)[t] = anob.get();
obj.owned_data.push_back(anob.release());
}
class Loader: public DataFile::CollectionObjectLoader<Scene>
{
public:
- Loader(Scene &, Collection &);
+ typedef std::map<std::string, Renderable *> ContentMap;
+
+ private:
+ ContentMap *content;
+ public:
+ Loader(Scene &, Collection &);
+ Loader(Scene &, Collection &, ContentMap &);
private:
+ void init();
+
void object(const std::string &);
+ void object_tagged(const std::string &, const std::string &);
};
protected:
+ // XXX If a loaded renderable is removed from the scene it needs to be removed from here as well
std::vector<Renderable *> owned_data;
mutable Matrix culling_matrix;
mutable Vector4 frustum_edges[6];