update parsing ambient
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/14 18:28:42 by yantoine #+# #+# */
|
/* Created: 2025/02/14 18:28:42 by yantoine #+# #+# */
|
||||||
/* Updated: 2025/02/14 18:51:17 by yantoine ### ########.fr */
|
/* Updated: 2025/02/14 20:15:29 by yantoine ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -17,9 +17,9 @@ inline int check_tokens(char **tokens, int expected)
|
|||||||
return (tokens && ft_arraylen(tokens) == expected);
|
return (tokens && ft_arraylen(tokens) == expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void check_if_max(t_scene scene, const int lower_than)
|
inline void check_if_max(t_scene scene, const int to_test, const int max)
|
||||||
{
|
{
|
||||||
if (scene.numAmbient >= lower_than)
|
if (to_test >= max)
|
||||||
{
|
{
|
||||||
printf("error:\n");
|
printf("error:\n");
|
||||||
close(scene.fd_if_exit);
|
close(scene.fd_if_exit);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/13 20:02:36 by yantoine #+# #+# */
|
/* Created: 2025/02/13 20:02:36 by yantoine #+# #+# */
|
||||||
/* Updated: 2025/02/14 18:49:30 by yantoine ### ########.fr */
|
/* Updated: 2025/02/14 20:45:21 by yantoine ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -126,8 +126,12 @@ t_scene parsing_light(const char *line, t_scene scene);
|
|||||||
t_scene parsing_sphere(const char *line, t_scene scene);
|
t_scene parsing_sphere(const char *line, t_scene scene);
|
||||||
t_scene parsing_plane(const char *line, t_scene scene);
|
t_scene parsing_plane(const char *line, t_scene scene);
|
||||||
t_scene parsing_cylindre(const char *line, t_scene scene);
|
t_scene parsing_cylindre(const char *line, t_scene scene);
|
||||||
|
t_color parse_color(const char *token, t_scene scene);
|
||||||
|
|
||||||
|
// Parsing utils
|
||||||
|
inline char **get_tokens_secure(t_scene scene, const int numObject, const int numObjectMax, const int supposed_nb_token);
|
||||||
|
|
||||||
// Check
|
// Check
|
||||||
inline int check_tokens(char **tokens, int expected)
|
inline int check_tokens(char **tokens, const int to_test, int expected);
|
||||||
inline void check_if_max(t_scene scene, const int lower_than);
|
inline void check_if_max(t_scene scene, const int to_test, const int max);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+3
-12
@@ -6,7 +6,7 @@
|
|||||||
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/14 18:04:39 by yantoine #+# #+# */
|
/* Created: 2025/02/14 18:04:39 by yantoine #+# #+# */
|
||||||
/* Updated: 2025/02/14 18:56:00 by yantoine ### ########.fr */
|
/* Updated: 2025/02/14 20:52:08 by yantoine ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -15,19 +15,10 @@
|
|||||||
|
|
||||||
t_scene parsing_ambiant(const char *line, t_scene scene)
|
t_scene parsing_ambiant(const char *line, t_scene scene)
|
||||||
{
|
{
|
||||||
const int result_if_max = check_if_max(scene, MAX_AMBIENT);
|
const char **tokens = get_tokens_secure(scene, scene.numAmbient, MAX_AMBIENT, 3);
|
||||||
const char **tokens = ft_split(line, ' ');
|
|
||||||
const int result_check_tokens = check_tokens(tokens, 3);
|
|
||||||
|
|
||||||
if (!result_check_tokens)
|
|
||||||
{
|
|
||||||
ft_free_array(tokens);
|
|
||||||
ft_putendl_fd("error", 2);
|
|
||||||
close(scene.fd);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
scene.ambient.ambient_ratio = ft_atof(tokens[1]);
|
scene.ambient.ambient_ratio = ft_atof(tokens[1]);
|
||||||
scene.ambient.ambient_color = parse_color(tokens[2], scene);
|
scene.ambient.ambient_color = parse_color(tokens[2], scene);
|
||||||
ft_free_array(tokens);
|
ft_free_array(tokens);
|
||||||
|
scene.numAmbient++;
|
||||||
return (scene);
|
return (scene);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* parsing_camera.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/02/14 20:02:29 by yantoine #+# #+# */
|
||||||
|
/* Updated: 2025/02/14 20:03:25 by yantoine ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "miniRT.h"
|
||||||
|
|
||||||
|
t_scene parsing_camera(const char *line, t_scene scene)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* parsing_color.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/02/14 20:05:49 by yantoine #+# #+# */
|
||||||
|
/* Updated: 2025/02/14 20:25:45 by yantoine ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "miniRT.h"
|
||||||
|
|
||||||
|
t_color parse_color(const char *token, t_scene scene)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* parsing_utils.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: yantoine <yantoine@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/02/14 20:23:21 by yantoine #+# #+# */
|
||||||
|
/* Updated: 2025/02/14 20:48:49 by yantoine ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "miniRT.h"
|
||||||
|
|
||||||
|
|
||||||
|
inline char **get_tokens_secure(t_scene scene, const int numObject, const int numObjectMax, const int supposed_nb_token)
|
||||||
|
{
|
||||||
|
const int result_if_max = check_if_max(scene, numObject, numObjectMax);
|
||||||
|
const char **tokens = ft_split(scene.line_if_exit, ' ');
|
||||||
|
const int result_check_tokens = check_tokens(tokens, supposed_nb_token);
|
||||||
|
|
||||||
|
if (!result_check_tokens)
|
||||||
|
{
|
||||||
|
ft_free_array(tokens);
|
||||||
|
ft_putendl_fd("error", 2);
|
||||||
|
free(scene.line_if_exit);
|
||||||
|
close(scene.fd);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
return (tokens);
|
||||||
|
}
|
||||||
@@ -91,7 +91,7 @@ camPos miniRT.h /^ t_vec3 camPos;$/;" m struct:s_camera typeref:typename:t_vec3
|
|||||||
camPos raytracer_formatted.c /^t_vec3 camPos = {0.0f, 0.0f, 0.0f};$/;" v typeref:typename:t_vec3
|
camPos raytracer_formatted.c /^t_vec3 camPos = {0.0f, 0.0f, 0.0f};$/;" v typeref:typename:t_vec3
|
||||||
center miniRT.h /^ t_vec3 center;$/;" m struct:s_cylinder typeref:typename:t_vec3
|
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
|
center miniRT.h /^ t_vec3 center;$/;" m struct:s_sphere typeref:typename:t_vec3
|
||||||
check_if_max check.c /^inline void check_if_max(t_scene scene, const int lower_than)$/;" f typeref:typename:void
|
check_if_max check.c /^inline void check_if_max(t_scene scene, const int to_test, const int max)$/;" f typeref:typename:void
|
||||||
check_tokens check.c /^inline int check_tokens(char **tokens, int expected)$/;" f typeref:typename:int
|
check_tokens check.c /^inline int check_tokens(char **tokens, int expected)$/;" f typeref:typename:int
|
||||||
color miniRT.h /^ t_vec3 color;$/;" m struct:s_cylinder 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_light typeref:typename:t_vec3
|
color miniRT.h /^ t_vec3 color;$/;" m struct:s_light typeref:typename:t_vec3
|
||||||
@@ -102,6 +102,7 @@ cylinders miniRT.h /^ t_cylinder cylinders[MAX_CYLINDERS];$/;" m struct:s_scene
|
|||||||
dir miniRT.h /^ t_vec3 dir;$/;" m struct:s_ray typeref:typename:t_vec3
|
dir miniRT.h /^ t_vec3 dir;$/;" m struct:s_ray typeref:typename:t_vec3
|
||||||
fov miniRT.h /^ float fov;$/;" m struct:s_camera typeref:typename:float
|
fov miniRT.h /^ float fov;$/;" m struct:s_camera typeref:typename:float
|
||||||
fov raytracer_formatted.c /^float fov = 90.0f;$/;" v typeref:typename:float
|
fov raytracer_formatted.c /^float fov = 90.0f;$/;" v typeref:typename:float
|
||||||
|
get_tokens_secure parsing_utils.c /^inline char **get_tokens_secure(t_scene scene, const int numObject, const int numObjectMax, cons/;" f typeref:typename:char **
|
||||||
height miniRT.h /^ float height;$/;" m struct:s_cylinder typeref:typename:float
|
height miniRT.h /^ float height;$/;" m struct:s_cylinder typeref:typename:float
|
||||||
intersectCylinder raytracer_formatted.c /^float intersectCylinder(Ray ray, Cylinder cy, t_vec3 *hitNormal)$/;" f typeref:typename:float
|
intersectCylinder raytracer_formatted.c /^float intersectCylinder(Ray ray, Cylinder cy, t_vec3 *hitNormal)$/;" f typeref:typename:float
|
||||||
intersectPlane raytracer_formatted.c /^float intersectPlane(Ray ray, Plane p, t_vec3 *hitNormal)$/;" f typeref:typename:float
|
intersectPlane raytracer_formatted.c /^float intersectPlane(Ray ray, Plane p, t_vec3 *hitNormal)$/;" f typeref:typename:float
|
||||||
@@ -119,7 +120,9 @@ numLights miniRT.h /^ int numLights;$/;" m struct:s_scene typeref:typename:int
|
|||||||
numPlanes miniRT.h /^ int numPlanes;$/;" m struct:s_scene typeref:typename:int
|
numPlanes miniRT.h /^ int numPlanes;$/;" m struct:s_scene typeref:typename:int
|
||||||
numSpheres miniRT.h /^ int numSpheres;$/;" m struct:s_scene typeref:typename:int
|
numSpheres miniRT.h /^ int numSpheres;$/;" m struct:s_scene typeref:typename:int
|
||||||
origin miniRT.h /^ t_vec3 origin;$/;" m struct:s_ray typeref:typename:t_vec3
|
origin miniRT.h /^ t_vec3 origin;$/;" m struct:s_ray typeref:typename:t_vec3
|
||||||
|
parse_color parsing_color.c /^t_color parse_color(const char *token, t_scene scene)$/;" f typeref:typename:t_color
|
||||||
parsing_ambiant parsing_ambiant.c /^t_scene parsing_ambiant(const char *line, t_scene scene)$/;" f typeref:typename:t_scene
|
parsing_ambiant parsing_ambiant.c /^t_scene parsing_ambiant(const char *line, t_scene scene)$/;" f typeref:typename:t_scene
|
||||||
|
parsing_camera parsing_camera.c /^t_scene parsing_camera(const char *line, t_scene scene)$/;" f typeref:typename:t_scene
|
||||||
parsing_line config.c /^static inline t_scene parsing_line(const char *line, t_scene scene)$/;" f typeref:typename:t_scene file:
|
parsing_line config.c /^static inline t_scene parsing_line(const char *line, t_scene scene)$/;" f typeref:typename:t_scene 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; \/\/ vue de haut en bas en radians$/;" m struct:s_camera typeref:typename:float
|
||||||
pitch raytracer_formatted.c /^float pitch = 0.0f; \/\/ vue de haut en bas en radians$/;" v typeref:typename:float
|
pitch raytracer_formatted.c /^float pitch = 0.0f; \/\/ vue de haut en bas en radians$/;" v typeref:typename:float
|
||||||
|
|||||||
Reference in New Issue
Block a user