zoom fonctionne meme en z

This commit is contained in:
hugogogo
2021-07-23 15:27:22 +02:00
parent b9f02a20f3
commit 04ad40b58d
5 changed files with 3 additions and 2 deletions

Binary file not shown.

Binary file not shown.

BIN
fdf

Binary file not shown.

View File

@@ -7,7 +7,6 @@ void draw_image(t_fdf *fdf)
fdf->rad_x = fdf->rot_x * M_PI / 180;
fdf->rad_y = fdf->rot_y * M_PI / 180;
//fdf->altitude *= (fdf->offset + fdf->zoom) / fdf->offset;
i =-1;
while (++i < fdf->img_size_y * fdf->img_sizel)
*(unsigned int*)(fdf->img_addr + i) = 0;
@@ -70,7 +69,8 @@ void draw_color_pixel(t_fdf *fdf, int new_x, int new_y, int z)
int color;
color = 0xffffff;
z = z / fdf->altitude;
z -= (z * fdf->zoom) / fdf->offset;
z /= fdf->altitude;
if (z)
{
color = color ^ (((0xff / fdf->max_z) * z) << 8 );

View File

@@ -46,6 +46,7 @@ int *new_coordinates(t_fdf *fdf, int i, int j)
y -= (fdf->map_size_y + fdf->zoom * fdf->map_height) / 2;
// rotation
z = fdf->map[j][i] * fdf->altitude;
z += (z * fdf->zoom) / fdf->offset;
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] = point[1] * cos(fdf->rad_y) - -z * sin(fdf->rad_y);