Skip to content

Kuesa::Qt3D::GLTF2Importer

Module: Kuesa Qt 3D API

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

#include <Kuesa/Qt3D/api/gltf2importer/gltf2importer.h>

Inherits from Kuesa::Qt3D::KuesaNode, Qt3DCore::QNode

Public Types

Name
enum Status { None, Loading, Ready, Error}
enum ActiveScene { DefaultScene = -2, EmptyScene = -1}

Public Slots

Name
void setSource(const QUrl & source)
void setAssignNames(bool assignNames)
void setOptions(const Kuesa::Qt3D::GLTF2Options & options)
void setActiveSceneIndex(int index)
void setAsynchronous(bool asynchronous)
void reload()

Public Signals

Name
void sourceChanged(const QUrl & source)
void statusChanged(const Kuesa::Qt3D::GLTF2Importer::Status status)
void assignNamesChanged(bool assignNames)
void activeSceneIndexChanged(int activeSceneIndex)
void availableScenesChanged(const QStringList & availableScenes)
void asynchronousChanged(bool asynchronous)

Public Functions

Name
GLTF2Importer(Qt3DCore::QNode * parent =nullptr)
~GLTF2Importer()
QUrl source() const
GLTF2Importer::Status status() const
bool assignNames() const
bool asynchronous() const
Kuesa::Qt3D::GLTF2Options * options()
const Kuesa::Qt3D::GLTF2Options * options() const
int activeSceneIndex() const
QStringList availableScenes() const
Kuesa::GLTF2Import::GLTF2Context * context() const

Public Properties

Name
QUrl source
the source of the glTF file
Kuesa::Qt3D::GLTF2Importer::Status status
the current status of the importer
bool assignNames
if true, assets with no names will be added to collections with default names (default is false)
Kuesa::Qt3D::GLTF2Options * options
Holds the Kuesa::Qt3D::GLTF2Import::GLTF2Options used to select what to import/generate.
int activeSceneIndex
Specifies which glTF scene should be loaded. Defaults to index GLTF2Importer::DefaultScene.
QStringList availableScenes
Holds the names of the available glTF scenes.
bool asynchronous
if true, parsing is performed in a non blocking manner from a secondary thread. This is false by default.

Friends

Name
class GLTF2Exporter

Additional inherited members

Public Slots inherited from Kuesa::Qt3D::KuesaNode

Name
void setSceneEntity(Kuesa::Qt3D::SceneEntity * sceneEntity)

Public Signals inherited from Kuesa::Qt3D::KuesaNode

Name
void sceneEntityChanged(Kuesa::Qt3D::SceneEntity * sceneEntity)

Public Functions inherited from Kuesa::Qt3D::KuesaNode

Name
KuesaNode(Qt3DCore::QNode * parent =nullptr)
SceneEntity * sceneEntity() const

Public Properties inherited from Kuesa::Qt3D::KuesaNode

Name
Kuesa::Qt3D::SceneEntity * sceneEntity

Protected Attributes inherited from Kuesa::Qt3D::KuesaNode

Name
SceneEntity * m_sceneEntity

Detailed Description

1
class Kuesa::Qt3D::GLTF2Importer;

Imports glTF 2 scenes into a Qt 3D Scene.

Since: Kuesa 2.0

\inherits{KuesaNode} GLTF2Importer imports glTF 2 scenes into a Qt 3D scene.

1
2
3
4
5
6
7
#include <GLTF2Importer>

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

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

If a Kuesa::Qt3D::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:

  • Materials
  • Meshes
  • Armatures
  • Skeletons
  • Cameras
  • Entities
  • Textures
  • TextureImages
  • AnimationClips
  • AnimationMappings

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:

  • a material that doesn't perform skinning for use with regular meshes. It will be added to the collection with the name "Mat"
  • a material that does perform skinning for use with skinned meshes. It will be added to the collection with the name "skinned_Mat"

Public Types Documentation

enum Status

Enumerator Value Description
None
Loading
Ready
Error

enum ActiveScene

Enumerator Value Description
DefaultScene -2
EmptyScene -1
  • DefaultScene Makes 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
  • EmptyScene Tell the importer to not load any scene by default

Public Slots Documentation

slot setSource

1
2
3
void setSource(
    const QUrl & source
)

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

Load the glTF file from the given url source.

slot setAssignNames

1
2
3
void 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.

slot setOptions

1
2
3
void setOptions(
    const Kuesa::Qt3D::GLTF2Options & options
)

slot setActiveSceneIndex

1
2
3
void setActiveSceneIndex(
    int index
)

slot setAsynchronous

1
2
3
void setAsynchronous(
    bool asynchronous
)

slot reload

1
void reload()

Reloads the current glTF file.

Public Signals Documentation

signal sourceChanged

1
2
3
void sourceChanged(
    const QUrl & source
)

signal statusChanged

1
2
3
void statusChanged(
    const Kuesa::Qt3D::GLTF2Importer::Status status
)

signal assignNamesChanged

1
2
3
void assignNamesChanged(
    bool assignNames
)

signal activeSceneIndexChanged

1
2
3
void activeSceneIndexChanged(
    int activeSceneIndex
)

signal availableScenesChanged

1
2
3
void availableScenesChanged(
    const QStringList & availableScenes
)

signal asynchronousChanged

1
2
3
void asynchronousChanged(
    bool asynchronous
)

Public Functions Documentation

function GLTF2Importer

1
2
3
GLTF2Importer(
    Qt3DCore::QNode * parent =nullptr
)

function ~GLTF2Importer

1
~GLTF2Importer()

function source

1
QUrl source() const

Returns the url of the glTF file

function status

1
GLTF2Importer::Status status() const

Return the current state of the importer

function assignNames

1
bool assignNames() const

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

function asynchronous

1
bool asynchronous() const

function options

1
Kuesa::Qt3D::GLTF2Options * options()

function options

1
const Kuesa::Qt3D::GLTF2Options * options() const

function activeSceneIndex

1
int activeSceneIndex() const

function availableScenes

1
QStringList availableScenes() const

function context

1
Kuesa::GLTF2Import::GLTF2Context * context() const

Public Property Documentation

property source

1
QUrl source;

the source of the glTF file

property status

1
Kuesa::Qt3D::GLTF2Importer::Status status;

the current status of the importer

See: Kuesa::Qt3D::GLTF2Importer::Status

property assignNames

1
bool assignNames;

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

property options

1
Kuesa::Qt3D::GLTF2Options * options;

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

property activeSceneIndex

1
int activeSceneIndex;

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

property availableScenes

1
QStringList availableScenes;

Holds the names of the available glTF scenes.

property asynchronous

1
bool asynchronous;

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

Friends

friend GLTF2Exporter

1
2
3
friend class GLTF2Exporter(
    GLTF2Exporter 
);

Updated on 2023-07-03 at 11:02:12 +0000