blender: add tentative triangle support
This commit is contained in:
parent
cb8fd7e345
commit
a37ec7eb2c
@ -46,12 +46,14 @@ def render_polygons(f, name, polygons):
|
|||||||
uv_ix = 0
|
uv_ix = 0
|
||||||
for i, polygon in enumerate(polygons):
|
for i, polygon in enumerate(polygons):
|
||||||
indices = [*polygon.vertices, polygon.material_index, uv_ix]
|
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)
|
uv_ix += len(polygon.vertices)
|
||||||
s = ", ".join(map(str, indices))
|
s = ", ".join(map(str, indices))
|
||||||
if len(polygon.vertices) == 4:
|
if len(polygon.vertices) in {3, 4}:
|
||||||
f.write(f" {{{s}}},\n")
|
f.write(f" {{{s}}},\n")
|
||||||
else:
|
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")
|
f.write("};\n\n")
|
||||||
|
|
||||||
def render_polygon_edge_pairs(f, name, polygons):
|
def render_polygon_edge_pairs(f, name, polygons):
|
||||||
|
@ -22,6 +22,17 @@ inline constexpr mat<4, 4, T> scale(vec<3, T> s)
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
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 <typename T>
|
template <typename T>
|
||||||
inline constexpr mat<4, 4, T> rotate_x(T t)
|
inline constexpr mat<4, 4, T> rotate_x(T t)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user