Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Assets::Loaders::GltfLoader Class Reference

Loads glTF files and converts tinygltf data into engine asset data. More...

#include <GltfLoader.h>

Classes

struct  GltfBufferDataView
 View into a glTF accessor's backing buffer data. More...
struct  GltfMaterialData
 Material data extracted from a glTF material and engine extensions. More...
struct  GltfMeshData
 Mesh data extracted from a glTF mesh node. More...
struct  GltfMeshPrimitiveData
 Geometry, material, and optional skinning data parsed from one glTF primitive. More...
struct  GltfTextureData
 Optional image payload extracted from tinygltf. More...
struct  GltfVertexData
 Resolved vertex attribute and index views for a glTF primitive. More...
struct  MaterialExtensions
 Parsed material extension bundle for one glTF material. More...
struct  StaticMeshExtensions
 Parsed extension bundle for one mesh or node. More...
struct  StaticMeshSettings
 Static mesh settings parsed from legacy glTF extras. More...
struct  VulkanSchneeExtension
 Parsed VULKAN_SCHNEE_engine_properties extension data. More...
struct  VulkanSchneeMaterialExtension
 Parsed VULKAN_SCHNEE_materials material extension data. More...

Public Member Functions

 GltfLoader (NamedThreadPool *threadPool=nullptr)
 Creates a loader that can use an optional thread pool for deferred work.
 ~GltfLoader ()
 Waits for queued work on the supplied thread pool before destruction.
std::vector< Vertex > getPrimitiveVertices (const tinygltf::Primitive &primitive)
 Legacy primitive vertex extraction entry point.
Ecs::PrimitiveData loadPrimitiveData (GltfVertexData vertexData)
 Converts resolved glTF vertex and index views into engine primitive data.
void load (const std::filesystem::path &path, std::vector< GltfMeshData > &meshes) const
 Loads mesh nodes from a glTF file.
std::optional< tinygltf::Model > loadModel (const std::filesystem::path &path) const
 Loads a full ASCII glTF model through tinygltf.
tinygltf::Model loadAsync (const std::filesystem::path &path) const
 Loads a glTF model while skipping image payload loading.
tinygltf::Model loadMetadataOnly (const std::filesystem::path &path) const
 Loads only glTF metadata without loading buffer data.

Static Public Member Functions

static Assets::Skin loadSkinData (const tinygltf::Model &model, int skinIndex)
 Loads skin data from a glTF model.
static Animation loadAnimationData (const tinygltf::Model &model, int animIndex, const Assets::Skin &skin)
 Loads animation data from a glTF model.

Private Attributes

NamedThreadPool * threadPool = nullptr

Detailed Description

Loads glTF files and converts tinygltf data into engine asset data.

GltfLoader parses mesh primitives, material metadata, engine-specific glTF extensions, skins, animations, and lightweight metadata. Texture pixel data is handed off to the texture asset pipeline instead of being owned by the loader.

Definition at line 38 of file GltfLoader.h.

Constructor & Destructor Documentation

◆ GltfLoader()

Engine::Assets::Loaders::GltfLoader::GltfLoader ( NamedThreadPool * threadPool = nullptr)

Creates a loader that can use an optional thread pool for deferred work.

Parameters
threadPoolOptional named thread pool. The loader does not own this pointer.

References threadPool.

◆ ~GltfLoader()

Engine::Assets::Loaders::GltfLoader::~GltfLoader ( )

Waits for queued work on the supplied thread pool before destruction.

Member Function Documentation

◆ getPrimitiveVertices()

std::vector< Vertex > Engine::Assets::Loaders::GltfLoader::getPrimitiveVertices ( const tinygltf::Primitive & primitive)

Legacy primitive vertex extraction entry point.

Parameters
primitiveglTF primitive to read.
Returns
Primitive vertices.
Exceptions
std::logic_errorThis method is not implemented.

◆ load()

void Engine::Assets::Loaders::GltfLoader::load ( const std::filesystem::path & path,
std::vector< GltfMeshData > & meshes ) const

Loads mesh nodes from a glTF file.

Nodes without meshes are skipped. Parsed mesh data is appended to meshes.

Parameters
pathPath to the glTF file. Prefer engine-relative asset paths for runtime assets.
meshesOutput vector that receives parsed mesh data.
Exceptions
std::runtime_errorWhen loadModel() fails to parse the file.

◆ loadAnimationData()

Animation Engine::Assets::Loaders::GltfLoader::loadAnimationData ( const tinygltf::Model & model,
int animIndex,
const Assets::Skin & skin )
static

Loads animation data from a glTF model.

Extracts translation, rotation, and scale keyframe tracks, maps target nodes to joint indices through the provided skin, and computes total duration.

Parameters
modelLoaded glTF model.
animIndexIndex into model.animations.
skinSkin asset used to map glTF node indices to joint indices.
Returns
Populated animation asset. Returns an empty animation when animIndex is invalid.

◆ loadAsync()

tinygltf::Model Engine::Assets::Loaders::GltfLoader::loadAsync ( const std::filesystem::path & path) const

Loads a glTF model while skipping image payload loading.

This parses JSON, buffers, images metadata, extras, and extensions, but leaves image bytes unloaded for deferred texture processing.

Parameters
pathPath to the glTF file.
Returns
Loaded tinygltf model with image payloads skipped.

◆ loadMetadataOnly()

tinygltf::Model Engine::Assets::Loaders::GltfLoader::loadMetadataOnly ( const std::filesystem::path & path) const

Loads only glTF metadata without loading buffer data.

Parses nodes, names, transforms, and extensions. Use this for actor spawning and metadata inspection before full mesh data is loaded.

Parameters
pathPath to the glTF or GLB file.
Returns
Parsed model with metadata only. Buffers are empty.

◆ loadModel()

std::optional< tinygltf::Model > Engine::Assets::Loaders::GltfLoader::loadModel ( const std::filesystem::path & path) const

Loads a full ASCII glTF model through tinygltf.

KTX and KTX2 image payloads are skipped because the engine loads them through Ktx2Loader. Other image formats use tinygltf's default image loader.

Parameters
pathPath to the glTF file.
Returns
Loaded tinygltf model.
Exceptions
std::runtime_errorWhen tinygltf fails to load the file.

◆ loadPrimitiveData()

Ecs::PrimitiveData Engine::Assets::Loaders::GltfLoader::loadPrimitiveData ( GltfVertexData vertexData)

Converts resolved glTF vertex and index views into engine primitive data.

Parameters
vertexDataResolved primitive attributes and index data.
Returns
Engine primitive data with vertices, local indices, and optional bone weights.

◆ loadSkinData()

Assets::Skin Engine::Assets::Loaders::GltfLoader::loadSkinData ( const tinygltf::Model & model,
int skinIndex )
static

Loads skin data from a glTF model.

Extracts joint hierarchy, inverse bind matrices, rest-pose transforms, and joint names from the specified glTF skin.

Parameters
modelLoaded glTF model.
skinIndexIndex into model.skins.
Returns
Populated skin asset. Returns an empty skin when skinIndex is invalid.

Member Data Documentation

◆ threadPool

NamedThreadPool* Engine::Assets::Loaders::GltfLoader::threadPool = nullptr
private

Definition at line 1296 of file GltfLoader.h.

Referenced by GltfLoader().


The documentation for this class was generated from the following file:
  • /workspace/magerbeton/gl3-vulkan/code/Engine/include/Engine/Mesh/GltfLoader.h