Vulkan Schnee 0.0.1
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>

Collaboration diagram for Engine::Assets::Loaders::GltfLoader:

Classes

struct  GltfBufferDataView
 View into a glTF accessor's backing buffer data. More...
struct  GltfMaterialData
 Stores the material data which is relevant for our current set of shaders. More...
struct  GltfMeshData
 Mesh data extracted from a glTF mesh node. More...
struct  GltfMeshPrimitiveData
 Stores intermediate data from loading the asset from disk. These are the vertices, indices and material data. 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
 Stores all material extensions. So if another extension for some kind of specific material attribute is needed we can add it here. More...
struct  StaticMeshExtensions
 Parses all extensions and extracts recognized extensions. More...
struct  StaticMeshSettings
 Static mesh settings parsed from legacy glTF extras. More...
struct  VulkanSchneeExtension
 The vulkan schnee extension for gltf files stores all data related to the engines core functionality. More...
struct  VulkanSchneeMaterialExtension
 Extracts all material data from the gltf file. All data during runtime will be read from an object of this type. 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< VertexgetPrimitiveVertices (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 a vector of meshes 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 the GLTF metadata (nodes, names, transforms) without loading buffer data.

Static Public Member Functions

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

Private Attributes

NamedThreadPoolthreadPool = 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 37 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 a vector of meshes from a gltf file.

Parameters
pathWhere to load the asset from (preferably a relative path like: "assets/Engine/geometry/LightDemo/LightDemo.gltf" for engine assets)
meshesThe loaded meshes from the file
Note
Use relative paths or else you will get issues with assets not loading on different systems "assets/Engine/geometry/LightDemo/LightDemo.gltf" engine asset "assets/AirHockey/geometry/.../<asset>.gltf" game asset

◆ loadAnimationData()

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

Load animation data from a glTF model.

Extracts keyframe tracks, maps target nodes to joint indices via the provided SkinAsset, and computes total duration.

Parameters
modelThe loaded glTF model
animIndexIndex into model.animations[]
skinThe SkinAsset to map node indices to joint indices
Returns
Populated AnimationAsset

◆ 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 the GLTF metadata (nodes, names, transforms) without loading buffer data.

This is a fast operation that parses only the JSON structure, skipping all binary buffer loading. Use this when you only need node names and transforms (e.g., for spawning actors before mesh data is fully loaded).

Parameters
pathPath to the GLTF/GLB file
Returns
Parsed model with node metadata (buffers will be 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

Load skin (skeleton) data from a glTF model.

Extracts joint hierarchy, inverse bind matrices, and joint names from the specified glTF skin.

Parameters
modelThe loaded glTF model
skinIndexIndex into model.skins[]
Returns
Populated SkinAsset

Member Data Documentation

◆ threadPool

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

Definition at line 968 of file GltfLoader.h.

Referenced by GltfLoader().


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