From 9d61da0868b3e61ab0cfb1bc98dcfd8374aa3356 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 14 Apr 2021 00:03:43 +0300 Subject: [PATCH] Support loading scenes from Resources --- source/resources/resources.cpp | 15 +++++++++++++++ source/resources/resources.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/source/resources/resources.cpp b/source/resources/resources.cpp index a2d9219b..dca3e8d3 100644 --- a/source/resources/resources.cpp +++ b/source/resources/resources.cpp @@ -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().keyword("pose"); add_type().keyword("shader").creator(&Resources::create_program); add_type().suffix(".samp").keyword("sampler"); + add_type().suffix(".scene").creator(&Resources::create_scene); add_type().suffix(".tech").keyword("technique"); add_type().base().suffix(".tex1d").keyword("texture1d"); add_type().base().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 = 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); diff --git a/source/resources/resources.h b/source/resources/resources.h index 3036c2f4..abda5cde 100644 --- a/source/resources/resources.h +++ b/source/resources/resources.h @@ -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 &); -- 2.45.2