This commit is contained in:
gbrochar 2024-10-04 18:22:49 +02:00
parent 5e66410346
commit 9022563247
4 changed files with 27 additions and 8 deletions

View File

@ -37,7 +37,8 @@ enum e_gl_buf_type {
UV,
NORMAL,
INDEX,
OTHER
OTHER,
INVALID
};
typedef struct s_cam t_cam;

9
resources/test.obj Normal file
View File

@ -0,0 +1,9 @@
v -10 -10 -10
v 10 10 10
v 0 0 0
v 30 30 30
v -20 10 30
f 1 2 3
f 1 2 4
f 3 2 4
f 1 3 5

View File

@ -6,7 +6,7 @@
/* By: gbrochar <gbrochar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/22 18:41:28 by gbrochar #+# #+# */
/* Updated: 2020/12/23 21:15:54 by gbrochar ### ########.fr */
/* Updated: 2024/10/04 18:09:40 by gbrochar ### ########.fr */
/* */
/* ************************************************************************** */
@ -22,7 +22,15 @@ t_gl_buf_type parse_gl_buf_type(char *token)
return (NORMAL);
if (strcmp(token, "f") == SUCCESS)
return (INDEX);
if (strcmp(token, "#") == SUCCESS
|| strcmp(token, "l") == SUCCESS
|| strcmp(token, "o") == SUCCESS
|| strcmp(token, "mtllib") == SUCCESS
|| strcmp(token, "s") == SUCCESS
|| strcmp(token, "g") == SUCCESS
|| strcmp(token, "usemtl") == SUCCESS)
return (OTHER);
return INVALID;
}
void parse_append_data_tmp(
@ -129,7 +137,6 @@ int parse_line(t_env *e, char *line)
token_count++;
}
if (gl_buf_type == INDEX && token_count > 4) {
//printf("spongebob squared face\n");
parse_triangulate_dispatcher(e, token_count - 1);
}
return (SUCCESS);

View File

@ -6,7 +6,7 @@
/* By: gbrochar <gbrochar@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/12/23 17:33:33 by gbrochar #+# #+# */
/* Updated: 2024/04/25 16:33:25 by gbrochar ### ########.fr */
/* Updated: 2024/10/04 17:47:15 by gbrochar ### ########.fr */
/* */
/* ************************************************************************** */
@ -71,6 +71,8 @@ int parse_token(
if (gl_buf_type == OTHER)
ret = BREAK;
if (gl_buf_type == INVALID)
ret = FAILURE;
if (gl_buf_type == VERTEX)
ret = parse_append_data_d(&(e->object.vertices), token);
if (gl_buf_type == UV && token_count < 3)