]> git.tdb.fi Git - libs/gl.git/commitdiff
Support loading scenes from Resources
authorMikko Rasa <tdb@tdb.fi>
Tue, 13 Apr 2021 21:03:43 +0000 (00:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 13 Apr 2021 21:03:43 +0000 (00:03 +0300)
source/resources/resources.cpp
source/resources/resources.h

index a2d9219b0f6075a97f7be5d6d54b3341a98f88e4..dca3e8d3d82158947b33ae743a3deb0cf6ecf0ee 100644 (file)
@@ -16,6 +16,7 @@
 #include "resourcemanager.h"
 #include "resources.h"
 #include "sampler.h"
+#include "scene.h"
 #include "technique.h"
 #include "texture1d.h"
 #include "texture2d.h"
@@ -51,6 +52,7 @@ Resources::Resources():
        add_type<Pose>().keyword("pose");
        add_type<Program>().keyword("shader").creator(&Resources::create_program);
        add_type<Sampler>().suffix(".samp").keyword("sampler");
+       add_type<Scene>().suffix(".scene").creator(&Resources::create_scene);
        add_type<Technique>().suffix(".tech").keyword("technique");
        add_type<Texture1D>().base<Texture>().suffix(".tex1d").keyword("texture1d");
        add_type<Texture2D>().base<Texture>().suffix(".tex2d").suffix(".png").suffix(".jpg").keyword("texture2d").creator(&Resources::create_texture2d);
@@ -124,6 +126,19 @@ Mesh *Resources::create_mesh(const string &name)
        return 0;
 }
 
+Scene *Resources::create_scene(const string &name)
+{
+       if(RefPtr<IO::Seekable> io = open_raw(name))
+       {
+               DataFile::Parser parser(*io, name);
+               Scene::GenericLoader ldr(*this);
+               ldr.load(parser);
+               return ldr.get_scene();
+       }
+
+       return 0;
+}
+
 Texture2D *Resources::create_texture2d(const string &name)
 {
        string ext = FS::extpart(name);
index 3036c2f463ef44425d0a4f48939a84fb363aae37..abda5cde7b29f8ee0756536e9acf918510a5333f 100644 (file)
@@ -12,6 +12,7 @@ class Mesh;
 class Module;
 class Program;
 class ResourceManager;
+class Scene;
 class Texture2D;
 
 /**
@@ -45,6 +46,7 @@ public:
 protected:
        Material *create_material(const std::string &);
        Mesh *create_mesh(const std::string &);
+       Scene *create_scene(const std::string &);
        Texture2D *create_texture2d(const std::string &);
        Module *create_module(const std::string &);
        Program *create_program(const std::string &);