added finner z modification

This commit is contained in:
asus
2024-01-09 16:29:26 +01:00
parent 3c0a459b64
commit dcdf16d4e7
12 changed files with 15 additions and 3 deletions
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+5
View File
@@ -68,6 +68,11 @@ int is_color(char *color);
void size_map(t_fdf *fdf, char *raw, int height); void size_map(t_fdf *fdf, char *raw, int height);
int **parse_map(t_fdf *fdf, int fd); int **parse_map(t_fdf *fdf, int fd);
// steps size for the hight transform with p and o
// must be > 0
// 100 is small, 1 is the biggest
# define Z_HIGHT 10
# define ESCAPE 65307 # define ESCAPE 65307
# define UP 65362 # define UP 65362
# define DOWN 65364 # define DOWN 65364
+2 -1
View File
@@ -75,7 +75,8 @@ void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z)
color = 0xffffff; color = 0xffffff;
z -= (z * fdf->zoom) / fdf->offset; z -= (z * fdf->zoom) / fdf->offset;
z /= fdf->altitude; if (z > 0)
z /= fdf->altitude;
if (z > fdf->min_z && fdf->z_amplitude) if (z > fdf->min_z && fdf->z_amplitude)
{ {
color = color ^ (((0xff / fdf->z_amplitude) * (z - fdf->min_z)) << 16); color = color ^ (((0xff / fdf->z_amplitude) * (z - fdf->min_z)) << 16);
+1 -1
View File
@@ -30,7 +30,7 @@ void keypress_more(int keycode, t_fdf *fdf)
else if (keycode == O) else if (keycode == O)
fdf->altitude++; fdf->altitude++;
else if (keycode == P) else if (keycode == P)
if (fdf->altitude > 1) if (fdf->altitude > 0)
fdf->altitude--; fdf->altitude--;
} }
+7 -1
View File
@@ -28,8 +28,14 @@ int *new_coordinates(t_fdf *fdf, int i, int j)
y = j * (fdf->offset + fdf->zoom); y = j * (fdf->offset + fdf->zoom);
x -= (fdf->map_size_x + fdf->zoom * fdf->map_width) / 2; x -= (fdf->map_size_x + fdf->zoom * fdf->map_width) / 2;
y -= (fdf->map_size_y + fdf->zoom * fdf->map_height) / 2; y -= (fdf->map_size_y + fdf->zoom * fdf->map_height) / 2;
z = fdf->map[j][i] * fdf->altitude; if (fdf->altitude > 0)
z = fdf->map[j][i] * fdf->altitude;
else if (fdf->altitude == 0)
z = 0;
else
z = fdf->map[j][i];
z += (z * fdf->zoom) / fdf->offset; z += (z * fdf->zoom) / fdf->offset;
z /= Z_HIGHT;
point[0] = x * cos(fdf->rad_x) + y * sin(fdf->rad_x); point[0] = x * cos(fdf->rad_x) + y * sin(fdf->rad_x);
point[1] = y * cos(fdf->rad_x) - x * sin(fdf->rad_x); point[1] = y * cos(fdf->rad_x) - x * sin(fdf->rad_x);
point[1] = point[1] * cos(fdf->rad_y) - -z * sin(fdf->rad_y); point[1] = point[1] * cos(fdf->rad_y) - -z * sin(fdf->rad_y);