Kuesa Runtime

GLTF2Importer Class

class Kuesa::GLTF2Importer

Imports glTF 2 scenes into a Qt 3D Scene. More...

Header: #include <Kuesa/GLTF2Importer>
Since: Kuesa 1.0
Instantiated By: GLTF2Importer

This class was introduced in Kuesa 1.0.

Public Types

enum ActiveScene { DefaultScene, EmptyScene }
enum Status { None, Loading, Ready, Error }

Properties

Public Functions

int activeSceneIndex() const
bool assignNames() const
QStringList availableScenes() const
Kuesa::GLTF2Import::GLTF2Options *options()
const Kuesa::GLTF2Import::GLTF2Options *options() const
Kuesa::SceneEntity *sceneEntity() const
QUrl source() const
GLTF2Importer::Status status() const

Public Slots

void setActiveSceneIndex(int index)
void setAssignNames(bool assignNames)
void setSceneEntity(Kuesa::SceneEntity *sceneEntity)
void setSource(const QUrl &source)

Signals

void activeSceneIndexChanged(int activeSceneIndex)
void assignNamesChanged(bool assignNames)
void availableScenesChanged(const QStringList &availableScenes)
void sceneEntityChanged(Kuesa::SceneEntity *sceneEntity)
void sourceChanged(const QUrl &source)
void statusChanged(const Kuesa::GLTF2Importer::Status status)

Detailed Description

GLTF2Importer imports glTF 2 scenes into a Qt 3D scene.

 #include <GLTF2Importer>

 Kuesa::SceneEntity *scene = new Kuesa::SceneEntity();
 Kuesa::GLTF2Importer *importer = new Kuesa::GLTF2Importer(scene);

 importer->setSceneEntity(scene);
 importer->setSource(QUrl("file:///source.gltf"));

If a Kuesa::SceneEntity has been set on the importer, various Qt 3D resources generated upon import will be registered into named collections. If no name is specified and assignNames is true, a default name will be assigned to the asset. If several assets of the same type share the same name, subsequent assets will be given unique names by appending an index.

Below is a list of Qt 3D resources currently registered into collections:

As far as glTF is concerned, a material could be used for skinned as well as regular meshes. This doesn't match with how Qt 3D works. If a material named "Mat" is used for both skinned and regular meshes, the importer will register two materials:

Member Type Documentation

enum GLTF2Importer::ActiveScene

ConstantValueDescription
Kuesa::GLTF2Importer::DefaultScene-2Makes the importer load the glTF scene specified as being the default one in the glTF file. If the glTF file doesn't specify anything, nothing will be loaded
Kuesa::GLTF2Importer::EmptyScene-1Tell the importer to not load any scene by default

enum GLTF2Importer::Status

This enum type describes state of the importer.

ConstantValueDescription
Kuesa::GLTF2Importer::None0Unknown state (default).
Kuesa::GLTF2Importer::Loading1Importer is currently loading a file.
Kuesa::GLTF2Importer::Ready2A glTF file was successfully loaded.
Kuesa::GLTF2Importer::Error3An error occurred when loading the current glTF file.

Property Documentation

activeSceneIndex : int

Specifies which glTF scene should be loaded. Defaults to index GLTF2Importer::DefaultScene.

Access functions:

int activeSceneIndex() const
void setActiveSceneIndex(int index)

Notifier signal:

void activeSceneIndexChanged(int activeSceneIndex)

assignNames : bool

if true, assets with no names will be added to collections with default names (default is false)

Access functions:

bool assignNames() const
void setAssignNames(bool assignNames)

Notifier signal:

void assignNamesChanged(bool assignNames)

availableScenes : const QStringList

Holds the names of the available glTF scenes.

Access functions:

QStringList availableScenes() const

Notifier signal:

void availableScenesChanged(const QStringList &availableScenes)

options : Kuesa::GLTF2Import::GLTF2Options* const

Holds the Kuesa::GLTF2Import::GLTF2Options used to select what to import/generate

Access functions:

Kuesa::GLTF2Import::GLTF2Options *options()
const Kuesa::GLTF2Import::GLTF2Options *options() const

sceneEntity : Kuesa::SceneEntity*

pointer to the SceneEntity with which assets will be registered as they are loaded from the glTF file.

Access functions:

Kuesa::SceneEntity *sceneEntity() const
void setSceneEntity(Kuesa::SceneEntity *sceneEntity)

Notifier signal:

void sceneEntityChanged(Kuesa::SceneEntity *sceneEntity)

source : QUrl

This property holds the source of the glTF file

Access functions:

QUrl source() const
void setSource(const QUrl &source)

Notifier signal:

void sourceChanged(const QUrl &source)

status : const Kuesa::GLTF2Importer::Status

This property holds the current status of the importer

Access functions:

GLTF2Importer::Status status() const

Notifier signal:

void statusChanged(const Kuesa::GLTF2Importer::Status status)

See also Kuesa::GLTF2Importer::Status.

Member Function Documentation

[slot] void GLTF2Importer::setAssignNames(bool assignNames)

If assignNames is true, assets with no names will be added to collections with default names.

Otherwise, assets will not be added to collections.

Note: Setter function for property assignNames.

See also assignNames().

[slot] void GLTF2Importer::setSceneEntity(Kuesa::SceneEntity *sceneEntity)

Set the SceneEntity instance which should be used to access the collections loaded assets will be registered with to sceneEntity.

Note: Setter function for property sceneEntity.

See also sceneEntity().

[slot] void GLTF2Importer::setSource(const QUrl &source)

Load the glTF file from the given url source.

Note: The loading is asynchronous. When loading is complete the status property will change.

Note: Setter function for property source.

See also source().

bool GLTF2Importer::assignNames() const

Returns true if assets with no names should be added to collections

Note: Getter function for property assignNames.

See also setAssignNames().

Kuesa::SceneEntity *GLTF2Importer::sceneEntity() const

Returns the SceneEntity used to access asset collections

Note: Getter function for property sceneEntity.

See also setSceneEntity().

QUrl GLTF2Importer::source() const

Returns the url of the glTF file

Note: Getter function for property source.

See also setSource().

GLTF2Importer::Status GLTF2Importer::status() const

Return the current state of the importer

Note: Getter function for property status.