The program takes a 2D map as a parameter and creates its 3D projection. The column is the x, the line is the y and the value is the z.
Here is a summary of how the overal program works:
- Parsing: the map which is presented as a file is read line by line and the values are parsed and stored into the following data structure where x, y, z and color values are the directly taken from the map:
-
typedef struct s_array{ double x; double y; double z; int color; int x_screen; int y_screen; int max_color; } t_array; - Then matrix-vector multiplication of the x, y and z with the rotation matrix is used to calculate the x_screen and y_screen at every point. For this application we chose to initialize the rotation matrix to: roll = 0.523599, pitch = -0.523599, yaw = 0.523599. you can modify these angles accordingly they will represent the first view of the map.
- Bresenham's Line Drawing Algorithm is used to draw lines between every two points.
- Hooks:
- Rotation: You can rotate the view using the keys D (roll -), A (roll +), W (picth +), X (pitch -), Z (yaw -), and E (yaw +).
- Zoom: Zoom in and out of the map as needed.
- Altitude Adjustment: Fine-tune the altitude scale coefficient using the up and down arrow keys.
- Color Variation: The map's colors dynamically change based on its altitude.
One of the requirement of this project was to use 42l's minilibX.
- This project is designed to work with minilibx for linux version make sure you have the minilibx-linux version in the repo.
- git clone https://github.com/shimazadeh/FDF.git FDF
- cd FDF
- make
- ./fdf maps/test_maps/map.fdf
Screen.Recording.2023-09-21.at.5.58.25.PM.mov
Explore more by using the maps in the map directory of the repo!