92 lines
2.5 KiB
C
92 lines
2.5 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: o_ :::::: ::: */
|
|
/* fdf.h :+: / :+::+: :+: */
|
|
/* +:+ > +:++:+ +:+ */
|
|
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
|
|
/* +#+ +#+#+ +#++#+ +#+ \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 <stdlib.h>
|
|
# include <unistd.h>
|
|
# include <fcntl.h>
|
|
# include <stdbool.h>
|
|
# include <math.h>
|
|
# include <stdio.h>
|
|
# include "libft.h"
|
|
# include "MLX42.h"
|
|
|
|
# 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 <filename>\n"
|
|
|
|
#ifndef M_PI
|
|
#define M_PI 3.14159265358979323846
|
|
#endif
|
|
# define SQRT2 1.41421356237309514547
|
|
# define SQRT6 2.44948974278317788134
|
|
|
|
# define WIDTH 1024
|
|
# define HEIGHT 640
|
|
|
|
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);
|
|
t_map *parse_map(char *filename);
|
|
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);
|
|
|
|
#endif
|