diff --git a/builds/fdf.o b/builds/fdf.o index 1d658db..3a333a5 100644 Binary files a/builds/fdf.o and b/builds/fdf.o differ diff --git a/fdf b/fdf index fcc8a96..fcf38b3 100755 Binary files a/fdf and b/fdf differ diff --git a/includes/fdf.h b/includes/fdf.h index 9e26421..02abddd 100644 --- a/includes/fdf.h +++ b/includes/fdf.h @@ -47,6 +47,7 @@ typedef struct s_fdf int **map; int offset; int margin; + int altitude; int win_size_x; int win_size_y; int img_size_x; diff --git a/srcs/fdf.c b/srcs/fdf.c index ae2a574..78f1155 100644 --- a/srcs/fdf.c +++ b/srcs/fdf.c @@ -14,10 +14,12 @@ void color_altitude_pixel(t_fdf *fdf, int new_x, int new_y, int z) int color; color = 0xffffff; + z = z / fdf->altitude; if (z) { - color = color ^ (((0xff * z) / fdf->max_z) << 8 ); - color = color ^ ((0xff * z) / fdf->max_z); + color = color ^ (((0xff / fdf->max_z) * z) << 8 ); + color = color ^ ((0xff / fdf->max_z) * z); + ft_printf("0xff:%i z:%i (0xff / max_z):%i ((0xff / max_z) * z):%i\n", 0xff, z, (0xff / fdf->max_z), ((0xff / fdf->max_z) * z)); } draw_pixel(fdf, new_x, new_y, color); } @@ -46,7 +48,7 @@ void draw_image(t_fdf *fdf) x = i * fdf->offset - (fdf->map_size_x / 2); y = j * fdf->offset - (fdf->map_size_y / 2); - z = fdf->map[j][i]; + z = fdf->map[j][i] * fdf->altitude; new_x = x * cos(fdf->rad_x) + y * sin(fdf->rad_x); new_y = y * cos(fdf->rad_x) - x * sin(fdf->rad_x); new_y = new_y * cos(fdf->rad_y) - -z * sin(fdf->rad_y); @@ -148,9 +150,10 @@ t_fdf *init_fdf(void) t_fdf *fdf; fdf = malloc(sizeof(t_fdf)); - // map offset and margin - fdf->offset = 10; + // map offset, margin, and altitude factor + fdf->offset = 50; fdf->margin = 50; + fdf->altitude = 3; // parse map fdf->map = parse_map(fdf); // size window