/* ************************************************************************** */ /* */ /* ::: o_ :::::: ::: */ /* fdf.h :+: / :+::+: :+: */ /* +:+ > +:++:+ +:+ */ /* By: whaffman +#+ +:+ +#++#++:++#++ */ /* +#+ +#+#+ +#++#+ +#+ \o/ */ /* Created: 2024/12/06 11:07:39 by whaffman #+#+# #+#+# #+# #+# | */ /* Updated: 2024/12/06 11:11:56 by whaffman ### ### ### ### / \ */ /* */ /* ************************************************************************** */ #ifndef FDF_H # define FDF_H # include # include # include # include # include # include # include "libft.h" # include "MLX42.h" # define SUCCESS 1 # define FAILURE 0 # define WRONG_LINE_LENGTH "Error: wrong line length. \ Expected %d, got %d in line nr %d\n" # define MALLOC_ERROR "Error: malloc failed\n" # define FILE_ERROR "Error: could not open file %s\n" # define USAGE_ERROR "Usage: %s \n" #ifndef M_PI #define M_PI 3.14159265358979323846 #endif # define SQRT2 1.41421356237309514547 # define SQRT6 2.44948974278317788134 # define WIDTH 2000 # define HEIGHT 1500 typedef struct s_point_3d { double x; double y; double z; int color; } t_point_3d; typedef struct s_point_2d { int x; int y; int color; } t_point_2d; typedef struct s_map { t_point_3d *points; t_point_2d *projected; int width; int height; int z_max; } t_map; typedef struct s_fdf { t_map *map; mlx_t *mlx; mlx_image_t *img; double angle_x; double angle_y; double angle_z; double zoom; int offset_x; int offset_y; double z_scale; } t_fdf; int get_map_sizes(char *filename, t_map *map); void free_line_and_split(char **line, char ***split); int read_map(char *filename, t_map *map); int parse_map(char *filename, t_fdf *fdf); void print_map(t_map *map); void rotate_x(t_point_3d **points, double angle, int size); void rotate_y(t_point_3d **points, double angle, int size); void rotate_z(t_point_3d **points, double angle, int size); bool fdf_put_pixel(mlx_image_t *img, t_point_2d point); void fdf_draw_line(mlx_image_t *img, t_point_2d start, t_point_2d end); int fdf_hooks(t_fdf *fdf); void draw_hook(void *param); void key_hook(mlx_key_data_t keydata, void *param); void fdf_set_background(mlx_image_t *img, int color); void fdf_project_isometric(t_map *map); double deg2rad(double deg); #endif