loader_aw

Load OBJ/MTL file formats
git clone git://git.meso-star.fr/loader_aw.git
Log | Files | Refs | README | LICENSE

commit 2933f8aacae2b40fcda89f85a76e6deb69679e66
parent c74809ebb3170e33b8798bffbf8dbe40e21d295e
Author: vaplv <vaplv@free.fr>
Date:   Tue, 11 Apr 2023 14:37:52 +0200

Update the aw_obj_desc data structure

Add the number of positions, texcoords and normals as new member
variables of the structure. Update the obj load test to check that
these variables are correctly defined.

Diffstat:
Msrc/aw.h | 3+++
Msrc/aw_obj.c | 3+++
Msrc/test_aw_obj.c | 12++++++++++++
3 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/aw.h b/src/aw.h @@ -58,6 +58,9 @@ enum aw_map_channel { struct aw_obj_desc { size_t faces_count; + size_t positions_count; + size_t normals_count; + size_t texcoords_count; size_t groups_count; size_t smooth_groups_count; size_t usemtls_count; diff --git a/src/aw_obj.c b/src/aw_obj.c @@ -816,6 +816,9 @@ aw_obj_get_desc(const struct aw_obj* obj, struct aw_obj_desc* desc) if(!obj || !desc) return RES_BAD_ARG; desc->faces_count = darray_face_size_get(&obj->faces); + desc->positions_count = darray_double_size_get(&obj->positions) / 4; + desc->normals_count = darray_double_size_get(&obj->normals) / 3; + desc->texcoords_count = darray_double_size_get(&obj->texcoords) / 3; desc->groups_count = darray_named_group_size_get(&obj->groups); desc->smooth_groups_count = darray_smooth_group_size_get(&obj->smooth_groups); desc->usemtls_count = darray_named_group_size_get(&obj->usemtls); diff --git a/src/test_aw_obj.c b/src/test_aw_obj.c @@ -70,6 +70,9 @@ test_plane(struct aw_obj* obj) CHK(aw_obj_get_desc(NULL, &desc) == RES_BAD_ARG); CHK(aw_obj_get_desc(obj, &desc) == RES_OK); CHK(desc.faces_count == 1); + CHK(desc.positions_count == 4); + CHK(desc.texcoords_count == 4); + CHK(desc.normals_count == 0); CHK(desc.groups_count == 1); CHK(desc.smooth_groups_count == 0); CHK(desc.usemtls_count == 1); @@ -190,6 +193,9 @@ test_squares(struct aw_obj* obj) CHK(aw_obj_get_desc(obj, &desc) == RES_OK); CHK(desc.faces_count == 2); + CHK(desc.positions_count == 6); + CHK(desc.texcoords_count == 0); + CHK(desc.normals_count == 6); CHK(desc.groups_count == 1); CHK(desc.smooth_groups_count == 1); CHK(desc.usemtls_count == 0); @@ -319,6 +325,9 @@ test_cube(struct aw_obj* obj) CHK(aw_obj_get_desc(obj, &desc) == RES_OK); CHK(desc.faces_count == 6); + CHK(desc.positions_count == 8); + CHK(desc.texcoords_count == 0); + CHK(desc.normals_count == 0); CHK(desc.groups_count == 6); CHK(desc.smooth_groups_count == 0); CHK(desc.usemtls_count == 6); @@ -447,6 +456,9 @@ test_cbox(struct aw_obj* obj) CHK(aw_obj_get_desc(obj, &desc) == RES_OK); CHK(desc.faces_count == 5); + CHK(desc.positions_count == 20); + CHK(desc.texcoords_count == 0); + CHK(desc.normals_count == 0); CHK(desc.groups_count == 5); CHK(desc.smooth_groups_count == 0); CHK(desc.usemtls_count == 5);