meshio
meshio copied to clipboard
Wavefront object normals and texture reading and writing
Hi, thank you for your work on this library.
Concerning wavefront objects, it seems normals and textures are not fully implemented, and I could not find an issue relating to it. The reader and writer correctly handles the normals (vn) and texture (vt) lines, but does not handle the face groups part.
According to the wiki on face elements each polygon's vertice can have a texture and normal id.
# Polygonal face element (see below)
f 1 2 3 << only vertices
f 3/1 4/2 5/3 << vertices and textures
f 6/4/1 3/5/3 7/6/5 << vertices textures and normals
f 7//1 8//2 9//3 << vertices and normals
The obj reader code is almost there.
elif split[0] == "f":
dat = [int(item.split("/")[0]) for item in split[1:]]
if len(face_groups) == 0 or (
len(face_groups[-1]) > 0 and len(face_groups[-1][-1]) != len(dat)
):
face_groups.append([])
face_groups[-1].append(dat)
item.split("/")
contains data for vertice, texture, and normal.
I just don't know in which part of the Mesh object this data coulrd / should be stored.
I second this request.
Each face of a mesh can index the buffers of vertices, texture coordinates and normals independently.
We could gather the face texture and face normal info in some additional face_texture_groups
and face_normals_groups
to complement face_groups
.
Should then these be stored in some additional CellBlock("triangle_texture", ...)
and CellBlock("triangle_normals", ...)
along with CellBlock("triangle", ...)
here?