OBJ Files

File format

Supported features

  • Vertex positions 2D, 3D, 4D
  • Texture coordinates 2D, 3D
    • per vertex
    • per half-edge (per vertex per face)
  • Normals
    • per vertex
    • per half-edge (per vertex per face)
  • Vertex colors

API

PMeshIO.readobjmeshFunction
mesh = readobjmesh(io, template::Mesh[;
                   real_type=Float64, index_type=Int32,
                   color_type=RGBA,
                   position=Val(:x), normal=Val(:n),
                   texcoord=Val(:u), color=Val(:c))

Read mesh of same type as template from OBJ data steam io.

  • real_type, index_type and color_type are used by OBJBuffer
  • position, normal, texcoord and color denote attributes in mesh, which may or may not exist or may be disabled.
Note

This method is called by readmesh

See also readmesh, OBJBuffer, readobj

source
PMeshIO.writeobjmeshMethod
writeobjmesh(io, mesh[;
             position=Val(:x), texcoord=Val(:u),
             normal=nothing, color=Val(:c),
             format="%g"])

Write mesh to io in OBJ format using attributes

  • position
  • texcoord optional vertex texture coordinates, possibly stored per face (as hattr).
  • normal optional vertex normal, possibly stored per face (as hattr)
  • color optional vertex color (format)

Pass nothing to ignore an optional attribute. Attributes the are disabled are also ignored, i.e., not written.

The optional format argument specifies the output format of a floating point number as a String using sprintf-syntax.

Note

This method is called by writemesh.

See also writemesh, readobjmesh, readobj

source