summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-03-12 00:54:24 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2023-03-12 19:43:14 +0000
commit88c9d66352c2f4856682efd48482b5b72aca18bf (patch)
tree7da5207ceb7cccf2866945fe0c6ba75533663704
parentInitial version of texture packer (diff)
downloadilt-88c9d66352c2f4856682efd48482b5b72aca18bf.tar.bz2
ilt-88c9d66352c2f4856682efd48482b5b72aca18bf.tar.xz
ilt-88c9d66352c2f4856682efd48482b5b72aca18bf.zip
Support loading references to texture fragments
-rw-r--r--assetFactory/assetFactory.cpp3
-rw-r--r--assetFactory/assetFactory.h3
-rw-r--r--assetFactory/textureFragment.cpp7
-rw-r--r--assetFactory/textureFragment.h14
-rw-r--r--res/brush47.xml2
-rw-r--r--res/rail/roofSideWithVents.pngbin0 -> 17011 bytes
-rw-r--r--res/rail/roofTopWithVents.pngbin0 -> 11921 bytes
7 files changed, 29 insertions, 0 deletions
diff --git a/assetFactory/assetFactory.cpp b/assetFactory/assetFactory.cpp
index f5fc2b3..de13579 100644
--- a/assetFactory/assetFactory.cpp
+++ b/assetFactory/assetFactory.cpp
@@ -75,11 +75,14 @@ AssetFactory::parseColour(std::string_view in) const
}
throw std::runtime_error("No such asset factory colour");
}
+
bool
AssetFactory::persist(Persistence::PersistenceStore & store)
{
using MapObjects = Persistence::MapByMember<Shapes, std::shared_ptr<Object>>;
using MapAssets = Persistence::MapByMember<Assets>;
+ using MapTextureFragments = Persistence::MapByMember<TextureFragments>;
return STORE_TYPE && STORE_NAME_HELPER("object", shapes, MapObjects)
+ && STORE_NAME_HELPER("textureFragment", textureFragments, MapTextureFragments)
&& STORE_NAME_HELPER("asset", assets, MapAssets);
}
diff --git a/assetFactory/assetFactory.h b/assetFactory/assetFactory.h
index b47d408..3d52f7f 100644
--- a/assetFactory/assetFactory.h
+++ b/assetFactory/assetFactory.h
@@ -3,12 +3,14 @@
#include "asset.h"
#include "persistence.h"
#include "shape.h"
+#include "textureFragment.h"
#include <filesystem>
class AssetFactory : public Persistence::Persistable {
public:
using Shapes = std::map<std::string, Shape::Ptr, std::less<>>;
using Assets = std::map<std::string, Asset::Ptr, std::less<>>;
+ using TextureFragments = std::map<std::string, TextureFragment::Ptr, std::less<>>;
using Colour = glm::vec3;
using ColourAlpha = glm::vec4;
using Colours = std::map<std::string, Colour, std::less<>>;
@@ -20,6 +22,7 @@ public:
Shapes shapes;
Assets assets;
Colours colours;
+ TextureFragments textureFragments;
static Colours parseX11RGB(const char * rgbtxtpath);
static void normalizeColourName(std::string &);
diff --git a/assetFactory/textureFragment.cpp b/assetFactory/textureFragment.cpp
new file mode 100644
index 0000000..72107a5
--- /dev/null
+++ b/assetFactory/textureFragment.cpp
@@ -0,0 +1,7 @@
+#include "textureFragment.h"
+
+bool
+TextureFragment::persist(Persistence::PersistenceStore & store)
+{
+ return STORE_TYPE && STORE_MEMBER(id) && STORE_MEMBER(path);
+}
diff --git a/assetFactory/textureFragment.h b/assetFactory/textureFragment.h
new file mode 100644
index 0000000..52f2591
--- /dev/null
+++ b/assetFactory/textureFragment.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "persistence.h"
+#include "stdTypeDefs.hpp"
+
+class TextureFragment : public Persistence::Persistable, public StdTypeDefs<TextureFragment> {
+public:
+ std::string id;
+ std::string path;
+
+private:
+ friend Persistence::SelectionPtrBase<Ptr>;
+ bool persist(Persistence::PersistenceStore & store) override;
+};
diff --git a/res/brush47.xml b/res/brush47.xml
index dbd3327..a7e3894 100644
--- a/res/brush47.xml
+++ b/res/brush47.xml
@@ -59,6 +59,8 @@
</face>
</use>
</object>
+ <textureFragment id="roofSideWithVents" path="rail/roofSideWithVents.png"/>
+ <textureFragment id="roofTopWithVents" path="rail/roofTopWithVents.png"/>
<asset p.typeid="RailVehicleClass" id="brush-47" name="Brush 47" length="19.38" wheelBase="15.70" maxSpeed="42.4688">
<bodyMesh id="body" size="2.69,19.38,3.9">
<use type="cuboid" position="0,0,1.2" scale="2.69,19.38,0.3" colour="goldenrod">
diff --git a/res/rail/roofSideWithVents.png b/res/rail/roofSideWithVents.png
new file mode 100644
index 0000000..67ed851
--- /dev/null
+++ b/res/rail/roofSideWithVents.png
Binary files differ
diff --git a/res/rail/roofTopWithVents.png b/res/rail/roofTopWithVents.png
new file mode 100644
index 0000000..0f64ced
--- /dev/null
+++ b/res/rail/roofTopWithVents.png
Binary files differ