diff options
| author | MrScautHD <[email protected]> | 2023-11-18 20:07:30 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-18 20:07:30 +0100 |
| commit | 0137efde7a20903ce50fbd8a796dc92c77cb2c39 (patch) | |
| tree | acd9cc4ab46d4ea79c057a3577a48f5167cc77ce /src | |
| parent | f6de0358e137625e12f60b26c794cc05f09999e4 (diff) | |
| download | raylib-0137efde7a20903ce50fbd8a796dc92c77cb2c39.tar.gz raylib-0137efde7a20903ce50fbd8a796dc92c77cb2c39.zip | |
Expanding Possibilities: Integrating Additional glTF / GLB Data Formats for Enhanced 3D Experiences (#3546)
* Add more gltf data formats
* Fix forgot to save bone ids
* Fix misstake
* Fix code format
* Removed useless formats
Diffstat (limited to 'src')
| -rw-r--r-- | src/rmodels.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/rmodels.c b/src/rmodels.c index 229d373f..c191f0ac 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -5155,16 +5155,29 @@ static Model LoadGLTF(const char *fileName) if ((attribute->component_type == cgltf_component_type_r_8u) && (attribute->type == cgltf_type_vec4)) { - // Init raylib mesh bone ids to copy glTF attribute data + // Handle 8-bit unsigned byte, vec4 format model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(unsigned char)); - - // Load 4 components of unsigned char data type into mesh.boneIds - // for cgltf_attribute_type_joints we have: - // - data.meshes[0] (256 vertices) - // - 256 values, provided as cgltf_type_vec4 of bytes (4 byte per joint, stride 4) LOAD_ATTRIBUTE(attribute, 4, unsigned char, model.meshes[meshIndex].boneIds) } - else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint attribute data format not supported, use vec4 u8", fileName); + else if ((attribute->component_type == cgltf_component_type_r_16u) && (attribute->type == cgltf_type_vec2)) + { + // Handle 16-bit unsigned short, vec2 format + model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*2, sizeof(unsigned short)); + LOAD_ATTRIBUTE(attribute, 2, unsigned short, model.meshes[meshIndex].boneIds) + } + else if ((attribute->component_type == cgltf_component_type_r_32u) && (attribute->type == cgltf_type_vec4)) + { + // Handle 32-bit unsigned int, vec4 format + model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*4, sizeof(unsigned int)); + LOAD_ATTRIBUTE(attribute, 4, unsigned int, model.meshes[meshIndex].boneIds) + } + else if ((attribute->component_type == cgltf_component_type_r_32f) && (attribute->type == cgltf_type_vec2)) + { + // Handle 32-bit float, vec2 format + model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount*2, sizeof(float)); + LOAD_ATTRIBUTE(attribute, 2, float, model.meshes[meshIndex].boneIds) + } + else TRACELOG(LOG_WARNING, "MODEL: [%s] Joint attribute data format not supported", fileName); } else if (data->meshes[i].primitives[p].attributes[j].type == cgltf_attribute_type_weights) // WEIGHTS_n (vec4 / u8, u16, f32) { |
