parser done except for f tokens, start matrices/vectors utils
This commit is contained in:
parent
7df21548f5
commit
be0af3b26d
|
@ -0,0 +1,23 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* mat4.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbrochar <gbrochar@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2020/12/22 20:35:00 by gbrochar #+# #+# */
|
||||
/* Updated: 2020/12/22 20:48:29 by gbrochar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef MAT4_H
|
||||
# define MAT4_H
|
||||
|
||||
typedef struct s_mat4 t_mat4;
|
||||
|
||||
struct s_mat4
|
||||
{
|
||||
double data[16];
|
||||
};
|
||||
|
||||
#endif
|
15
src/main.c
15
src/main.c
|
@ -6,7 +6,7 @@
|
|||
/* By: gbrochar <gbrochar@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2020/12/22 12:02:14 by gbrochar #+# #+# */
|
||||
/* Updated: 2020/12/22 20:11:50 by gbrochar ### ########.fr */
|
||||
/* Updated: 2020/12/22 20:48:00 by gbrochar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -19,19 +19,6 @@ int main(int argc, char **argv)
|
|||
init_env(&e);
|
||||
if (parse(&e, argc, argv) == SUCCESS)
|
||||
{
|
||||
// printf("vertices: ");
|
||||
// for (size_t i = 0; i < e.object.vertices.ptr; i++)
|
||||
// printf("%f ", e.object.vertices.data[i]);
|
||||
// printf("\nuvs: ");
|
||||
// for (size_t i = 0; i < e.object.uvs.ptr; i++)
|
||||
// printf("%f ", e.object.uvs.data[i]);
|
||||
// printf("\nnormals: ");
|
||||
// for (size_t i = 0; i < e.object.normals.ptr; i++)
|
||||
// printf("%f ", e.object.normals.data[i]);
|
||||
// printf("\nindices: ");
|
||||
// for (size_t i = 0; i < e.object.indices.ptr; i++)
|
||||
// printf("%d ", e.object.indices.data[i]);
|
||||
// printf("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* mat4_transpose.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: gbrochar <gbrochar@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2020/12/22 20:34:52 by gbrochar #+# #+# */
|
||||
/* Updated: 2020/12/22 20:48:21 by gbrochar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "mat4.h"
|
||||
|
||||
t_mat4 mat4_transpose(t_mat4 m)
|
||||
{
|
||||
t_mat4 out;
|
||||
|
||||
out.data[0] = m.data[0];
|
||||
out.data[1] = m.data[4];
|
||||
out.data[2] = m.data[8];
|
||||
out.data[3] = m.data[12];
|
||||
out.data[4] = m.data[1];
|
||||
out.data[5] = m.data[5];
|
||||
out.data[6] = m.data[9];
|
||||
out.data[7] = m.data[13];
|
||||
out.data[8] = m.data[2];
|
||||
out.data[9] = m.data[6];
|
||||
out.data[10] = m.data[10];
|
||||
out.data[11] = m.data[14];
|
||||
out.data[12] = m.data[3];
|
||||
out.data[13] = m.data[7];
|
||||
out.data[14] = m.data[11];
|
||||
out.data[15] = m.data[15];
|
||||
return (out);
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
/* By: gbrochar <gbrochar@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2020/12/22 18:41:28 by gbrochar #+# #+# */
|
||||
/* Updated: 2020/12/22 20:15:50 by gbrochar ### ########.fr */
|
||||
/* Updated: 2020/12/22 20:26:47 by gbrochar ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -40,13 +40,13 @@ int parse_append_data_i(t_buf_i *buffer, char *token)
|
|||
|
||||
t_gl_buf_type parse_gl_buf_type(char *token)
|
||||
{
|
||||
if (strstr(token, "v"))
|
||||
if (strcmp(token, "v") == SUCCESS)
|
||||
return (VERTEX);
|
||||
if (strstr(token, "vt"))
|
||||
if (strcmp(token, "vt") == SUCCESS)
|
||||
return (UV);
|
||||
if (strstr(token, "vn"))
|
||||
if (strcmp(token, "vn") == SUCCESS)
|
||||
return (NORMAL);
|
||||
if (strstr(token, "f"))
|
||||
if (strcmp(token, "f") == SUCCESS)
|
||||
return (INDEX);
|
||||
return (OTHER);
|
||||
}
|
||||
|
@ -63,7 +63,10 @@ int parse_token(
|
|||
if (gl_buf_type == VERTEX)
|
||||
ret = parse_append_data_d(&(e->object.vertices), token);
|
||||
if (gl_buf_type == UV)
|
||||
{
|
||||
printf("uv");
|
||||
ret = parse_append_data_d(&(e->object.uvs), token);
|
||||
}
|
||||
if (gl_buf_type == NORMAL)
|
||||
ret = parse_append_data_d(&(e->object.normals), token);
|
||||
if (gl_buf_type == INDEX)
|
||||
|
|
Loading…
Reference in New Issue