Skip to main content

Module mesh_formats

Module mesh_formats 

Source
Expand description

Tessellated interchange: glTF 2.0, OBJ and PLY.

Three formats, one philosophy carried over from the DXF writer: the functions take bare tessellations rather than a model, so anything that produces a Triangulation (a solid, one face, a healed import) exports without this module knowing where it came from. glTF is written as GLB, the single-file binary form, with positions, normals, indices and an optional base colour per mesh; OBJ and PLY are the plain-text dialects every downstream tool reads.

§Reading is not writing backwards

What this module writes is one of many shapes each format allows, and a reader that assumed its own writer’s choices would read almost nothing. glTF is the sharp case: its geometry reaches the file through accessors over buffer views over buffers, any of which may stride, offset, use any of six component types, scale integers into fractions, or be overridden piecewise by a sparse block, and the whole is placed by a node hierarchy stated as a matrix or as translation, rotation and scale. All of that is read. What is not read is refused by name rather than approximated.

Structs§

ExportMesh
One mesh to export, with what the format can say about it.
ImportedMesh
One mesh read back out of a glTF document.
ObjImport
What read_obj_with_materials found.
PlyImport
What read_ply_bytes found.

Enums§

MeshColours
The colours a mesh read carries, in the most compact form that says exactly what the file said.

Functions§

read_glb
Read a GLB: glTF 2.0’s single-file binary form.
read_gltf
Read a .gltf: the JSON form, whose buffers are data URIs.
read_obj
Read an OBJ into a triangulation.
read_obj_file
Read an OBJ file from disk with its materials, as read_obj_with_materials reads them.
read_obj_with_materials
Read an OBJ with the colours its materials give it.
read_ply
Read a PLY into a triangulation.
read_ply_bytes
Read a PLY, ASCII or binary of either byte order, mesh or point cloud.
write_glb
Write meshes as a GLB: glTF 2.0’s single-file binary form.
write_obj
Write meshes as Wavefront OBJ.
write_ply
Write one mesh as ASCII PLY.
write_ply_binary
Write a cloud, or a mesh over it, as binary little-endian PLY.
write_vrml
Write meshes as VRML 97.