est ce donc finis
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/14 01:41:17 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/18 20:44:41 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/02/22 20:37:46 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -43,7 +43,7 @@ t_scene load_config(const char *filename)
|
||||
|
||||
scene = create_scene();
|
||||
fd = open(filename, O_RDONLY);
|
||||
if (!fd)
|
||||
if (fd <= 0 || !have_extension(filename))
|
||||
{
|
||||
printf("Erreur : impossible d'ouvrir %s\n", filename);
|
||||
return (scene);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* have_extension.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/22 20:45:59 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/22 21:04:31 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "miniRT.h"
|
||||
|
||||
int have_extension(const char *line)
|
||||
{
|
||||
const int lenght = ft_strlen(line);
|
||||
|
||||
if (lenght < 3)
|
||||
return (0);
|
||||
if (ft_strncmp(lenght + line - 3, ".rt", lenght) == 0)
|
||||
return (1);
|
||||
printf("erreur: pas d'extension\n");
|
||||
return (0);
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/17 19:54:03 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/18 17:23:15 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/02/22 21:32:40 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -51,13 +51,31 @@ static void setup_hooks(t_app *app)
|
||||
mlx_loop_hook(app->mlx, update_frame, app);
|
||||
}
|
||||
|
||||
static int check_number(t_scene scene)
|
||||
{
|
||||
if (scene.num_camera > MAX_CAMERA)
|
||||
return (0);
|
||||
if (scene.num_planes > MAX_PLANES)
|
||||
return (0);
|
||||
if (scene.num_spheres > MAX_SPHERES)
|
||||
return (0);
|
||||
if (scene.num_cylinders > MAX_CYLINDERS)
|
||||
return (0);
|
||||
if (scene.num_lights > MAX_LIGHTS)
|
||||
return (0);
|
||||
if (scene.num_ambient > MAX_AMBIENT)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
t_app app;
|
||||
|
||||
ft_bzero(&app, sizeof(t_app));
|
||||
init_app_config(&app, argc, argv);
|
||||
if (app.scene.num_camera == 0 || init_mlx_and_image(&app))
|
||||
if (!check_number(app.scene) || app.scene.num_camera == 0 || init_mlx_and_image(&app))
|
||||
return (1);
|
||||
setup_hooks(&app);
|
||||
mlx_loop(app.mlx);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 20:02:36 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/22 18:29:15 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/02/22 21:21:03 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
# define MAX_SPHERES 128
|
||||
# define MAX_PLANES 128
|
||||
# define MAX_CYLINDERS 128
|
||||
# define MAX_LIGHTS 16
|
||||
# define MAX_LIGHTS 1
|
||||
# define MAX_AMBIENT 1
|
||||
# define MAX_CAMERA 1
|
||||
|
||||
@@ -237,6 +237,7 @@ char **get_tokens_secure(t_scene scene, const int numObject,
|
||||
// Check
|
||||
int check_tokens(char **tokens, int expected);
|
||||
int isdigit_token(char **tokens);
|
||||
int have_extension(const char *line);
|
||||
void check_if_max(t_scene scene, const int to_test, const int max);
|
||||
|
||||
// Intersection
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
A 0 255,255,255
|
||||
|
||||
C 0,0,0 0,0,-1 70
|
||||
|
||||
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
|
||||
@@ -0,0 +1,9 @@
|
||||
A 0 255,255,25555555555555555555555555555555555555555555555555555555555555555555
|
||||
|
||||
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
|
||||
@@ -0,0 +1,9 @@
|
||||
A 0 255,255,255
|
||||
|
||||
C 4444444444444444444444444,1111111111111111111111111,9999999999999999999999999999 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
|
||||
@@ -0,0 +1,9 @@
|
||||
A 999999999999999999999999999999999999999999999999999999999999999999999999999 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
|
||||
@@ -0,0 +1,27 @@
|
||||
# **************************************************************************** #
|
||||
# #
|
||||
# ::: :::::::: #
|
||||
# pas_extention :+: :+: :+: #
|
||||
# +:+ +:+ +:+ #
|
||||
# By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2025/02/13 19:27:37 by yantoine #+# #+# #
|
||||
# Updated: 2025/02/17 23:48:13 by yantoine ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
# Ambient lighting (ratio et couleur)
|
||||
A 0 255,255,255
|
||||
|
||||
# Camera : position à (0,0,20) et orientée vers (0,0,-1) avec un FOV de 70°
|
||||
C 0,0,0 0,0,0 70
|
||||
|
||||
# Light : source lumineuse forte placée au-dessus de la scène
|
||||
L 11,40,-30 1 255,255,255
|
||||
|
||||
sp 0,0,-20 10 0,0,100
|
||||
|
||||
# Plane : un plan vert servant de sol, passant par (0,-5,0) et avec une normale vers le haut
|
||||
pl 0,-5,0 0,1,0 100,55,0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user