diff --git a/res/models/stairs.xml b/res/models/stairs.xml
index 9eeac7a1..5921e08c 100644
--- a/res/models/stairs.xml
+++ b/res/models/stairs.xml
@@ -1,6 +1,6 @@
-
-
+
+
diff --git a/src/coders/vcm.cpp b/src/coders/vcm.cpp
index 9e87f5ab..e86fc138 100644
--- a/src/coders/vcm.cpp
+++ b/src/coders/vcm.cpp
@@ -14,8 +14,8 @@ static const std::unordered_map side_indices {
{"south", 1},
{"top", 2},
{"bottom", 3},
- {"east", 4},
- {"west", 5},
+ {"west", 4},
+ {"east", 5},
};
static void perform_rect(const xmlelement& root, model::Model& model) {
diff --git a/src/graphics/commons/Model.cpp b/src/graphics/commons/Model.cpp
index 05835f2a..20d90eb4 100644
--- a/src/graphics/commons/Model.cpp
+++ b/src/graphics/commons/Model.cpp
@@ -77,13 +77,13 @@ void Mesh::addBox(
if (enabledSides[1]) // south
addPlane(pos-Z*size, -X*size, Y*size, -Z, uvs[1]);
if (enabledSides[2]) // top
- addPlane(pos+Y*size, X*size, -Z*size, Y, uvs[2]);
+ addPlane(pos+Y*size, X*size, -Z*size, Y, uvs[2] * glm::vec2(-1));
if (enabledSides[3]) // bottom
- addPlane(pos-Y*size, X*size, Z*size, -Y, uvs[3]);
+ addPlane(pos-Y*size, X*size, Z*size, -Y, uvs[3] * glm::vec2(-1, 1));
if (enabledSides[4]) // west
addPlane(pos+X*size, -Z*size, Y*size, X, uvs[4]);
if (enabledSides[5]) // east
- addPlane(pos-X*size, Z*size, Y*size, -X, uvs[5]);
+ addPlane(pos-X*size, Z*size, Y*size, -X, uvs[5] * glm::vec2(-1, 1));
}
void Mesh::scale(const glm::vec3& size) {
diff --git a/src/graphics/render/ModelsGenerator.cpp b/src/graphics/render/ModelsGenerator.cpp
index ccaffa0d..230c4804 100644
--- a/src/graphics/render/ModelsGenerator.cpp
+++ b/src/graphics/render/ModelsGenerator.cpp
@@ -98,7 +98,7 @@ model::Model ModelsGenerator::fromCustom(
for (size_t i = 0; i < modelBoxes.size(); i++) {
auto& mesh = model.addMesh("blocks:");
mesh.lighting = lighting;
- const UVRegion boxtexfaces[6] = {
+ UVRegion boxtexfaces[6] = {
get_region_for(modelTextures[i * 6 + 5], assets),
get_region_for(modelTextures[i * 6 + 4], assets),
get_region_for(modelTextures[i * 6 + 3], assets),
@@ -106,6 +106,9 @@ model::Model ModelsGenerator::fromCustom(
get_region_for(modelTextures[i * 6 + 1], assets),
get_region_for(modelTextures[i * 6 + 0], assets)
};
+ boxtexfaces[2].scale(glm::vec2(-1));
+ boxtexfaces[5].scale(glm::vec2(-1, 1));
+
bool enabled[6] {1,1,1,1,1,1};
mesh.addBox(
modelBoxes[i].center(),
diff --git a/src/graphics/ui/elements/ModelViewer.cpp b/src/graphics/ui/elements/ModelViewer.cpp
index 4f931839..686a6a01 100644
--- a/src/graphics/ui/elements/ModelViewer.cpp
+++ b/src/graphics/ui/elements/ModelViewer.cpp
@@ -95,6 +95,7 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) {
ctx.setFramebuffer(fbo.get());
ctx.setViewport({size.x, size.y});
ctx.setDepthTest(true);
+ ctx.setCullFace(true);
display::clear();
auto& ui3dShader = assets.require("ui3d");
@@ -111,8 +112,8 @@ void ModelViewer::draw(const DrawContext& pctx, const Assets& assets) {
"blocks:dbg_south",
"blocks:dbg_top",
"blocks:dbg_bottom",
- "blocks:dbg_east",
"blocks:dbg_west",
+ "blocks:dbg_east",
};
region = util::get_texture_region(
assets,
diff --git a/src/maths/UVRegion.hpp b/src/maths/UVRegion.hpp
index 0940cd3c..354c939b 100644
--- a/src/maths/UVRegion.hpp
+++ b/src/maths/UVRegion.hpp
@@ -43,8 +43,8 @@ struct UVRegion {
}
void scale(float x, float y) {
- float w = getWidth();
- float h = getHeight();
+ float w = u2 - u1;
+ float h = v2 - v1;
float cx = (u1 + u2) * 0.5f;
float cy = (v1 + v2) * 0.5f;
u1 = cx - w * 0.5f * x;
@@ -63,4 +63,10 @@ struct UVRegion {
u2 = vec.z;
v2 = vec.w;
}
+
+ UVRegion operator*(const glm::vec2& scale) const {
+ auto copy = UVRegion(*this);
+ copy.scale(scale);
+ return copy;
+ }
};