From cfe370e8d961506ad1a17ea545cd525d56bf77b0 Mon Sep 17 00:00:00 2001 From: Trevor Hollmann <thollmann@uni-koblenz.de> Date: Tue, 3 Aug 2021 08:24:39 +0200 Subject: [PATCH] [#79] Update documentation of asset loader. --- .../include/vkcv/asset/asset_loader.hpp | 17 ++++++++++------- .../src/vkcv/asset/asset_loader.cpp | 11 ++++++++++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/modules/asset_loader/include/vkcv/asset/asset_loader.hpp b/modules/asset_loader/include/vkcv/asset/asset_loader.hpp index 16cb5baf..2b14ccc0 100644 --- a/modules/asset_loader/include/vkcv/asset/asset_loader.hpp +++ b/modules/asset_loader/include/vkcv/asset/asset_loader.hpp @@ -84,20 +84,23 @@ struct Sampler { }; /** - * This struct describes a loaded texture. - * Note that textures are currently always loaded with 4 channels as RGBA, even - * if the image has just RGB or is grayscale. + * This struct describes a (partially) loaded texture. + * The data member is not populated after calling probeScene() but only when + * calling loadMesh(), loadScene() or loadTexture(). Note that textures are + * currently always loaded with 4 channels as RGBA, even if the image has just + * RGB or is grayscale. In the case where the glTF-file does not provide a URI + * but references a buffer view for the raw data, the path member will be empty + * even though the rest is initialized properly. */ struct Texture { - std::filesystem::path path; // file path of the encoded texture data - int sampler; // index into the sampler array of the Scene + std::filesystem::path path; // URI to the encoded texture data + int sampler; // index into the sampler array of the Scene union { int width; int w; }; union { int height; int h; }; int channels; - // binary data of the decoded texture - std::vector<char*> data; + std::vector<char*> data; // binary data of the decoded texture }; /** diff --git a/modules/asset_loader/src/vkcv/asset/asset_loader.cpp b/modules/asset_loader/src/vkcv/asset/asset_loader.cpp index 3e7207e4..56ae8f5c 100644 --- a/modules/asset_loader/src/vkcv/asset/asset_loader.cpp +++ b/modules/asset_loader/src/vkcv/asset/asset_loader.cpp @@ -453,7 +453,10 @@ namespace vkcv::asset { } /** - * TODO document + * Returns an integer with specific bits set corresponding to the + * textures that appear in the given material. This mask is used in the + * vkcv::asset::Material struct and can be tested via the hasTexture + * method. */ static uint16_t generateTextureMask(fx::gltf::Material &material) { uint16_t textureMask = 0; @@ -621,6 +624,12 @@ namespace vkcv::asset { return ASSET_SUCCESS; } + /** + * Loads and decodes the textures data based on the textures file path. + * The path member is the only one that has to be initialized before + * calling this function, the others (width, height, channels, data) + * are set by this function and the sampler is of no concern here. + */ static int loadTextureData(Texture& texture) { if ((texture.width > 0) && (texture.height > 0) && (texture.channels > 0) && (!texture.data.empty())) { -- GitLab