Magnum::Trade::ObjImporter class

OBJ importer plugin.

Loads Wavefront OBJ (*.obj) files, with the following supported features:

  • multiple objects
  • vertex positions, normals and 2D texture coordinates
  • triangles, lines and points

Usage

This plugin depends on the Trade library and is built if MAGNUM_WITH_OBJIMPORTER is enabled when building Magnum. To use as a dynamic plugin, load "ObjImporter" via Corrade::PluginManager::Manager.

Additionally, if you're using Magnum as a CMake subproject, do the following:

set(MAGNUM_WITH_OBJIMPORTER ON CACHE BOOL "" FORCE)
add_subdirectory(magnum EXCLUDE_FROM_ALL)

# So the dynamically loaded plugin gets built implicitly
add_dependencies(your-app Magnum::ObjImporter)

To use as a static plugin or as a dependency of another plugin with CMake, you need to request the ObjImporter component of the Magnum package and link to the Magnum::ObjImporter target:

find_package(Magnum REQUIRED ObjImporter)

# ...
target_link_libraries(your-app PRIVATE Magnum::ObjImporter)

See Downloading and building, Usage with CMake, Loading and using plugins and File format support for more information.

Behavior and limitations

Meshes are imported as MeshPrimitive::Triangles with MeshIndexType::UnsignedInt indices, interleaved VertexFormat::Vector3 positions with optional VertexFormat::Vector3 normals and VertexFormat::Vector2 texture coordinates, if present in the source file.

Polygons (quads etc.) and material properties are currently not supported.

Base classes

class AbstractImporter
Base for importer plugins.

Constructors, destructors, conversion operators

ObjImporter() explicit
Default constructor.
ObjImporter(PluginManager::AbstractManager& manager, const Containers::StringView& plugin) explicit
Plugin manager constructor.