gltf_importer.h
| File Path | engine/include/conjure/renderer/gltf_importer.h |
| API ↗ | Rendering, Renderer assets |
glTF 2.0 import: .gltf / .glb -> CPU meshes, materials, textures and a model node tree. cgltf does the parsing in engine/src; this header carries only engine types. Unsupported features (skins, animations, KHR_texture_transform, unknown extensions) are warnings, and so is a normal-mapped mesh imported with generateTangents off; parse errors, missing buffers, non-triangle topology and unsupported accessor layouts are failures.
Structs
| File | Description |
|---|---|
gltf_import_options |
generateTangents decides how a primitive gets its tangents when the file does not give them: true builds them from the TEXCOORD_0 derivatives (tangent_generation::FROM_UVS), false from the normal alone (FROM_NORMAL), which is only right where no normal map is drawn. A mesh whose primitives all have a TANGENT (an element per vertex) keeps them under either value. In a mesh where only some primitives have one, false keeps those and builds the others from the normal, while true generates every tangent of the mesh from the UVs. One exception: in a mesh where some primitive lacks NORMAL the normals of all primitives are generated, and if only some of its primitives have a TANGENT, none of those is kept under either value. With false, a mesh gets one import warning when a lit material with a normal texture is drawn by a primitive whose tangents were built from the normal: the materials the file gives the mesh are looked at (a primitive after the first MAX_MATERIAL_SLOTS draws with the material of the last slot), a material assigned to the mesh after the import is not. With true nothing is reported, also not for a mesh without TEXCOORD_0, whose generated tangents come from the normal alone too. scale multiplies the translation and the scale of the root nodes. importCameras and importLights put glTF cameras and KHR_lights_punctual lights on the model's nodes. |
gltf_import_result |
Classes
| File | Description |
|---|---|
gltf_asset_importer |
The assets-module adapter: the primary asset is the model (conjure.renderer.model); meshes, materials and textures are sub-assets ("mesh/<index>", "material/<index>", "texture/<index>") with stable uuids. Settings mirror gltf_import_options as { "generateTangents": true, "scale": 1.0, "importCameras": false, "importLights": true }. The importer's warnings become the import's warnings. |
gltf_importer |
Type Aliases
gltf_file_reader
using gltf_file_reader = std::function<core::result<std::vector<std::byte>>(std::string_view relativePath)>;
Reads a file next to the glTF (external buffers and images) by its relative URI.
material_texture_indices
How a material of the result references the result's textures: an index into gltf_import_result::textures per slot, or INVALID_INDEX.
Constants
| Name | Type | Value | Description |
|---|---|---|---|
GLTF_EXTENSIONS |
inline constexpr std:: |
{".gltf", ".glb"} |
|
GLTF_IMPORTER_ID |
inline constexpr std:: |
"conjure.renderer.gltf" |
|
GLTF_IMPORTER_VERSION |
inline constexpr u32 |
3 |
Bumped whenever the importer's output changes for some input: a cached import made by another version is stale. 2: a light without a range gets one from its intensity. 3: generateTangents = false builds tangents from the normal alone, and with it a primitive keeps its TANGENT when other primitives of its mesh have none (sweep-2026-11-12). |
GLTF_LIGHT_RANGE_CUTOFF |
inline constexpr f32 |
0.01f |
A point or spot light without a glTF range gets the distance at which its inverse-square falloff, intensity / d^2, drops to GLTF_LIGHT_RANGE_CUTOFF lux: sqrt(intensity / GLTF_LIGHT_RANGE_CUTOFF) metres (about 32 m for 10 cd), clamped to [GLTF_MIN_LIGHT_RANGE, GLTF_MAX_LIGHT_RANGE] because the range is also the light's shadow far plane and bounds its light-culling tiles. Fixed at import. |
GLTF_MAX_LIGHT_RANGE |
inline constexpr f32 |
100.0f |
|
GLTF_MIN_LIGHT_RANGE |
inline constexpr f32 |
0.1f |
Functions
Public
gltf_import_options_from_json
gltf_import_options_from_json[[nodiscard]] CONJURE_API core::result<gltf_import_options> gltf_import_options_from_json(
const core::json::value &source);Reads the options object; missing keys keep their defaults. Fails with INVALID_ARGUMENT for a non-object or a wrong member type.
gltf_import_options_to_document
gltf_import_options_to_document[[nodiscard]] CONJURE_API core::json::document gltf_import_options_to_document(
const gltf_import_options &options);Writes the options object with sorted keys.