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

This plugin depends on the Trade library and is built if WITH_OBJIMPORTER is enabled when building Magnum. To use as a dynamic plugin, you need to load the "ObjImporter" plugin from MAGNUM_PLUGINS_IMPORTER_DIR. 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. See Downloading and building, Usage with CMake and Loading and using plugins for more information.

Behavior and limitations

Polygons (quads etc.), automatic normal generation 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 std::string& plugin) explicit
Plugin manager constructor.

Private functions

auto doFeatures() const override -> Features virtual
Implementation for features()
auto doIsOpened() const override -> bool virtual
Implementation for isOpened()
void doOpenData(Containers::ArrayView<const char> data) override virtual
Implementation for openData()
void doOpenFile(const std::string& filename) override virtual
Implementation for openFile()
void doClose() override virtual
Implementation for close()
auto doMesh3DCount() const override -> UnsignedInt virtual
Implementation for mesh3DCount()
auto doMesh3DForName(const std::string& name) override -> Int virtual
Implementation for mesh3DForName()
auto doMesh3DName(UnsignedInt id) override -> std::string virtual
Implementation for mesh3DName()
auto doMesh3D(UnsignedInt id) override -> Containers::Optional<MeshData3D> virtual
Implementation for mesh3D()

Function documentation

void Magnum::Trade::ObjImporter::doOpenFile(const std::string& filename) override virtual private

Implementation for openFile()

If Feature::OpenData is supported, default implementation opens the file and calls doOpenData() with its contents. It is allowed to call this function from your doOpenFile() implementation.

UnsignedInt Magnum::Trade::ObjImporter::doMesh3DCount() const override virtual private

Implementation for mesh3DCount()

Default implementation returns 0.

Int Magnum::Trade::ObjImporter::doMesh3DForName(const std::string& name) override virtual private

Implementation for mesh3DForName()

Default implementation returns -1.

std::string Magnum::Trade::ObjImporter::doMesh3DName(UnsignedInt id) override virtual private

Implementation for mesh3DName()

Default implementation returns empty string.