diff --git a/blender.py b/blender.py index f741597..dcc9582 100644 --- a/blender.py +++ b/blender.py @@ -46,12 +46,14 @@ def render_polygons(f, name, polygons): uv_ix = 0 for i, polygon in enumerate(polygons): indices = [*polygon.vertices, polygon.material_index, uv_ix] + if len(polygon.vertices) == 3: + indices = [*polygon.vertices, -1, polygon.material_index, uv_ix] uv_ix += len(polygon.vertices) s = ", ".join(map(str, indices)) - if len(polygon.vertices) == 4: + if len(polygon.vertices) in {3, 4}: f.write(f" {{{s}}},\n") else: - f.write(f" {{0, 0, 0, 0, -1}}, // {{{s}}}\n") + f.write(f" {{-1, -1, -1, -1, -1, -1}}, // {{{s}}}\n") f.write("};\n\n") def render_polygon_edge_pairs(f, name, polygons): diff --git a/math/transform.hpp b/math/transform.hpp index 4e6337b..8e60b21 100644 --- a/math/transform.hpp +++ b/math/transform.hpp @@ -22,6 +22,17 @@ inline constexpr mat<4, 4, T> scale(vec<3, T> s) }; } +template +inline constexpr mat<4, 4, T> scale(T s) +{ + return { + s, 0, 0, 0, + 0, s, 0, 0, + 0, 0, s, 0, + 0, 0, 0, 1 + }; +} + template inline constexpr mat<4, 4, T> rotate_x(T t) {