Skip to content

Mesh Formats

Lukas Kalbertodt edited this page Dec 3, 2018 · 11 revisions

Overview

  • PLY: Arbitrary elements with arbitrary properties. Standard conventions exist. No exact specification.
  • STL: Super simple, just a list of faces with face normal and three vertex positions each.
  • OFF: ASCII, very simple, only f32, only position and face-color
  • OBJ: Fairly powerful, but can't store arbitrary properties. Face, edge and point elements. Extended by MTL format which stores material information.
  • COLLADA: By Khronos Group, super extensive, supports nearly everything :P
  • FBX: proprietary TODO
  • 3DS: proprietary TODO
  • X3D: wants to be the standard, but no-one is using it

Description

PLY ("specs", wiki)

ASCII & binary

Can store arbitrary elements with arbitrary properties. Since everything is arbitrary, there exist a number of conventions used by most software:

  • There exist an element vertex
    • It has three float or double properties called x, y and z
  • There exist an element face
    • It has a vertex_indices property which is a list of uints. Each list is three entries long.

Properties can have the following types:

  • {u|i}{8|16|32}
  • f{32|64}
  • Variable length homogeneous lists of one of the primitive types

Each property can be stored as ASCII or as binary in either BE or LE.

Example file

ply
format ascii 1.0
element vertex 3
property double x
property double y
property double z
element face 1
property list uchar uint vertex_indices
end_header
0 0 0
1 3 0
2 0 0
3 0 1 2
ASCII & binary

Very limited. Just a list of triangles each of which specifies a normal and the position of all three vertices. The only type is f32.

Example file

solid myname
facet normal ni nj nk
    outer loop
        vertex v1x v1y v1z
        vertex v2x v2y v2z
        vertex v3x v3y v3z
    endloop
endfacet
endsolid myname

OFF ("specs", wiki)

ASCII only
  • Only floats
  • Vertex data: only 3D pos
  • Face data: vertex indices and potentially color (3x u8)
OFF
# cube.off
# A cube
 
8 6 12
 1.0  0.0 1.4142
 0.0  1.0 1.4142
-1.0  0.0 1.4142
 0.0 -1.0 1.4142
 1.0  0.0 0.0
 0.0  1.0 0.0
-1.0  0.0 0.0
 0.0 -1.0 0.0
4  0 1 2 3  255 0 0 #red
4  7 4 0 3  0 255 0 #green
4  4 5 1 0  0 0 255 #blue
4  5 6 2 1  0 255 0 
4  3 2 6 7  0 0 255
4  6 5 4 7  255 0 0

OBJ (specs, wiki)

basically ASCII only

Supports polygonal and free-form objects. To make things easy, we'll completely ignore everything related to free-form objects.

Vertices can have the following properties attached to them:

  • position (3d) plus optional weight (only for free form)
  • normal (3d)
  • UV coordinate (2 or 3 dimensional)

There are point, line and face elements. Faces are specified by specifying the indices of the surrounding vertices in CCW-order. Faces and lines can consist of arbitrarily many vertices.

The format .mtl is closely related to .obj and stores material information. This can probably store arbitrary properties for vertices. Without this however, OBJ files cannot store arbitrary properties. However, OBJ without MTL already stores some rendering information. We should ignore those for now.

Example

v 0.000000 2.000000 0.000000
v 0.000000 0.000000 0.000000
v 2.000000 0.000000 0.000000
v 2.000000 2.000000 0.000000
f 1 2 3 
f 3 4 1

COLLADA (specs, wiki, website)

XML

Very extensive. Supports arbitrary vertex (and probably face, edge, ...) properties.

Helpful resources

Links