/* ************************************************************************** */ /* */ /* ::: 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 # include "libft.h" # include "MLX42.h" # define SUCCESS 1 # define FAILURE 0 # define WRONG_LINE_LENGTH "Error: wrong line length.\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 500 # define HEIGHT 500 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 *orig; t_point_3d *rot; t_point_2d *proj; int width; int height; int z_max; } t_map; typedef struct s_fdf { t_map *map; mlx_t *mlx; mlx_image_t *img; mlx_image_t *menu; double angle_x; double angle_y; double angle_z; double animate_z; double zoom; int offset_x; int offset_y; int last_width; int last_height; double z_scale; } t_fdf; int interpolate_color(t_point_2d start, t_point_2d end, t_point_2d current); int get_color(char *str); int get_map_sizes(char *filename, t_map *map); void free_line_and_split(char **line, char ***split); int read_map(char *filename, t_fdf *fdf); int parse_map(char *filename, t_fdf *fdf); void print_map(t_map *map); void copy_map(t_fdf *fdf); void fdf_apply_rotation(t_fdf *fdf); void handle_error(t_fdf *fdf, char *error); 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 resize_hook(int width, int height, void *param); 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 project_isometric(t_fdf *fdf); double deg2rad(double deg); t_fdf *initialise_fdf(void); bool clean_fdf(t_fdf *fdf); void get_z_max(t_fdf *fdf); int init_mlx(t_fdf *fdf); void set_map_point(t_fdf *fdf, int x, int y, char **str); mlx_image_t *draw_menu(t_fdf *fdf); int get_z_color(double z, int z_max); #endif // FdF by whaffman // ============================ // [?] Help menu // [a] / [d] Rotate around Z-axis // [w] / [s] Rotate around X-axis // [q] / [e] Rotate around Y-axis // [z] / [x] Change Z-scale // [=] / [-] Change Zoom // [UP] / [DOWN] Change X-offset // [LEFT] / [RIGHT] Change Y-offset // [[] / []] Change animation speed // [c] Change colormode // [p] Change projection mode // [ESC] Close window // ============================