update norme

This commit is contained in:
H3XploR
2025-02-19 17:02:54 +01:00
parent d32c5bd01c
commit cc014a14d0
9 changed files with 89 additions and 88 deletions
BIN
View File
Binary file not shown.
+33 -32
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/13 20:02:36 by yantoine #+# #+# */
/* Updated: 2025/02/19 16:48:27 by yantoine ### ########.fr */
/* Updated: 2025/02/19 16:57:35 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -69,8 +69,8 @@ typedef struct s_plane
typedef struct s_cylinder
{
t_vec3 center;
t_vec3 axis; // Axe normalisé
float radius; // Demi-diamètre
t_vec3 axis;
float radius;
float height;
t_vec3 color;
} t_cylinder;
@@ -90,29 +90,29 @@ typedef struct s_ambient
typedef struct s_hit
{
float t;
t_vec3 normal;
t_vec3 color;
float t;
t_vec3 normal;
t_vec3 color;
} t_hit;
typedef struct s_hit_info {
t_vec3 point;
t_vec3 normal;
t_vec3 color;
} t_hit_info;
typedef struct s_hit_info
{
t_vec3 point;
t_vec3 normal;
t_vec3 color;
} t_hit_info;
typedef struct s_camera
{
t_vec3 camPos;
t_vec3 camDir;
t_vec3 cam_pos;
t_vec3 cam_dir;
t_vec3 right;
t_vec3 up;
float rot_speed;
float move_speed;
float fov;
float yaw; // vue de gauche a droite
float pitch; // vue de haut en bas en radians
float yaw;
float pitch;
} t_camera;
typedef struct s_scene
@@ -167,11 +167,11 @@ typedef struct s_calc
float b;
float c;
float disc;
float sqrtDisc;
float sqrt_disc;
float t0;
float t1;
float t;
t_vec3 hitPoint;
t_vec3 hit_point;
t_vec3 d;
t_vec3 v;
float d_dot_v;
@@ -198,12 +198,12 @@ typedef struct s_calc
t_ray ray;
t_vec3 ray_dir;
t_vec3 color;
t_light light;
t_vec3 l;
float diff;
t_vec3 view_dir;
t_vec3 half_dir;
float spec;
t_light light;
t_vec3 l;
float diff;
t_vec3 view_dir;
t_vec3 half_dir;
float spec;
} t_calc;
@@ -245,17 +245,18 @@ float intersect_sphere(t_ray ray, t_sphere s, t_vec3 *hitNormal);
bool is_in_shadow(t_vec3 hitPoint, t_vec3 lightPos, t_scene scene);
bool intersect_objects(float *tMin, t_vec3 *hitNormal,
t_vec3 *objColor, t_scene scene);
t_vec3 calc_lighting(t_vec3 hitPoint, t_vec3 hitNormal, t_vec3 objColor,
t_scene scene);
t_vec3 calc_lighting(t_vec3 hitPoint, t_vec3 hitNormal,
t_vec3 objColor, t_scene scene);
t_vec3 trace(t_ray ray, t_scene scene);
// Interesction utils cylindre
int init_intersection(t_ray ray, t_cylinder cy, t_calc *calc);
void compute_side_intersection(t_cylinder cy, t_calc *calc);
void compute_cap_intersection(t_ray ray, t_cylinder cy, t_calc *calc);
float select_final_intersection(t_calc *calc);
void compute_hit_normal(t_ray ray, t_cylinder cy, t_calc *calc,
t_vec3 *hitNormal);
int init_intersection(t_ray ray, t_cylinder cy, t_calc *calc);
void compute_side_intersection(t_cylinder cy, t_calc *calc);
void compute_cap_intersection(t_ray ray, t_cylinder cy,
t_calc *calc);
float select_final_intersection(t_calc *calc);
void compute_hit_normal(t_ray ray, t_cylinder cy, t_calc *calc,
t_vec3 *hitNormal);
// Peripherique
int key_press(int keycode, t_app *app);
+5 -5
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/14 20:02:29 by yantoine #+# #+# */
/* Updated: 2025/02/19 16:49:01 by yantoine ### ########.fr */
/* Updated: 2025/02/19 16:58:31 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -18,11 +18,11 @@ t_scene parsing_camera(t_scene scene)
tokens = get_tokens_secure(scene, scene.num_camera, MAX_CAMERA, 4);
scene.token_if_exit = tokens;
scene.camera.camPos = parse_vector(tokens[1], scene);
scene.camera.camDir = parse_vector_normalize(tokens[2], scene);
scene.camera.cam_pos = parse_vector(tokens[1], scene);
scene.camera.cam_dir = parse_vector_normalize(tokens[2], scene);
scene.camera.fov = ft_atof(tokens[3]);
scene.camera.yaw = atan2f(scene.camera.camDir.x, -scene.camera.camDir.z);
scene.camera.pitch = asinf(scene.camera.camDir.y);
scene.camera.yaw = atan2f(scene.camera.cam_dir.x, -scene.camera.cam_dir.z);
scene.camera.pitch = asinf(scene.camera.cam_dir.y);
ft_free_array(tokens);
scene.num_camera++;
return (scene);
+6 -6
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/17 18:54:45 by yantoine #+# #+# */
/* Updated: 2025/02/18 20:43:49 by yantoine ### ########.fr */
/* Updated: 2025/02/19 16:59:10 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -29,9 +29,9 @@ int init_intersection(t_ray ray, t_cylinder cy, t_calc *calc)
calc->disc = calc->b * calc->b - 4 * calc->a * calc->c;
if (calc->disc < 0)
return (-1);
calc->sqrtDisc = sqrtf(calc->disc);
calc->t0 = (-calc->b - calc->sqrtDisc) / (2 * calc->a);
calc->t1 = (-calc->b + calc->sqrtDisc) / (2 * calc->a);
calc->sqrt_disc = sqrtf(calc->disc);
calc->t0 = (-calc->b - calc->sqrt_disc) / (2 * calc->a);
calc->t1 = (-calc->b + calc->sqrt_disc) / (2 * calc->a);
return (0);
}
@@ -109,8 +109,8 @@ float select_final_intersection(t_calc *calc)
void compute_hit_normal(t_ray ray, t_cylinder cy, t_calc *calc,
t_vec3 *hitNormal)
{
calc->hitPoint = vec3_add(ray.origin, vec3_scale(calc->d, calc->t_final));
calc->cp = vec3_sub(calc->hitPoint, cy.center);
calc->hit_point = vec3_add(ray.origin, vec3_scale(calc->d, calc->t_final));
calc->cp = vec3_sub(calc->hit_point, cy.center);
calc->proj = vec3_dot(calc->cp, calc->v);
if (fabs(calc->proj) < cy.height / 2.0f - 1e-3f)
{
+6 -6
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/15 19:46:16 by yantoine #+# #+# */
/* Updated: 2025/02/19 16:50:19 by yantoine ### ########.fr */
/* Updated: 2025/02/19 16:59:34 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -37,16 +37,16 @@ float intersect_sphere(t_ray ray, t_sphere s, t_vec3 *hitNormal)
calc.disc = calc.b * calc.b - 4 * calc.a * calc.c;
if (calc.disc < 0)
return (-1);
calc.sqrtDisc = sqrtf(calc.disc);
calc.t0 = (-calc.b - calc.sqrtDisc) / (2 * calc.a);
calc.t1 = (-calc.b + calc.sqrtDisc) / (2 * calc.a);
calc.sqrt_disc = sqrtf(calc.disc);
calc.t0 = (-calc.b - calc.sqrt_disc) / (2 * calc.a);
calc.t1 = (-calc.b + calc.sqrt_disc) / (2 * calc.a);
if (calc.t0 > 1e-3f)
calc.t = calc.t0;
else
calc.t = calc.t1;
if (calc.t < 1e-3f)
return (-1);
calc.hitPoint = vec3_add(ray.origin, vec3_scale(ray.dir, calc.t));
*hitNormal = vec3_normalize(vec3_sub(calc.hitPoint, s.center));
calc.hit_point = vec3_add(ray.origin, vec3_scale(ray.dir, calc.t));
*hitNormal = vec3_normalize(vec3_sub(calc.hit_point, s.center));
return (calc.t);
}
+3 -3
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/17 19:24:30 by yantoine #+# #+# */
/* Updated: 2025/02/17 23:08:52 by yantoine ### ########.fr */
/* Updated: 2025/02/19 16:59:45 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -25,11 +25,11 @@ static void render_pixel(t_app *app, int x, int y)
calc.scale = tanf((app->scene.camera.fov * 0.5f) * (M_PI / 180.0f));
calc.screen_x = (2 * calc.ndc_x - 1) * calc.aspect * calc.scale;
calc.screen_y = (1 - 2 * calc.ndc_y) * calc.scale;
calc.ray_dir = vec3_add(app->scene.camera.camDir,
calc.ray_dir = vec3_add(app->scene.camera.cam_dir,
vec3_add(vec3_scale(app->scene.camera.right, calc.screen_x),
vec3_scale(app->scene.camera.up, calc.screen_y)));
calc.ray_dir = vec3_normalize(calc.ray_dir);
calc.ray.origin = app->scene.camera.camPos;
calc.ray.origin = app->scene.camera.cam_pos;
calc.ray.dir = calc.ray_dir;
calc.color = trace(calc.ray, app->scene);
r = (unsigned char)(fminf(calc.color.x, 1.0f) * 255);
+22 -22
View File
@@ -272,7 +272,7 @@ all minilibx-linux/test/Makefile.mk /^all: $(NAME)$/;" t
ambient miniRT.h /^ t_ambient ambient;$/;" m struct:s_scene typeref:typename:t_ambient
aspect miniRT.h /^ float aspect;$/;" m struct:s_calc typeref:typename:float
at_exit minilibx-linux/test/run_tests.sh /^at_exit() {$/;" f
axis miniRT.h /^ t_vec3 axis; \/\/ Axe normalisé$/;" m struct:s_cylinder typeref:typename:t_vec3
axis miniRT.h /^ t_vec3 axis;$/;" m struct:s_cylinder typeref:typename:t_vec3
b miniRT.h /^ float b;$/;" m struct:s_calc typeref:typename:float
base libft/libft.h /^ int base;$/;" m struct:s_info typeref:typename:int
better_ray_tracer README.md /^# better_ray_tracer/;" c
@@ -286,8 +286,8 @@ brightness miniRT.h /^ float brightness;$/;" m struct:s_light typeref:typename:
c miniRT.h /^ float c;$/;" m struct:s_calc typeref:typename:float
calc_light_contribution trace.c /^static t_vec3 calc_light_contribution(t_hit_info hit, t_light light,$/;" f typeref:typename:t_vec3 file:
calc_lighting trace.c /^t_vec3 calc_lighting(t_vec3 hit_point, t_vec3 hit_normal, t_vec3 obj_color,$/;" f typeref:typename:t_vec3
camDir miniRT.h /^ t_vec3 camDir;$/;" m struct:s_camera typeref:typename:t_vec3
camPos miniRT.h /^ t_vec3 camPos;$/;" m struct:s_camera typeref:typename:t_vec3
cam_dir miniRT.h /^ t_vec3 cam_dir;$/;" m struct:s_camera typeref:typename:t_vec3
cam_pos miniRT.h /^ t_vec3 cam_pos;$/;" m struct:s_camera typeref:typename:t_vec3
camera miniRT.h /^ t_camera camera;$/;" m struct:s_scene typeref:typename:t_camera
center miniRT.h /^ t_vec3 center;$/;" m struct:s_cylinder typeref:typename:t_vec3
center miniRT.h /^ t_vec3 center;$/;" m struct:s_sphere typeref:typename:t_vec3
@@ -310,11 +310,11 @@ col minilibx-linux/mlx_int.h /^ int col;$/;" m struct:s_xpm_col typeref:typenam
color miniRT.h /^ t_vec3 color;$/;" m struct:s_ambient typeref:typename:t_vec3
color miniRT.h /^ t_vec3 color;$/;" m struct:s_calc typeref:typename:t_vec3
color miniRT.h /^ t_vec3 color;$/;" m struct:s_cylinder typeref:typename:t_vec3
color miniRT.h /^ t_vec3 color;$/;" m struct:s_hit typeref:typename:t_vec3
color miniRT.h /^ t_vec3 color;$/;" m struct:s_hit_info typeref:typename:t_vec3
color miniRT.h /^ t_vec3 color;$/;" m struct:s_light typeref:typename:t_vec3
color miniRT.h /^ t_vec3 color;$/;" m struct:s_plane typeref:typename:t_vec3
color miniRT.h /^ t_vec3 color;$/;" m struct:s_sphere typeref:typename:t_vec3
color miniRT.h /^ t_vec3 color;$/;" m struct:s_hit typeref:typename:t_vec3
color miniRT.h /^ t_vec3 color;$/;" m struct:s_hit_info typeref:typename:t_vec3
color minilibx-linux/mlx_int.h /^ int color;$/;" m struct:s_col_name typeref:typename:int
color_map_1 minilibx-linux/test/main.c /^int color_map_1(void *win,int w,int h)$/;" f typeref:typename:int
color_map_2 minilibx-linux/test/main.c /^int color_map_2(unsigned char *data,int bpp,int sl,int w,int h,int endian, int type)$/;" f typeref:typename:int
@@ -336,7 +336,7 @@ data3 minilibx-linux/test/main.c /^char *data3;$/;" v typeref:typename:char *
data4 minilibx-linux/test/main.c /^char *data4;$/;" v typeref:typename:char *
decrgb minilibx-linux/mlx_int.h /^ int decrgb[6];$/;" m struct:s_xvar typeref:typename:int[6]
depth minilibx-linux/mlx_int.h /^ int depth;$/;" m struct:s_xvar typeref:typename:int
diff miniRT.h /^ float diff;$/;" m struct:s_calc typeref:typename:float
diff miniRT.h /^ float diff;$/;" m struct:s_calc typeref:typename:float
dir miniRT.h /^ t_vec3 dir;$/;" m struct:s_ray typeref:typename:t_vec3
disc miniRT.h /^ float disc;$/;" m struct:s_calc typeref:typename:float
display minilibx-linux/mlx_int.h /^ Display *display;$/;" m struct:s_xvar typeref:typename:Display *
@@ -424,10 +424,10 @@ gnl_ft_strchr libft/gnl_utils.c /^char *gnl_ft_strchr(char *s, int c)$/;" f type
gnl_ft_strjoin libft/gnl_utils.c /^char *gnl_ft_strjoin(char *s1, char *s2)$/;" f typeref:typename:char *
gnl_ft_strlen libft/gnl_utils.c /^size_t gnl_ft_strlen(char *s)$/;" f typeref:typename:size_t
gnl_read_fd libft/gnl.c /^char *gnl_read_fd(int fd, char *str)$/;" f typeref:typename:char *
half_dir miniRT.h /^ t_vec3 half_dir;$/;" m struct:s_calc typeref:typename:t_vec3
half_dir miniRT.h /^ t_vec3 half_dir;$/;" m struct:s_calc typeref:typename:t_vec3
height miniRT.h /^ float height;$/;" m struct:s_cylinder typeref:typename:float
height minilibx-linux/mlx_int.h /^ int height;$/;" m struct:s_img typeref:typename:int
hitPoint miniRT.h /^ t_vec3 hitPoint;$/;" m struct:s_calc typeref:typename:t_vec3
hit_point miniRT.h /^ t_vec3 hit_point;$/;" m struct:s_calc typeref:typename:t_vec3
hook minilibx-linux/mlx_int.h /^ int (*hook)();$/;" m struct:s_event_list typeref:typename:int (*)()
hooks minilibx-linux/mlx_int.h /^ t_event_list hooks[MLX_MAX_EVENT];$/;" m struct:s_win_list typeref:typename:t_event_list[]
i libft/libft.h /^ size_t i;$/;" m struct:s_info typeref:typename:size_t
@@ -463,9 +463,9 @@ key_w miniRT.h /^ int key_w;$/;" m struct:s_app typeref:typename:int
key_win1 minilibx-linux/test/main.c /^int key_win1(int key,void *p)$/;" f typeref:typename:int
key_win2 minilibx-linux/test/main.c /^int key_win2(int key,void *p)$/;" f typeref:typename:int
key_win3 minilibx-linux/test/main.c /^int key_win3(int key,void *p)$/;" f typeref:typename:int
l miniRT.h /^ t_vec3 l;$/;" m struct:s_calc typeref:typename:t_vec3
l miniRT.h /^ t_vec3 l;$/;" m struct:s_calc typeref:typename:t_vec3
len_word libft/ft_split.c /^static size_t len_word(char *s, char c, size_t start)$/;" f typeref:typename:size_t file:
light miniRT.h /^ t_light light;$/;" m struct:s_calc typeref:typename:t_light
light miniRT.h /^ t_light light;$/;" m struct:s_calc typeref:typename:t_light
lights miniRT.h /^ t_light lights[MAX_LIGHTS];$/;" m struct:s_scene typeref:typename:t_light[]
line_if_exit miniRT.h /^ char *line_if_exit;$/;" m struct:s_scene typeref:typename:char *
load_config config.c /^t_scene load_config(const char *filename)$/;" f typeref:typename:t_scene
@@ -569,9 +569,9 @@ name minilibx-linux/mlx_int.h /^ int name;$/;" m struct:s_xpm_col typeref:typen
ndc_x miniRT.h /^ float ndc_x;$/;" m struct:s_calc typeref:typename:float
ndc_y miniRT.h /^ float ndc_y;$/;" m struct:s_calc typeref:typename:float
next minilibx-linux/mlx_int.h /^ struct s_win_list *next;$/;" m struct:s_win_list typeref:struct:s_win_list *
normal miniRT.h /^ t_vec3 normal;$/;" m struct:s_hit typeref:typename:t_vec3
normal miniRT.h /^ t_vec3 normal;$/;" m struct:s_hit_info typeref:typename:t_vec3
normal miniRT.h /^ t_vec3 normal;$/;" m struct:s_plane typeref:typename:t_vec3
normal miniRT.h /^ t_vec3 normal;$/;" m struct:s_hit typeref:typename:t_vec3
normal miniRT.h /^ t_vec3 normal;$/;" m struct:s_hit_info typeref:typename:t_vec3
num_ambient miniRT.h /^ int num_ambient;$/;" m struct:s_scene typeref:typename:int
num_camera miniRT.h /^ int num_camera;$/;" m struct:s_scene typeref:typename:int
num_cylinders miniRT.h /^ int num_cylinders;$/;" m struct:s_scene typeref:typename:int
@@ -596,12 +596,12 @@ parsing_line config.c /^static inline t_scene parsing_line(char *line, t_scene s
parsing_plane parsing_plane.c /^t_scene parsing_plane(t_scene scene)$/;" f typeref:typename:t_scene
parsing_sphere parsing_sphere.c /^t_scene parsing_sphere(t_scene scene)$/;" f typeref:typename:t_scene
partie_entiere libft/ft_strtod.c /^static int partie_entiere(double *entier, char *string, int i, double *sign)$/;" f typeref:typename:int file:
pitch miniRT.h /^ float pitch; \/\/ vue de haut en bas en radians$/;" m struct:s_camera typeref:typename:float
pitch miniRT.h /^ float pitch;$/;" m struct:s_camera typeref:typename:float
pix minilibx-linux/mlx_int.h /^ Pixmap pix;$/;" m struct:s_img typeref:typename:Pixmap
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_hit_info typeref:typename:t_vec3
point miniRT.h /^ t_vec3 point;$/;" m struct:s_plane typeref:typename:t_vec3
point miniRT.h /^ t_vec3 point;$/;" m struct:s_hit_info typeref:typename:t_vec3
pos miniRT.h /^ t_vec3 pos;$/;" m struct:s_light typeref:typename:t_vec3
print_cylinder print_next.c /^void print_cylinder(t_cylinder cyl)$/;" f typeref:typename:void
print_plane print_next.c /^void print_plane(t_plane plane)$/;" f typeref:typename:void
@@ -614,8 +614,8 @@ proj miniRT.h /^ float proj;$/;" m struct:s_calc typeref:typename:float
pshm_format minilibx-linux/mlx_int.h /^ int pshm_format;$/;" m struct:s_xvar typeref:typename:int
putnbr_b libft/printf_fd.c /^static int putnbr_b(t_lu n, char *str, int numdig, t_info *info)$/;" f typeref:typename:int file:
putstr libft/printf_fd.c /^static int putstr(char *str, char c, int is_char, t_info *info)$/;" f typeref:typename:int file:
radius miniRT.h /^ float radius;$/;" m struct:s_cylinder typeref:typename:float
radius miniRT.h /^ float radius;$/;" m struct:s_sphere typeref:typename:float
radius miniRT.h /^ float radius; \/\/ Demi-diamètre$/;" m struct:s_cylinder typeref:typename:float
range_is_ok parsing_color.c /^static inline int range_is_ok(char **token_color)$/;" f typeref:typename:int file:
range_is_ok parsing_vector.c /^static inline int range_is_ok(char **token_vector)$/;" f typeref:typename:int file:
ratio miniRT.h /^ float ratio;$/;" m struct:s_ambient typeref:typename:float
@@ -639,7 +639,7 @@ s_col_name minilibx-linux/mlx_int.h /^struct s_col_name$/;" s
s_cylinder miniRT.h /^typedef struct s_cylinder$/;" s
s_event_list minilibx-linux/mlx_int.h /^typedef struct s_event_list$/;" s
s_hit miniRT.h /^typedef struct s_hit$/;" s
s_hit_info miniRT.h /^typedef struct s_hit_info {$/;" s
s_hit_info miniRT.h /^typedef struct s_hit_info$/;" s
s_img minilibx-linux/mlx_int.h /^typedef struct s_img$/;" s
s_info libft/libft.h /^struct s_info$/;" s
s_light miniRT.h /^typedef struct s_light$/;" s
@@ -671,12 +671,12 @@ sl1 minilibx-linux/test/main.c /^int sl1;$/;" v typeref:typename:int
sl2 minilibx-linux/test/main.c /^int sl2;$/;" v typeref:typename:int
sl3 minilibx-linux/test/main.c /^int sl3;$/;" v typeref:typename:int
sl4 minilibx-linux/test/main.c /^int sl4;$/;" v typeref:typename:int
spec miniRT.h /^ float spec;$/;" m struct:s_calc typeref:typename:float
spec miniRT.h /^ float spec;$/;" m struct:s_calc typeref:typename:float
spheres miniRT.h /^ t_sphere spheres[MAX_SPHERES];$/;" m struct:s_scene typeref:typename:t_sphere[]
sqrtDisc miniRT.h /^ float sqrtDisc;$/;" m struct:s_calc typeref:typename:float
sqrt_disc miniRT.h /^ float sqrt_disc;$/;" m struct:s_calc typeref:typename:float
strlcpy_is_not_posix minilibx-linux/mlx_xpm.c /^unsigned int strlcpy_is_not_posix(char *dest, char *src, unsigned int size)$/;" f typeref:typename:unsigned int
t miniRT.h /^ float t;$/;" m struct:s_calc typeref:typename:float
t miniRT.h /^ float t;$/;" m struct:s_hit typeref:typename:float
t miniRT.h /^ float t;$/;" m struct:s_hit typeref:typename:float
t0 miniRT.h /^ float t0;$/;" m struct:s_calc typeref:typename:float
t1 miniRT.h /^ float t1;$/;" m struct:s_calc typeref:typename:float
t_ambient miniRT.h /^} t_ambient;$/;" t typeref:struct:s_ambient
@@ -689,7 +689,7 @@ t_cylinder miniRT.h /^} t_cylinder;$/;" t typeref:struct:s_cylinder
t_event_list minilibx-linux/mlx_int.h /^} t_event_list;$/;" t typeref:struct:s_event_list
t_final miniRT.h /^ float t_final;$/;" m struct:s_calc typeref:typename:float
t_hit miniRT.h /^} t_hit;$/;" t typeref:struct:s_hit
t_hit_info miniRT.h /^} t_hit_info;$/;" t typeref:struct:s_hit_info
t_hit_info miniRT.h /^} t_hit_info;$/;" t typeref:struct:s_hit_info
t_img minilibx-linux/mlx_int.h /^} t_img;$/;" t typeref:struct:s_img
t_info libft/libft.h /^typedef struct s_info t_info;$/;" t typeref:struct:s_info
t_light miniRT.h /^} t_light;$/;" t typeref:struct:s_light
@@ -725,7 +725,7 @@ vec3_mul calcul_de_vecteur2.c /^t_vec3 vec3_mul(t_vec3 a, t_vec3 b)$/;" f typere
vec3_normalize calcul_de_vecteur2.c /^t_vec3 vec3_normalize(t_vec3 a)$/;" f typeref:typename:t_vec3
vec3_scale calcul_de_vecteur.c /^t_vec3 vec3_scale(t_vec3 a, float s)$/;" f typeref:typename:t_vec3
vec3_sub calcul_de_vecteur.c /^t_vec3 vec3_sub(t_vec3 a, t_vec3 b)$/;" f typeref:typename:t_vec3
view_dir miniRT.h /^ t_vec3 view_dir;$/;" m struct:s_calc typeref:typename:t_vec3
view_dir miniRT.h /^ t_vec3 view_dir;$/;" m struct:s_calc typeref:typename:t_vec3
visual minilibx-linux/mlx_int.h /^ Visual *visual;$/;" m struct:s_xvar typeref:typename:Visual *
width minilibx-linux/mlx_int.h /^ int width;$/;" m struct:s_img typeref:typename:int
win miniRT.h /^ void *win;$/;" m struct:s_app typeref:typename:void *
@@ -746,5 +746,5 @@ xpm1_x minilibx-linux/test/main.c /^int xpm1_x;$/;" v typeref:typename:int
xpm1_y minilibx-linux/test/main.c /^int xpm1_y;$/;" v typeref:typename:int
y miniRT.h /^ float y;$/;" m struct:s_calc typeref:typename:float
y miniRT.h /^ float y;$/;" m struct:s_vec3 typeref:typename:float
yaw miniRT.h /^ float yaw; \/\/ vue de gauche a droite$/;" m struct:s_camera typeref:typename:float
yaw miniRT.h /^ float yaw;$/;" m struct:s_camera typeref:typename:float
z miniRT.h /^ float z;$/;" m struct:s_vec3 typeref:typename:float
+2 -2
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/17 19:07:07 by yantoine #+# #+# */
/* Updated: 2025/02/19 16:52:23 by yantoine ### ########.fr */
/* Updated: 2025/02/19 16:59:53 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -36,7 +36,7 @@ static t_vec3 calc_light_contribution(t_hit_info hit, t_light light,
if (is_in_shadow(hit.point, light.pos, scene))
return ((t_vec3){0, 0, 0});
diff = fmaxf(0.0f, vec3_dot(hit.normal, l));
view_dir = vec3_normalize(vec3_sub(camera.camPos, hit.point));
view_dir = vec3_normalize(vec3_sub(camera.cam_pos, hit.point));
half_dir = vec3_normalize(vec3_add(l, view_dir));
spec = powf(fmaxf(0.0f, vec3_dot(hit.normal, half_dir)), 32.0f);
return (vec3_add(vec3_scale(vec3_mul(hit.color, \
+12 -12
View File
@@ -6,7 +6,7 @@
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/02/17 19:27:23 by yantoine #+# #+# */
/* Updated: 2025/02/17 23:36:33 by yantoine ### ########.fr */
/* Updated: 2025/02/19 17:02:04 by yantoine ### ########.fr */
/* */
/* ************************************************************************** */
@@ -26,35 +26,35 @@ static void update_camera_rotation(t_app *app)
app->scene.camera.pitch = 1.57f - 0.01f;
if (app->scene.camera.pitch < -1.57f + 0.01f)
app->scene.camera.pitch = -1.57f + 0.01f;
app->scene.camera.camDir.x = cosf(app->scene.camera.pitch)
app->scene.camera.cam_dir.x = cosf(app->scene.camera.pitch)
* sinf(app->scene.camera.yaw);
app->scene.camera.camDir.y = sinf(app->scene.camera.pitch);
app->scene.camera.camDir.z = -cosf(app->scene.camera.pitch)
app->scene.camera.cam_dir.y = sinf(app->scene.camera.pitch);
app->scene.camera.cam_dir.z = -cosf(app->scene.camera.pitch)
* cosf(app->scene.camera.yaw);
app->scene.camera.camDir = vec3_normalize(app->scene.camera.camDir);
app->scene.camera.cam_dir = vec3_normalize(app->scene.camera.cam_dir);
app->scene.camera.right = (t_vec3){cosf(app->scene.camera.yaw), 0,
sinf(app->scene.camera.yaw)};
app->scene.camera.right = vec3_normalize(app->scene.camera.right);
app->scene.camera.up = vec3_normalize(vec3_cross(app->scene.camera.right,
app->scene.camera.camDir));
app->scene.camera.cam_dir));
}
static void update_camera_movement(t_app *app)
{
if (app->key_w)
app->scene.camera.camPos = vec3_add(app->scene.camera.camPos,
vec3_scale(app->scene.camera.camDir,
app->scene.camera.cam_pos = vec3_add(app->scene.camera.cam_pos,
vec3_scale(app->scene.camera.cam_dir,
app->scene.camera.move_speed));
if (app->key_s)
app->scene.camera.camPos = vec3_sub(app->scene.camera.camPos,
vec3_scale(app->scene.camera.camDir,
app->scene.camera.cam_pos = vec3_sub(app->scene.camera.cam_pos,
vec3_scale(app->scene.camera.cam_dir,
app->scene.camera.move_speed));
if (app->key_a)
app->scene.camera.camPos = vec3_sub(app->scene.camera.camPos,
app->scene.camera.cam_pos = vec3_sub(app->scene.camera.cam_pos,
vec3_scale(app->scene.camera.right,
app->scene.camera.move_speed));
if (app->key_d)
app->scene.camera.camPos = vec3_add(app->scene.camera.camPos,
app->scene.camera.cam_pos = vec3_add(app->scene.camera.cam_pos,
vec3_scale(app->scene.camera.right,
app->scene.camera.move_speed));
}