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
Inherits: Kuesa::KuesaNode

This class was introduced in Kuesa 1.0.

Public Types

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

Properties

  • options : Kuesa::GLTF2Import::GLTF2Options* const
  • source : QUrl
  • status : const Kuesa::GLTF2Importer::Status

Public Functions

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

Public Slots

void reload()
void setActiveSceneIndex(int index)
void setAssignNames(bool assignNames)
void setAsynchronous(bool asynchronous)
void setSource(const QUrl &source)

Signals

void activeSceneIndexChanged(int activeSceneIndex)
void assignNamesChanged(bool assignNames)
void asynchronousChanged(bool asynchronous)
void availableScenesChanged(const QStringList &availableScenes)
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)

asynchronous : bool

if true, parsing is performed in a non blocking manner from a secondary thread. This is false by default.

Access functions:

bool asynchronous() const
void setAsynchronous(bool asynchronous)

Notifier signal:

void asynchronousChanged(bool asynchronous)

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

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::reload()

Reloads the current glTF file.

[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::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().

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.