diff --git a/cross_cylindre_plane_sphere.rt b/cross_cylindre_plane_sphere.rt deleted file mode 100644 index 857b85e..0000000 --- a/cross_cylindre_plane_sphere.rt +++ /dev/null @@ -1,26 +0,0 @@ -# **************************************************************************** # -# # -# ::: :::::::: # -# config.rt :+: :+: :+: # -# +:+ +:+ +:+ # -# By: yantoine +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2025/02/13 19:27:37 by yantoine #+# #+# # -# Updated: 2025/02/18 17:19:31 by yantoine ### ########.fr # -# # -# **************************************************************************** # - -A 0 255,255,255 - -C 10,20,-60 0,0,1 70 - -L 11,40,-30 1 255,255,255 - -sp 0,0,0 10 255,0,0 -sp 10,10,10 10 0,0,100 - -pl 0,-5,0 0,1,0 100,55,0 - -cy 10,0,0 0.5,0,0 8 20 0,0,255 -cy 10,0,0 0,1,0 8 20 0,0,255 - diff --git a/isdigit_token.c b/isdigit_token.c new file mode 100644 index 0000000..eca669a --- /dev/null +++ b/isdigit_token.c @@ -0,0 +1,23 @@ +#include "miniRT.h" + +int isdigit_token(char **tokens) +{ + int i; + int j; + + i = -1; + while (tokens[++i]) + { + j = -1; + while (tokens[i][++j]) + { + if (!ft_isdigit(tokens[i][j]) && tokens[i][j] != '\n' && tokens[i][j] != '-' && tokens[i][j] != ',') + { + printf("%c\n", tokens[i][j]); + printf("%p\n", tokens[i]); + return (0); + } + } + } + return (1); +} diff --git a/libft b/libft index 060e991..2b3e413 160000 --- a/libft +++ b/libft @@ -1 +1 @@ -Subproject commit 060e991b6fce3d4d9418cd47b3b14f7cbd438ccc +Subproject commit 2b3e413e157169f4cb5abf69f9e0b1aa05636121 diff --git a/main.c b/main.c index ca7f091..5ca9e74 100644 --- a/main.c +++ b/main.c @@ -57,7 +57,7 @@ int main(int argc, char **argv) ft_bzero(&app, sizeof(t_app)); init_app_config(&app, argc, argv); - if (init_mlx_and_image(&app)) + if (app.scene.num_camera == 0 || init_mlx_and_image(&app)) return (1); setup_hooks(&app); mlx_loop(app.mlx); diff --git a/miniRT b/miniRT deleted file mode 100755 index d559f4a..0000000 Binary files a/miniRT and /dev/null differ diff --git a/miniRT.h b/miniRT.h index a359e57..9fb38db 100644 --- a/miniRT.h +++ b/miniRT.h @@ -237,6 +237,7 @@ char **get_tokens_secure(t_scene scene, const int numObject, // Check int check_tokens(char **tokens, int expected); void check_if_max(t_scene scene, const int to_test, const int max); +int isdigit_token(char **tokens); // Intersection float intersect_cylinder(t_ray ray, t_cylinder cy, t_vec3 *hitNormal); diff --git a/one_sphere_plane.rt b/one_sphere_plane.rt deleted file mode 100644 index 199ce91..0000000 --- a/one_sphere_plane.rt +++ /dev/null @@ -1,21 +0,0 @@ -# **************************************************************************** # -# # -# ::: :::::::: # -# one_sphere_plane.rt :+: :+: :+: # -# +:+ +:+ +:+ # -# By: yantoine +#+ +:+ +#+ # -# +#+#+#+#+#+ +#+ # -# Created: 2025/02/13 19:27:37 by yantoine #+# #+# # -# Updated: 2025/02/18 17:17:07 by yantoine ### ########.fr # -# # -# **************************************************************************** # - -A 0 255,255,255 - -C 0,0,0 0,0,-1 70 - -L 11,40,50 1 255,255,255 - -sp 0,0,-20 10 0,0,100 - -pl 0,-5,0 0,1,0 100,55,0 diff --git a/parsing_utils.c b/parsing_utils.c index 7b7d2cf..d36a3af 100644 --- a/parsing_utils.c +++ b/parsing_utils.c @@ -19,7 +19,7 @@ char **get_tokens_secure(t_scene scene, const int numObject, check_if_max(scene, numObject, numObjectMax); tokens = ft_split(scene.line_if_exit, ' '); - if (!check_tokens(tokens, supposed_nb_token)) + if (!check_tokens(tokens, supposed_nb_token) || !isdigit_token(tokens + 1)) { ft_free_array(tokens); ft_putendl_fd("error", 2); diff --git a/scene_fonctionnel/cross_cylindre_plane_sphere.rt b/scene_fonctionnel/cross_cylindre_plane_sphere.rt new file mode 100644 index 0000000..6152fb0 --- /dev/null +++ b/scene_fonctionnel/cross_cylindre_plane_sphere.rt @@ -0,0 +1,14 @@ +A 0 255,255,255 + +C 10,20,-60 0,0,1 70 + +L 11,40,-30 1 255,255,255 + +sp 0,0,0 10 255,0,0 +sp 10,10,10 10 0,0,100 + +pl 0,-5,0 0,1,0 100,55,0 + +cy 10,0,0 0.5,0,0 8 20 0,0,255 +cy 10,0,0 0,1,0 8 20 0,0,255 + diff --git a/scene_fonctionnel/one_sphere_plane.rt b/scene_fonctionnel/one_sphere_plane.rt new file mode 100644 index 0000000..f2a1bcf --- /dev/null +++ b/scene_fonctionnel/one_sphere_plane.rt @@ -0,0 +1,9 @@ +A 0 255,255,255 + +C 0,0,0 0,0,-1 70 + +L 11,40,50 1 255,255,255 + +sp 0,0,-20 10 0,0,100 + +pl 0,-5,0 0,1,0 100,55,0 diff --git a/one_sphere_plane_contre_jour.rt b/scene_fonctionnel/one_sphere_plane_contre_jour.rt similarity index 100% rename from one_sphere_plane_contre_jour.rt rename to scene_fonctionnel/one_sphere_plane_contre_jour.rt diff --git a/scene_non_fonctionel/letter2.rt b/scene_non_fonctionel/letter2.rt new file mode 100644 index 0000000..5b3b688 --- /dev/null +++ b/scene_non_fonctionel/letter2.rt @@ -0,0 +1,9 @@ +A 0 255,255,255 + +C 0,0,0 0,0,-1 70 + +L 11,40,50 1 2e5,255,255 + +sp 0,0,-20 10 0,0,100 + +pl 0,-5,0 0,1,0 100,55,0 diff --git a/scene_non_fonctionel/lettre_en_param.rt b/scene_non_fonctionel/lettre_en_param.rt new file mode 100644 index 0000000..caf070a --- /dev/null +++ b/scene_non_fonctionel/lettre_en_param.rt @@ -0,0 +1,9 @@ +A e 255,255,255 + +C 0,0,0 0,0,-1 70 + +L 11,40,50 1 255,255,255 + +sp 0,0,-20 10 0,0,100 + +pl 0,-5,0 0,1,0 100,55,0 diff --git a/scene_non_fonctionel/over_param.rt b/scene_non_fonctionel/over_param.rt new file mode 100644 index 0000000..75d9da0 --- /dev/null +++ b/scene_non_fonctionel/over_param.rt @@ -0,0 +1,9 @@ +A 0 255,255,255 1 + +C 0,0,0 0,0,-1 70 + +L 11,40,50 1 255,255,255 + +sp 0,0,-20 10 0,0,100 + +pl 0,-5,0 0,1,0 100,55,0 diff --git a/scene_non_fonctionel/sans_camera.rt b/scene_non_fonctionel/sans_camera.rt new file mode 100644 index 0000000..581ca19 --- /dev/null +++ b/scene_non_fonctionel/sans_camera.rt @@ -0,0 +1,12 @@ +A 0 255,255,255 + +L 11,40,-30 1 255,255,255 + +sp 0,0,0 10 255,0,0 +sp 10,10,10 10 0,0,100 + +pl 0,-5,0 0,1,0 100,55,0 + +cy 10,0,0 0.5,0,0 8 20 0,0,255 +cy 10,0,0 0,1,0 8 20 0,0,255 +