Class GltfLoader#
Defined in File GltfLoader.ixx
Class Documentation#
-
class GltfLoader#
Loads
.gltf/.glbgeometry into the SAME CPU-side arraysObjLoaderproduces, so it plugs intoModel/Meshand theAsyncModelParseworker unchanged. Touches no Vulkan - that is the point, the parse is the expensive part worth moving off the render thread.Increment b: geometry (positions/normals/UVs, indices, baked node transforms) plus a single neutral material. Per-material import and texture resolution are follow-ups (see BACKLOG glTF increments c/d).
Public Functions
Device-owning:
loadModelcan upload.parseCpualone needs no device, so the default constructor stays available for the CPU-only path.
-
GltfLoader() = default#
-
std::shared_ptr<Model> loadModel(const std::string &modelFile)#
Parses
modelFilethen builds the Vulkan-side Model from it - i.e. parseCpu + uploadParsed. Returns nullptr on a device-free loader or a failed parse.
-
std::shared_ptr<Model> uploadParsed()#
Builds the Vulkan-side Model from the LAST parseCpu result - the GPU half, separated so a device-free worker can parse and a device-owning loader upload (the async split). Must run on the thread owning the device; returns nullptr on a device-free loader or before a successful parse. Mirrors ObjLoader so AsyncModelParse can drive glTF the same way.
-
void adoptParsed(GltfLoader &&other)#
Moves another loader’s parse results in, so a device-owning loader can upload what a device-free worker produced without copying the arrays.
-
bool parseCpu(const std::string &modelFile)#
Parses the document into vertices/indices/materials/materialIndex. Returns false on a missing or malformed file, leaving the instance empty.
-
inline const std::vector<Vertex> &getVertices() const#
-
inline const std::vector<unsigned int> &getIndices() const#
-
inline const std::vector<ObjMaterial> &getMaterials() const#
-
inline const std::vector<unsigned int> &getMaterialIndices() const#
-
inline const std::vector<std::vector<unsigned char>> &getTextureImages() const#
Encoded base-colour image bytes (PNG/JPG…), one entry per distinct image; materials sharing an image share a slot, indexed by that material’s textureID. loadModel decodes and uploads them via Texture::createFromMemory; a test can assert the CPU extraction without a device.
-
inline const std::vector<GltfSamplerDesc> &getTextureSamplerDescs() const#
The glTF sampler (wrap modes + filters) each entry of getTextureImages() was authored with, index-parallel with it. Two textures sharing one image but naming different samplers get distinct slots (see parseCpu’s dedup key), so this stays index-parallel rather than needing its own lookup.
-
inline const std::vector<unsigned char> &getTextureSrgbFlags() const#
Colour space each entry of getTextureImages() was authored in, index-parallel with it: 1 for sRGB (base colour, emissive), 0 for linear (normal maps).
unsigned char, notstd::vector<bool>- the proxy reference is a trap in a parallel-array getter. An image used as both base colour and normal map gets two slots, one per colour space, since a slot can only carry one image format.