Reference/API

PMeshIO.OBJBufferType

Store contents of Wavefront OBJ file, use for reading files.

  • T is the scalar type, I is the index type, ColorT is used for RGBA colors
  • nv: numberof vertices
  • positiondim number of coordinates (2,3,3)
  • texcoorddim number of texture coordinates (1,2,3)
  • position coordinates of vertex positions
  • texcoord texture coordinates
  • normal coordinates of normals (always 3 coordinates per normal)
  • fdegree vector of face degrees
  • vidx indices of vertices (positions) spanning faces
  • tidx indices of texture coordinates, may be discontinuous (i.e., possibly >1 per vertex)
  • nidx indices of normal vectors, may be discontinuous (i.e., possibly >1 per vertex)
  • vcolor per vertex color as ColorT
Note

In contrast to MeshIO, polygons are not triangulated, and there is support for "discontinuous" normals and texture coordinates that are defined per face vertex.

See also Wavefront OBJ and vertex color

See also writeobjmesh

source
PMesh.createmeshMethod
mesh = createmesh(obj::OBJBuffer;
                  template::Mesh=createmesh(; real_type=T),
                  position=Val(:x),
                  normal=Val(:n),
                  texcoord=Val(:u))

Create mesh from obj that was read by readobj using template and the specified attribute names.

  • Attributes which are not defined in obj will be disabled!
  • Attributes which are not defined in template are not copied from obj.
Note

The given attribute names are uses equally for vertex attributes and for half-edge attributes.

See also OBJBuffer, `toggleattributes!

source
PMesh.createmeshMethod
mesh = createmesh(::OBJ[; real_type=Float64, dimx=Val(3), dimu=Val(2)])

Create an empty mesh with all attributes that may be read from an OBJ file: position, normal, and texture coordinates:

  • vertex attributes :x, :n, :u, :c
  • face attributes: :n
  • half-edge attributes :n, :u

The latter stores texture coordinates and normals that are defined for each vertex of a face.

Note

This method uses default attribute names :x, :n, :u, :c!

source
PMeshIO.copy!Method
copy!(mesh, obj,
      Val(NX), Val(NU),
      Val(:x), Val(:n), Val(:u), Val(:c))

Helper that copies contents of [OBJBuffer])@ref) obj to mesh using dimensions NX and NU and the provided attributes for position, normal, texture coordinates, and color.

See also OBJBuffer, createmesh

source
PMeshIO.hashnMethod

Does OBJBuffer provide texture coordinates per face?

Note

Per-face texture coordinates will be stored as half-edge attribute (hattr) in PMesh

source
PMeshIO.hashtMethod

Does OBJBuffer provide vertex normals per face?

Note

Per-face normals will be stored as half-edge attribute (hattr) in PMesh

source
PMeshIO.normalFunction
N = normal(obj)
ns = normal(obj, Val(3))

Get normals stored in OBJBuffer as N::Matrix{T} with normals in columns or ns::Vector{SVector{T, 3}}.

Note

The returned matrix/vectors shares data with obj!

source
PMeshIO.positionFunction
X = position(obj)
xs = position(obj, Val(N))

Get vertex positions stored in OBJBuffer as X::Matrix{T} with positions in columns or xs::Vector{SVector{T, N}} (where N must match positiondim.

Note

The returned matrix/vectors shares data with obj!

source
PMeshIO.texcoordFunction
U = texcoord(obj)
us = texcoord(obj, Val(N))

Get texcoords stored in OBJBuffer as U::Matrix{T} with texture coordinates in columns or us::Vector{SVector{T, N}} (where N must match texcoorddim.

Note

The returned matrix/vectors shares data with obj!

source
PMeshIO.update!Method

Update number of vertices and dimensions of OBJBuffer after reading.

Note

Constructs a new OBJBuffer and "steals" data from obj!

source