diff options
Diffstat (limited to 'assetFactory')
| -rw-r--r-- | assetFactory/asset.cpp | 6 | ||||
| -rw-r--r-- | assetFactory/asset.h | 7 | ||||
| -rw-r--r-- | assetFactory/assetFactory.cpp | 5 | ||||
| -rw-r--r-- | assetFactory/lights.cpp | 14 | ||||
| -rw-r--r-- | assetFactory/lights.h | 18 |
5 files changed, 49 insertions, 1 deletions
diff --git a/assetFactory/asset.cpp b/assetFactory/asset.cpp index e3f5feb..0254943 100644 --- a/assetFactory/asset.cpp +++ b/assetFactory/asset.cpp @@ -7,6 +7,12 @@ Asset::persist(Persistence::PersistenceStore & store) return STORE_MEMBER(id) && STORE_MEMBER(name); } +std::any +Asset::createAt(const Location &) const +{ + return {}; +} + Asset::TexturePtr Asset::getTexture() const { diff --git a/assetFactory/asset.h b/assetFactory/asset.h index b5de056..d8b42f6 100644 --- a/assetFactory/asset.h +++ b/assetFactory/asset.h @@ -2,17 +2,22 @@ #include "factoryMesh.h" #include "persistence.h" +#include <any> #include <manyPtr.h> #include <stdTypeDefs.h> class TextureAtlas; class Renderable; +class Location; class Asset : public Persistence::Persistable, public StdTypeDefs<Asset> { public: - using ManyPtr = ManySharedPtr<Asset, const Renderable>; + using ManyPtr = ManySharedPtr<Asset, Renderable>; using TexturePtr = std::shared_ptr<TextureAtlas>; + /// Used only for the asset viewer + [[nodiscard]] virtual std::any createAt(const Location &) const; + std::string id; std::string name; diff --git a/assetFactory/assetFactory.cpp b/assetFactory/assetFactory.cpp index 426fecc..a8d6036 100644 --- a/assetFactory/assetFactory.cpp +++ b/assetFactory/assetFactory.cpp @@ -3,6 +3,7 @@ #include "cuboid.h" #include "cylinder.h" #include "filesystem.h" +#include "gfx/gl/gldebug.h" #include "gfx/image.h" #include "gfx/models/texture.h" #include "gfx/renderable.h" @@ -26,6 +27,7 @@ AssetFactory::AssetFactory() : std::shared_ptr<AssetFactory> AssetFactory::loadXML(const std::filesystem::path & filename) { + glDebugScope _ {0, filename.native()}; filesystem::FileStar file {filename.c_str(), "r"}; return Persistence::SAXParsePersistence {}.loadState<std::shared_ptr<AssetFactory>>(file); } @@ -33,6 +35,7 @@ AssetFactory::loadXML(const std::filesystem::path & filename) AssetFactory::Assets AssetFactory::loadAll(const std::filesystem::path & root) { + glDebugScope _ {0}; return std::accumulate(std::filesystem::recursive_directory_iterator {root}, std::filesystem::recursive_directory_iterator {}, Assets {}, [](auto out, const auto & path) { if (path.path().extension() == ".xml") { @@ -115,6 +118,7 @@ void AssetFactory::createTexutre() const { if (!textureFragments.empty() && !texture) { + glDebugScope _ {0}; // * layout images std::map<const TextureFragment *, std::unique_ptr<const Image>> images; std::transform( @@ -140,6 +144,7 @@ AssetFactory::createTexutre() const size++; return decltype(textureFragmentPositions)::value_type {i.first->id, m}; }); + texture->complete(); } } diff --git a/assetFactory/lights.cpp b/assetFactory/lights.cpp new file mode 100644 index 0000000..ec8e17e --- /dev/null +++ b/assetFactory/lights.cpp @@ -0,0 +1,14 @@ +#include "lights.h" + +bool +SpotLight::persist(Persistence::PersistenceStore & store) +{ + return STORE_TYPE && STORE_MEMBER(position) && STORE_MEMBER(direction) && STORE_MEMBER(colour) && STORE_MEMBER(kq) + && STORE_MEMBER(arc); +} + +bool +PointLight::persist(Persistence::PersistenceStore & store) +{ + return STORE_TYPE && STORE_MEMBER(position) && STORE_MEMBER(colour) && STORE_MEMBER(kq); +} diff --git a/assetFactory/lights.h b/assetFactory/lights.h new file mode 100644 index 0000000..8657d85 --- /dev/null +++ b/assetFactory/lights.h @@ -0,0 +1,18 @@ +#pragma once + +#include "gfx/models/lights.h" +#include "persistence.h" +#include "stdTypeDefs.h" + +struct SpotLight : Persistence::Persistable, SpotLightDef, StdTypeDefs<SpotLight> { +private: + friend Persistence::SelectionPtrBase<std::shared_ptr<SpotLight>>; + bool persist(Persistence::PersistenceStore & store) override; +}; + +struct PointLight : Persistence::Persistable, PointLightDef, StdTypeDefs<PointLight> { +private: + friend Persistence::SelectionPtrBase<std::shared_ptr<PointLight>>; + bool persist(Persistence::PersistenceStore & store) override; +}; + |
