VkCV Framework
0.0.1
CV Vulkan framework
|
Classes | |
struct | Material |
struct | Mesh |
struct | Sampler |
struct | Scene |
struct | Texture |
struct | TextureData |
struct | VertexAttribute |
struct | VertexGroup |
Enumerations | |
enum | PrimitiveMode : uint8_t { POINTS =0, LINES, LINELOOP, LINESTRIP, TRIANGLES, TRIANGLESTRIP, TRIANGLEFAN } |
enum | IndexType : uint8_t { UNDEFINED =0, UINT8 =1, UINT16 =2, UINT32 =3 } |
enum | PBRTextureTarget { baseColor =1, metalRough =2, normal =4, occlusion =8, emissive =16 } |
enum | PrimitiveType : uint32_t { UNDEFINED = 0, POSITION = 1, NORMAL = 2, TEXCOORD_0 = 3, TEXCOORD_1 = 4, TANGENT = 5 } |
enum | ComponentType : uint16_t { NONE = 0, INT8 = 5120, UINT8 = 5121, INT16 = 5122, UINT16 = 5123, UINT32 = 5125, FLOAT32 = 5126 } |
Functions | |
bool | materialHasTexture (const Material *const m, const PBRTextureTarget t) |
int | loadScene (const std::string &path, Scene &scene) |
TextureData | loadTexture (const std::filesystem::path &path) |
uint8_t | convertTypeToInt (const fx::gltf::Accessor::Type type) |
void | print_what (const std::exception &e, const std::string &path) |
enum IndexType | getIndexType (const enum fx::gltf::Accessor::ComponentType &t) |
std::array< float, 16 > | computeModelMatrix (std::array< float, 3 > translation, std::array< float, 3 > scale, std::array< float, 4 > rotation, std::array< float, 16 > matrix) |
LOADING MESHES The description of meshes is a hierarchy of structures with the Mesh at the top.
Each Mesh has an array of one or more vertex groups (called "primitives" in glTF parlance). Specifically, it has an array of indices into an array of vertex groups defined by the Scene struct.
Each vertex group describes a part of the meshes vertices by defining how they should be rendered (as points, lines, triangles), how many indices and vertices there are, how the content of the vertex buffer is to be interpreted and which material from the Scenes materials array should be used for the surface of the vertices. As a bonus there is also the axis aligned bounding box of the vertices.
The vertex buffer is presented as a single block of binary data with a given length in bytes. The layout of the vertex buffer is described by an array of VertexAttribute structs that define the type of attribute, the offset, length and stride in bytes and number and type of components of the attribute. These values can directly be given to vulkan when describing the content of vertex buffers.
|
strong |
These integer values are used the same way in OpenGL, Vulkan and glTF. This enum is not needed for translation, it's only for the programmers convenience (easier to read in if/switch statements etc). While this enum exists in (almost) the same definition in the fx-gltf library, we want to avoid exposing that dependency, thus it is re-defined here.
|
strong |
The indices in the index buffer can be of different bit width.
|
strong |
Flags for the bit-mask in the Material struct. To check if a material has a certain texture target, you can use the hasTexture() function below, passing the material struct and the enum.
|
strong |
This enum matches modes in fx-gltf, the library returns a standard mode (TRIANGLES) if no mode is given in the file.
|
strong |
With these enums, 0 is reserved to signal uninitialized or invalid data.
std::array<float, 16> vkcv::asset::computeModelMatrix | ( | std::array< float, 3 > | translation, |
std::array< float, 3 > | scale, | ||
std::array< float, 4 > | rotation, | ||
std::array< float, 16 > | matrix | ||
) |
This function computes the modelMatrix out of the data given in the gltf file. It also checks, whether a modelMatrix was given.
translation | possible translation vector (default 0,0,0) |
scale | possible scale vector (default 1,1,1) |
rotation | possible rotation, given in quaternion (default 0,0,0,1) |
matrix | possible modelmatrix (default identity) |
uint8_t vkcv::asset::convertTypeToInt | ( | const fx::gltf::Accessor::Type | type | ) |
convert the accessor type from the fx-gltf library to an unsigned int
type |
enum IndexType vkcv::asset::getIndexType | ( | const enum fx::gltf::Accessor::ComponentType & | t | ) |
Translate the component type used in the index accessor of fx-gltf to our enum for index type. The reason we have defined an incompatible enum that needs translation is that only a subset of component types is valid for indices and we want to catch these incompatibilities here.
int vkcv::asset::loadScene | ( | const std::string & | path, |
Scene & | scene | ||
) |
Load every mesh from the glTF file, as well as materials and textures.
path | must be the path to a glTF or glb file. |
scene | is a reference to a Scene struct that will be filled with the content of the glTF file being loaded. |
References print_what().
bool vkcv::asset::materialHasTexture | ( | const Material *const | m, |
const PBRTextureTarget | t | ||
) |
void vkcv::asset::print_what | ( | const std::exception & | e, |
const std::string & | path | ||
) |
This function unrolls nested exceptions via recursion and prints them
e | error code |
path | path to file that is responsible for error |
Referenced by loadScene().