33 lines
1.1 KiB
C
33 lines
1.1 KiB
C
/*#include <gear/graphics/models.h>
|
|
#include <gear/graphics/color.h>
|
|
#include <fast_obj/fast_obj.h>
|
|
|
|
g_model* g_model_load(const char* filename) {
|
|
fastObjMesh* mesh = fast_obj_read(filename);
|
|
|
|
fastObjMaterial mat = mesh->materials[0];
|
|
|
|
g_vertex_vec vertices = { 0 };
|
|
printf("load: %d positions\n", mesh->position_count);
|
|
for(sz i = 1; i < mesh->position_count; i++) {
|
|
g_vertex vertex = {
|
|
.x = mesh->positions[i * 3],
|
|
.y = mesh->positions[i * 3 + 1],
|
|
.z = mesh->positions[i * 3 + 2],
|
|
.color = (g_color){ mat.Kd[0] * 255, mat.Kd[1] * 255, mat.Kd[2] * 255, 255 },
|
|
.u = mesh->texcoords[i * 2] * 32767,
|
|
.v = mesh->texcoords[i * 2 + 1] * 32767
|
|
};
|
|
|
|
sl_vec_push(vertices, vertex);
|
|
}
|
|
|
|
g_index_vec indices = { 0 };
|
|
printf("load: %d indices\n", mesh->index_count);
|
|
for(sz i = 0; i < mesh->index_count; i++) {
|
|
printf("index (%u) points to\n", mesh->indices[i].p);
|
|
sl_vec_push(indices, mesh->indices[i].p - 1);
|
|
}
|
|
|
|
return g_model_create(&vertices, &indices);
|
|
}*/
|