Magnum::Trade::TinyGltfImporter class

TinyGltf importer plugin.

Imports glTF and binary glTF using the TinyGLTF library.

This plugin depends on the Trade library and is built if WITH_TINYGLTFIMPORTER is enabled when building Magnum Plugins. To use as a dynamic plugin, you need to load the "TinyGltfImporter" 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 TinyGltfImporter component of the MagnumPlugins package and link to the MagnumPlugins::TinyGltfImporter target. See Downloading and building plugins, Plugin usage with CMake and Loading and using plugins for more information.

This plugin provides GltfImporter and GlbImporter plugins.

Defaults

As glTF leaves the defaults of some properties to the application, the following defaults have been chosen for this importer:

Behavior and limitations

  • Importer requires no specific JSON node in glTF file (like accessors) so it can be used to import only light data, for example.

Light import

  • Light intensity is not yet supported due to glTF extension draft state.

Mesh import

  • Only the first mesh of a multi-primitive mesh is imported.
  • Meshes with interleaved vertex data/buffer views are not supported.

Material import

  • All materials are imported as Trade::PhongMaterialData with ambient color always set to 0x000000_rgbf
  • Alpha channel of colors is ignored.

Texture import

Access to internal importer state

Access to the underlying TinyGLTF structures it is provided through importer-specific data accessors:

Base classes

class AbstractImporter
Base for importer plugins.

Constructors, destructors, conversion operators

TinyGltfImporter() explicit
Default constructor.
TinyGltfImporter(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()
auto doCamera(UnsignedInt id) override -> Containers::Optional<CameraData> virtual
Implementation for camera()
auto doCameraCount() const override -> UnsignedInt virtual
Implementation for cameraCount()
auto doLight(UnsignedInt id) override -> Containers::Optional<LightData> virtual
Implementation for light()
auto doLightCount() const override -> UnsignedInt virtual
Implementation for lightCount()
auto doDefaultScene() override -> Int virtual
Implementation for defaultScene()
auto doScene(UnsignedInt id) override -> Containers::Optional<SceneData> virtual
Implementation for scene()
auto doSceneCount() const override -> UnsignedInt virtual
Implementation for sceneCount()
auto doObject3DCount() const override -> UnsignedInt virtual
Implementation for object3DCount()
auto doObject3DName(UnsignedInt id) override -> std::string virtual
Implementation for object3DName()
auto doObject3DForName(const std::string& name) override -> Int virtual
Implementation for object3DForName()
auto doObject3D(UnsignedInt id) override -> std::unique_ptr<ObjectData3D> virtual
Implementation for object3D()
auto doMesh3DCount() const override -> UnsignedInt virtual
Implementation for mesh3DCount()
auto doMesh3DForName(const std::string& name) override -> Int virtual
Implementation for mesh3DForName()
auto doMesh3DName(const UnsignedInt id) override -> std::string virtual
Implementation for mesh3DName()
auto doMesh3D(const UnsignedInt id) override -> Containers::Optional<MeshData3D> virtual
Implementation for mesh3D()
auto doMaterialCount() const override -> UnsignedInt virtual
Implementation for materialCount()
auto doMaterialForName(const std::string& name) override -> Int virtual
Implementation for materialForName()
auto doMaterialName(const UnsignedInt id) override -> std::string virtual
Implementation for materialName()
auto doMaterial(const UnsignedInt id) override -> std::unique_ptr<AbstractMaterialData> virtual
Implementation for material()
auto doTextureCount() const override -> UnsignedInt virtual
Implementation for textureCount()
auto doTexture(const UnsignedInt id) override -> Containers::Optional<TextureData> virtual
Implementation for texture()
auto doImage2DCount() const override -> UnsignedInt virtual
Implementation for image2DCount()
auto doImage2D(const UnsignedInt id) override -> Containers::Optional<ImageData2D> virtual
Implementation for image2D()
void doClose() override virtual
Implementation for close()

Function documentation

void Magnum::Trade::TinyGltfImporter::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::TinyGltfImporter::doCameraCount() const override virtual private

Implementation for cameraCount()

Default implementation returns 0.

UnsignedInt Magnum::Trade::TinyGltfImporter::doLightCount() const override virtual private

Implementation for lightCount()

Default implementation returns 0.

Int Magnum::Trade::TinyGltfImporter::doDefaultScene() override virtual private

Implementation for defaultScene()

Default implementation returns -1.

UnsignedInt Magnum::Trade::TinyGltfImporter::doSceneCount() const override virtual private

Implementation for sceneCount()

Default implementation returns 0.

UnsignedInt Magnum::Trade::TinyGltfImporter::doObject3DCount() const override virtual private

Implementation for object3DCount()

Default implementation returns 0.

std::string Magnum::Trade::TinyGltfImporter::doObject3DName(UnsignedInt id) override virtual private

Implementation for object3DName()

Default implementation returns empty string.

Int Magnum::Trade::TinyGltfImporter::doObject3DForName(const std::string& name) override virtual private

Implementation for object3DForName()

Default implementation returns -1.

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

Implementation for mesh3DCount()

Default implementation returns 0.

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

Implementation for mesh3DForName()

Default implementation returns -1.

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

Implementation for mesh3DName()

Default implementation returns empty string.

UnsignedInt Magnum::Trade::TinyGltfImporter::doMaterialCount() const override virtual private

Implementation for materialCount()

Default implementation returns 0.

Int Magnum::Trade::TinyGltfImporter::doMaterialForName(const std::string& name) override virtual private

Implementation for materialForName()

Default implementation returns -1.

std::string Magnum::Trade::TinyGltfImporter::doMaterialName(const UnsignedInt id) override virtual private

Implementation for materialName()

Default implementation returns empty string.

UnsignedInt Magnum::Trade::TinyGltfImporter::doTextureCount() const override virtual private

Implementation for textureCount()

Default implementation returns 0.

UnsignedInt Magnum::Trade::TinyGltfImporter::doImage2DCount() const override virtual private

Implementation for image2DCount()

Default implementation returns 0.