fonctionnel
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/17 21:52:57 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/02/17 23:28:25 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -54,8 +54,10 @@ t_scene load_config(const char *filename)
|
||||
line = get_next_line(fd);
|
||||
if (!line)
|
||||
break ;
|
||||
parsing_line(line, scene);
|
||||
scene = parsing_line(line, scene);
|
||||
free(line);
|
||||
}
|
||||
printf("AFFICHE CONFIG\n");
|
||||
print_scene(scene);
|
||||
return (scene);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ #
|
||||
# +#+#+#+#+#+ +#+ #
|
||||
# Created: 2025/02/13 19:27:37 by yantoine #+# #+# #
|
||||
# Updated: 2025/02/13 19:37:39 by yantoine ### ########.fr #
|
||||
# Updated: 2025/02/17 23:33:44 by yantoine ### ########.fr #
|
||||
# #
|
||||
# **************************************************************************** #
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
A 0 255,255,255
|
||||
|
||||
# Camera : position à (0,0,20) et orientée vers (0,0,-1) avec un FOV de 70°
|
||||
C 10,20,20 0,0,-1 70
|
||||
C 10,0,-30 0,0,1 70
|
||||
|
||||
# Light : source lumineuse forte placée au-dessus de la scène
|
||||
L 11,40,-30 1 255,255,255
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/17 19:54:03 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/17 23:10:31 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/02/17 23:35:02 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -20,17 +20,6 @@ static int init_app_config(t_app *app, int argc, char **argv)
|
||||
scene = load_config(argv[1]);
|
||||
app->win_width = WIDTH;
|
||||
app->win_height = HEIGHT;
|
||||
app->scene.camera.move_speed = 0.5f;
|
||||
app->scene.camera.rot_speed = 0.03f;
|
||||
app->mouse_sens = 0.002f;
|
||||
app->key_w = 0;
|
||||
app->key_s = 0;
|
||||
app->key_a = 0;
|
||||
app->key_d = 0;
|
||||
app->key_left = 0;
|
||||
app->key_right = 0;
|
||||
app->key_up = 0;
|
||||
app->key_down = 0;
|
||||
app->scene = scene;
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/13 20:02:36 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/17 23:10:49 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/02/17 23:35:34 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -94,8 +94,6 @@ typedef struct s_camera
|
||||
t_vec3 camDir;
|
||||
t_vec3 right;
|
||||
t_vec3 up;
|
||||
float move_speed;
|
||||
float rot_speed;
|
||||
float fov;
|
||||
float yaw;// vue de gauche a droite
|
||||
float pitch; // vue de haut en bas en radians
|
||||
@@ -239,6 +237,19 @@ int update_frame(t_app *app);
|
||||
// Array
|
||||
int ft_arraylen(char **array);
|
||||
void ft_free_array(char **array);
|
||||
|
||||
// Conversion
|
||||
float ft_atof(char *str);
|
||||
|
||||
// Info
|
||||
void print_vec3(t_vec3 vec);
|
||||
void print_ray(t_ray ray);
|
||||
void print_sphere(t_sphere sphere);
|
||||
void print_plane(t_plane plane);
|
||||
void print_cylinder(t_cylinder cyl);
|
||||
void print_light(t_light light);
|
||||
void print_ambient(t_ambient amb);
|
||||
void print_camera(t_camera cam);
|
||||
void print_scene(t_scene scene);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,139 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* print.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/17 23:16:21 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/17 23:35:54 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "miniRT.h"
|
||||
|
||||
void print_vec3(t_vec3 vec) {
|
||||
printf("(x: %.2f, y: %.2f, z: %.2f)", vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
void print_ray(t_ray ray) {
|
||||
printf("Rayon d'origine : ");
|
||||
print_vec3(ray.origin);
|
||||
printf("\nDirection : ");
|
||||
print_vec3(ray.dir);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_sphere(t_sphere sphere) {
|
||||
printf("Centre : ");
|
||||
print_vec3(sphere.center);
|
||||
printf("\nRayon : %.2f", sphere.radius);
|
||||
printf("\nCouleur : ");
|
||||
print_vec3(sphere.color);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_plane(t_plane plane) {
|
||||
printf("Point : ");
|
||||
print_vec3(plane.point);
|
||||
printf("\nNormale : ");
|
||||
print_vec3(plane.normal);
|
||||
printf("\nCouleur : ");
|
||||
print_vec3(plane.color);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_cylinder(t_cylinder cyl) {
|
||||
printf("Centre : ");
|
||||
print_vec3(cyl.center);
|
||||
printf("\nAxe : ");
|
||||
print_vec3(cyl.axis);
|
||||
printf("\nRayon : %.2f", cyl.radius);
|
||||
printf("\nHauteur : %.2f", cyl.height);
|
||||
printf("\nCouleur : ");
|
||||
print_vec3(cyl.color);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_light(t_light light) {
|
||||
printf("Position : ");
|
||||
print_vec3(light.pos);
|
||||
printf("\nIntensité : %.2f", light.brightness);
|
||||
printf("\nCouleur : ");
|
||||
print_vec3(light.color);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_ambient(t_ambient amb) {
|
||||
printf("Ratio d'ambiance : %.2f\n", amb.ratio);
|
||||
printf("Couleur ambiante : ");
|
||||
print_vec3(amb.color);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_camera(t_camera cam) {
|
||||
printf("Position de la caméra : ");
|
||||
print_vec3(cam.camPos);
|
||||
printf("\nDirection : ");
|
||||
print_vec3(cam.camDir);
|
||||
printf("\nRight : ");
|
||||
print_vec3(cam.right);
|
||||
printf("\nUp : ");
|
||||
print_vec3(cam.up);
|
||||
printf("\nFOV : %.2f", cam.fov);
|
||||
printf("\nYaw : %.2f", cam.yaw);
|
||||
printf("\nPitch : %.2f", cam.pitch);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void print_scene(t_scene scene) {
|
||||
int i = 0;
|
||||
|
||||
printf("=== SCENE ===\n");
|
||||
|
||||
// Ambiance
|
||||
printf("\n--- Ambiance ---\n");
|
||||
print_ambient(scene.ambient);
|
||||
|
||||
// Caméra
|
||||
if (scene.numCamera > 0) {
|
||||
printf("\n--- Caméra ---\n");
|
||||
print_camera(scene.camera);
|
||||
}
|
||||
|
||||
// Sphères
|
||||
printf("\n--- Sphères (%d) ---\n", scene.numSpheres);
|
||||
i = 0;
|
||||
while (i < scene.numSpheres) {
|
||||
printf("\nSphère %d :\n", i);
|
||||
print_sphere(scene.spheres[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
// Plans
|
||||
printf("\n--- Plans (%d) ---\n", scene.numPlanes);
|
||||
i = 0;
|
||||
while (i < scene.numPlanes) {
|
||||
printf("\nPlan %d :\n", i);
|
||||
print_plane(scene.planes[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
// Cylindres
|
||||
printf("\n--- Cylindres (%d) ---\n", scene.numCylinders);
|
||||
i = 0;
|
||||
while (i < scene.numCylinders) {
|
||||
printf("\nCylindre %d :\n", i);
|
||||
print_cylinder(scene.cylinders[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
// Lumières
|
||||
printf("\n--- Lumières (%d) ---\n", scene.numLights);
|
||||
i = 0;
|
||||
while (i < scene.numLights) {
|
||||
printf("\nLumière %d :\n", i);
|
||||
print_light(scene.lights[i]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -550,7 +550,6 @@ mouse_sens miniRT.h /^ float mouse_sens;$/;" m struct:s_app typeref:typename:flo
|
||||
mouse_win1 minilibx-linux/test/main.c /^int mouse_win1(int button,int x,int y, void *p)$/;" f typeref:typename:int
|
||||
mouse_win2 minilibx-linux/test/main.c /^int mouse_win2(int button,int x,int y, void *p)$/;" f typeref:typename:int
|
||||
mouse_win3 minilibx-linux/test/main.c /^int mouse_win3(int x,int y, void *p)$/;" f typeref:typename:int
|
||||
move_speed miniRT.h /^ float move_speed;$/;" m struct:s_camera typeref:typename:float
|
||||
n miniRT.h /^ t_vec3 n;$/;" m struct:s_calc typeref:typename:t_vec3
|
||||
name minilibx-linux/mlx_int.h /^ char *name;$/;" m struct:s_col_name typeref:typename:char *
|
||||
name minilibx-linux/mlx_int.h /^ int name;$/;" m struct:s_xpm_col typeref:typename:int
|
||||
@@ -588,6 +587,15 @@ pixels miniRT.h /^ int *pixels;$/;" m struct:s_app typeref:typename:int *
|
||||
planes miniRT.h /^ t_plane planes[MAX_PLANES];$/;" m struct:s_scene typeref:typename:t_plane[]
|
||||
point miniRT.h /^ t_vec3 point;$/;" m struct:s_plane typeref:typename:t_vec3
|
||||
pos miniRT.h /^ t_vec3 pos;$/;" m struct:s_light typeref:typename:t_vec3
|
||||
print_ambient print.c /^void print_ambient(t_ambient amb) {$/;" f typeref:typename:void
|
||||
print_camera print.c /^void print_camera(t_camera cam) {$/;" f typeref:typename:void
|
||||
print_cylinder print.c /^void print_cylinder(t_cylinder cyl) {$/;" f typeref:typename:void
|
||||
print_light print.c /^void print_light(t_light light) {$/;" f typeref:typename:void
|
||||
print_plane print.c /^void print_plane(t_plane plane) {$/;" f typeref:typename:void
|
||||
print_ray print.c /^void print_ray(t_ray ray) {$/;" f typeref:typename:void
|
||||
print_scene print.c /^void print_scene(t_scene scene) {$/;" f typeref:typename:void
|
||||
print_sphere print.c /^void print_sphere(t_sphere sphere) {$/;" f typeref:typename:void
|
||||
print_vec3 print.c /^void print_vec3(t_vec3 vec) {$/;" f typeref:typename:void
|
||||
printf_fd libft/printf_fd.c /^int printf_fd(int fd, const char *str, ...)$/;" f typeref:typename:int
|
||||
private_cmap minilibx-linux/mlx_int.h /^ int private_cmap;$/;" m struct:s_xvar typeref:typename:int
|
||||
proj miniRT.h /^ float proj;$/;" m struct:s_calc typeref:typename:float
|
||||
@@ -609,7 +617,6 @@ render_pixel render.c /^static void render_pixel(t_app *app, int x, int y)$/;" f
|
||||
render_scene render.c /^void render_scene(t_app *app)$/;" f typeref:typename:void
|
||||
right miniRT.h /^ t_vec3 right;$/;" m struct:s_camera typeref:typename:t_vec3
|
||||
root minilibx-linux/mlx_int.h /^ Window root;$/;" m struct:s_xvar typeref:typename:Window
|
||||
rot_speed miniRT.h /^ float rot_speed;$/;" m struct:s_camera typeref:typename:float
|
||||
s_ambient miniRT.h /^typedef struct s_ambient$/;" s
|
||||
s_app miniRT.h /^typedef struct s_app$/;" s
|
||||
s_calc miniRT.h /^typedef struct s_calc$/;" s
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/17 19:27:23 by yantoine #+# #+# */
|
||||
/* Updated: 2025/02/17 23:07:57 by yantoine ### ########.fr */
|
||||
/* Updated: 2025/02/17 23:36:33 by yantoine ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user