aboutsummaryrefslogtreecommitdiff
path: root/src/tile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tile.cpp')
-rw-r--r--src/tile.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tile.cpp b/src/tile.cpp
index 17ec51614..7cb39eabf 100644
--- a/src/tile.cpp
+++ b/src/tile.cpp
@@ -389,6 +389,7 @@ public:
// Shall be called from the main thread.
bool generateImage(std::string part_of_name, video::IImage *& baseimg);
+ video::ITexture* getNormalTexture(const std::string &name);
private:
// The id of the thread that is allowed to use irrlicht directly
@@ -1872,3 +1873,24 @@ void imageTransform(u32 transform, video::IImage *src, video::IImage *dst)
dst->setPixel(dx,dy,c);
}
}
+
+video::ITexture* TextureSource::getNormalTexture(const std::string &name)
+{
+ u32 id;
+ if (isKnownSourceImage("override_normal.png"))
+ return getTexture("override_normal.png", &id);
+ std::string fname_base = name;
+ std::string normal_ext = "_normal.png";
+ size_t pos = fname_base.find(".");
+ std::string fname_normal = fname_base.substr(0, pos) + normal_ext;
+ if (isKnownSourceImage(fname_normal)) {
+ // look for image extension and replace it
+ size_t i = 0;
+ while ((i = fname_base.find(".", i)) != std::string::npos) {
+ fname_base.replace(i, 4, normal_ext);
+ i += normal_ext.length();
+ }
+ return getTexture(fname_base, &id);
+ }
+ return NULL;
+}