mirror of
https://github.com/minetest/minetestmapper.git
synced 2024-12-26 10:50:40 +01:00
Add --min-y and --max-y options
This commit is contained in:
parent
33f323b1e3
commit
15444ff8f6
@ -53,6 +53,15 @@ drawplayers:
|
||||
draworigin:
|
||||
Draw origin indicator, `--draworigin`
|
||||
|
||||
noshading:
|
||||
Don't draw shading on nodes, `--noshading`
|
||||
|
||||
min-y:
|
||||
Don't draw nodes below this y value, `--min-y -25`
|
||||
|
||||
max-y:
|
||||
Don't draw nodes above this y value, `--max-y 75`
|
||||
|
||||
geometry:
|
||||
Limit area to specific geometry, `--geometry -800:-800+1600+1600`
|
||||
|
||||
|
@ -102,6 +102,8 @@ TileGenerator::TileGenerator():
|
||||
m_xMax(INT_MIN),
|
||||
m_zMin(INT_MAX),
|
||||
m_zMax(INT_MIN),
|
||||
m_yMin(-30000),
|
||||
m_yMax(30000),
|
||||
m_geomX(-50),
|
||||
m_geomY(-50),
|
||||
m_geomX2(50),
|
||||
@ -213,6 +215,16 @@ void TileGenerator::setGeometry(int x, int y, int w, int h)
|
||||
}
|
||||
}
|
||||
|
||||
void TileGenerator::setMinY(int y)
|
||||
{
|
||||
m_yMin = y;
|
||||
}
|
||||
|
||||
void TileGenerator::setMaxY(int y)
|
||||
{
|
||||
m_yMax = y;
|
||||
}
|
||||
|
||||
void TileGenerator::parseColorsFile(const std::string &fileName)
|
||||
{
|
||||
ifstream in;
|
||||
@ -295,6 +307,12 @@ void TileGenerator::loadBlocks()
|
||||
if (pos.x < m_geomX || pos.x >= m_geomX2 || pos.z < m_geomY || pos.z >= m_geomY2) {
|
||||
continue;
|
||||
}
|
||||
if (pos.y < m_yMin) {
|
||||
continue;
|
||||
}
|
||||
if (pos.y > m_yMax) {
|
||||
continue;
|
||||
}
|
||||
if (pos.x < m_xMin) {
|
||||
m_xMin = pos.x;
|
||||
}
|
||||
@ -479,7 +497,9 @@ inline void TileGenerator::renderMapBlock(const unsigned_string &mapBlock, const
|
||||
continue;
|
||||
}
|
||||
int imageX = getImageX(xBegin + x);
|
||||
for (int y = 15; y >= 0; --y) {
|
||||
int minY = (pos.y * 16 > m_yMin) ? 0 : m_yMin - pos.y * 16;
|
||||
int maxY = (pos.y * 16 < m_yMax) ? 15 : m_yMax - pos.y * 16;
|
||||
for (int y = maxY; y >= minY; --y) {
|
||||
int position = x + (y << 4) + (z << 8);
|
||||
int content = readBlockContent(mapData, version, position);
|
||||
if (content == m_blockIgnoreId || content == m_blockAirId) {
|
||||
|
@ -77,6 +77,8 @@ public:
|
||||
void setDrawScale(bool drawScale);
|
||||
void setShading(bool shading);
|
||||
void setGeometry(int x, int y, int w, int h);
|
||||
void setMinY(int y);
|
||||
void setMaxY(int y);
|
||||
void parseColorsFile(const std::string &fileName);
|
||||
void generate(const std::string &input, const std::string &output);
|
||||
|
||||
@ -117,6 +119,8 @@ private:
|
||||
int m_xMax;
|
||||
int m_zMin;
|
||||
int m_zMax;
|
||||
int m_yMin;
|
||||
int m_yMax;
|
||||
int m_geomX;
|
||||
int m_geomY;
|
||||
int m_geomX2;
|
||||
|
24
mapper.cpp
24
mapper.cpp
@ -51,6 +51,8 @@ int main(int argc, char *argv[])
|
||||
{"drawscale", no_argument, 0, 'S'},
|
||||
{"noshading", no_argument, 0, 'H'},
|
||||
{"geometry", required_argument, 0, 'g'},
|
||||
{"min-y", required_argument, 0, 'a'},
|
||||
{"max-y", required_argument, 0, 'c'},
|
||||
};
|
||||
|
||||
string input;
|
||||
@ -65,7 +67,7 @@ int main(int argc, char *argv[])
|
||||
if (c == -1) {
|
||||
if (input.empty() || output.empty()) {
|
||||
usage();
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -104,6 +106,22 @@ int main(int argc, char *argv[])
|
||||
case 'H':
|
||||
generator.setShading(false);
|
||||
break;
|
||||
case 'a': {
|
||||
istringstream iss;
|
||||
iss.str(optarg);
|
||||
int miny;
|
||||
iss >> miny;
|
||||
generator.setMinY(miny);
|
||||
}
|
||||
break;
|
||||
case 'c': {
|
||||
istringstream iss;
|
||||
iss.str(optarg);
|
||||
int maxy;
|
||||
iss >> maxy;
|
||||
generator.setMaxY(maxy);
|
||||
}
|
||||
break;
|
||||
case 'g': {
|
||||
istringstream geometry;
|
||||
geometry.str(optarg);
|
||||
@ -112,13 +130,13 @@ int main(int argc, char *argv[])
|
||||
geometry >> x >> c >> y >> w >> h;
|
||||
if (geometry.fail() || c != ':' || w < 1 || h < 1) {
|
||||
usage();
|
||||
exit(-1);
|
||||
exit(1);
|
||||
}
|
||||
generator.setGeometry(x, y, w, h);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user