]> git.tdb.fi Git - libs/gl.git/commitdiff
Allow tagging objects in a scene file for retrieval after loading
authorMikko Rasa <tdb@tdb.fi>
Fri, 24 May 2019 15:43:19 +0000 (18:43 +0300)
committerMikko Rasa <tdb@tdb.fi>
Fri, 24 May 2019 15:43:19 +0000 (18:43 +0300)
blender/io_mspgl/export_scene.py
source/scene.cpp
source/scene.h

index 3b2147d14d061b64352602aac8bf19a987f2019a..9b36c48ff43faadb0f7ef6da596f37e7806dfd47 100644 (file)
@@ -108,7 +108,7 @@ class SceneExporter:
 
                for o in objs:
                        obj_res = resources[prototypes[o.name].name+".object"]
 
                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":
                        # 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":
index ef1f246bac0c4f61b2ec5dc3bf402bf32067f10d..e6c62e802f8c9672fafce477d3eae50c9f2efaac 100644 (file)
@@ -75,16 +75,37 @@ bool Scene::frustum_cull(const Renderable &renderable) const
 
 
 Scene::Loader::Loader(Scene &s, Collection &c):
 
 
 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);
+       add("object", &Loader::object_tagged);
 }
 
 void Scene::Loader::object(const string &n)
 }
 
 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);
 {
        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());
 }
 
        obj.owned_data.push_back(anob.release());
 }
 
index 9e90b1284a014e90aa9a03191172b7137c80e35b..639a467fa849cb526c19ac31744b957f820af7ea 100644 (file)
@@ -21,13 +21,23 @@ public:
        class Loader: public DataFile::CollectionObjectLoader<Scene>
        {
        public:
        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:
        private:
+               void init();
+
                void object(const std::string &);
                void object(const std::string &);
+               void object_tagged(const std::string &, const std::string &);
        };
 
 protected:
        };
 
 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];
        std::vector<Renderable *> owned_data;
        mutable Matrix culling_matrix;
        mutable Vector4 frustum_edges[6];