diff --git a/Changelog b/Changelog index 240b691..675937b 100644 --- a/Changelog +++ b/Changelog @@ -12,6 +12,12 @@ are: point, line, rectangle, ellipse (circle), text. Translucency (alpha) is supported, although for ellipses, it does not work as expected (due to a bug in libgd) + - 'air' nodes can now have a color. Their color should be defined as fully + transparent (alpha = 0), so that they don't obscure underlying blocks. + In that case, air will only be drawn if no other blocks are beneath it. + Nodes with alpha value 0 never participate in shading. + As this comes at a significant performance penalty, this feature is + subject to a command-line option: --drawair. - A default color can be specified for invisible/undefined nodes in rendered blocks Normally, such nodes are not drawn, so they have the background color; If a different default color is specified, undefined/invisible diff --git a/README.rst b/README.rst index 0dcdc98..1bcbb31 100644 --- a/README.rst +++ b/README.rst @@ -171,6 +171,14 @@ draworigin: drawalpha: Allow blocks to be drawn with transparency, `--drawalpha` +drawair: + Draw air blocks (at a significant performance penalty). `--drawair` + + For best results, the air color should be defined as fully transparent + so that the color of underlying blocks overrides it. + + This option has a significant performance impact. + noshading: Don't draw shading on nodes, `--noshading` diff --git a/TileGenerator.cpp b/TileGenerator.cpp index 5f078c5..5abdaae 100644 --- a/TileGenerator.cpp +++ b/TileGenerator.cpp @@ -131,6 +131,7 @@ TileGenerator::TileGenerator(): m_drawPlayers(false), m_drawScale(false), m_drawAlpha(false), + m_drawAir(false), m_shading(true), m_border(0), m_backend(DEFAULT_BACKEND), @@ -268,6 +269,11 @@ void TileGenerator::setDrawAlpha(bool drawAlpha) m_drawAlpha = drawAlpha; } +void TileGenerator::setDrawAir(bool drawAir) +{ + m_drawAir = drawAir; +} + void TileGenerator::setShading(bool shading) { m_shading = shading; @@ -1089,7 +1095,9 @@ void TileGenerator::processMapBlock(const DB::Block &block) readString(name, data, dataOffset, nameLen, length); name = name.c_str(); // Truncate any trailing NUL bytes if (name == "air") { - m_blockAirId = nodeId; + ColorMap::const_iterator color = m_colors.find(name); + if (!m_drawAir || color == m_colors.end()) + m_blockAirId = nodeId; } else if (name == "ignore") { m_blockIgnoreId = nodeId; diff --git a/TileGenerator.h b/TileGenerator.h index 872e8d1..b7b2582 100644 --- a/TileGenerator.h +++ b/TileGenerator.h @@ -92,6 +92,7 @@ public: void setDrawPlayers(bool drawPlayers); void setDrawScale(bool drawScale); void setDrawAlpha(bool drawAlpha); + void setDrawAir(bool drawAir); void drawObject(const DrawObject &object) { m_drawObjects.push_back(object); } void setShading(bool shading); void setGeometry(const NodeCoord &corner1, const NodeCoord &corner2); @@ -169,6 +170,7 @@ private: bool m_drawPlayers; bool m_drawScale; bool m_drawAlpha; + bool m_drawAir; bool m_shading; int m_border; std::string m_backend; diff --git a/colors.txt b/colors.txt index 2decbce..7a983f3 100644 --- a/colors.txt +++ b/colors.txt @@ -1,3 +1,4 @@ +air 220 220 255 0 mesecons_pistons:piston_up_sticky_on 160 160 160 mesecons_pistons:piston_normal_off 125 125 125 mesecons_pistons:piston_up_pusher_sticky 123 124 124 diff --git a/mapper.cpp b/mapper.cpp index d30cfaa..dbdc59b 100644 --- a/mapper.cpp +++ b/mapper.cpp @@ -26,6 +26,7 @@ using namespace std; #define OPT_PROGRESS_INDICATOR 0x82 #define OPT_DRAW_OBJECT 0x83 #define OPT_BLOCKCOLOR 0x84 +#define OPT_DRAWAIR 0x85 #define OPT_VERBOSE_SEARCH_COLORS 0x86 // Will be replaced with the actual name and location of the executable (if found) @@ -71,6 +72,7 @@ void usage() " --drawplayers\n" " --draworigin\n" " --drawalpha\n" + " --drawair\n" " --draw[map]point \", color\"\n" " --draw[map]line \" color\"\n" " --draw[map]circle \" color\"\n" @@ -526,6 +528,7 @@ int main(int argc, char *argv[]) {"drawplayers", no_argument, 0, 'P'}, {"drawscale", no_argument, 0, 'S'}, {"drawalpha", no_argument, 0, 'e'}, + {"drawair", no_argument, 0, OPT_DRAWAIR}, {"drawpoint", required_argument, 0, OPT_DRAW_OBJECT}, {"drawline", required_argument, 0, OPT_DRAW_OBJECT}, {"drawcircle", required_argument, 0, OPT_DRAW_OBJECT}, @@ -647,6 +650,9 @@ int main(int argc, char *argv[]) case 'e': generator.setDrawAlpha(true); break; + case OPT_DRAWAIR: + generator.setDrawAir(true); + break; case 'H': generator.setShading(false); break;