This project is about creating a simple wireframe model representation of a 3D landscape by linking various points (x, y, z) thanks to line segments (edges). (Only compatible with macOS)
FdF is a computer graphics introductory project in 42 school. The goal of the project is to visually represent a 3D landscape in isometric projection. The coordinates of the landscape are stored in a .fdf file passed as a parameter to the program.
Here is an example:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 10 10 0 0 10 10 0 0 0 10 10 10 10 10 0 0 0
0 0 10 10 0 0 10 10 0 0 0 0 0 0 0 10 10 0 0
0 0 10 10 0 0 10 10 0 0 0 0 0 0 0 10 10 0 0
0 0 10 10 10 10 10 10 0 0 0 0 10 10 10 10 0 0 0
0 0 0 10 10 10 10 10 0 0 0 10 10 0 0 0 0 0 0
0 0 0 0 0 0 10 10 0 0 0 10 10 0 0 0 0 0 0
0 0 0 0 0 0 10 10 0 0 0 10 10 10 10 10 10 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Each number represents a point in space:
- The horizontal position corresponds to its axis.
- The vertical position corresponds to its ordinate.
- The value corresponds to its altitude.
In order to run the program first clone the repository:
git clone git@github.com:ferri17/FdF.gitOpen the folder:
cd FdF/Compile the program:
makeRun the program with a valid map as argument(test maps can be found in /maps)
./fdf maps/42.fdf| Action | Key |
|---|---|
| Move map | Mouse right click + drag |
| Rotate map | Mouse left click + drag |
| Lock rotation axis | Hold X,Y,Z while rotating |
| Color themes | 1, 2, 3 |
| Change map heights | N,M |
| Edge/Vertex mode | G |
| Snap rotation | Hold H while rotating |
| Isometric/Paralel projection | I,P |
Minilibx
Really good guides to start using minilibx functions.
- https://gontjarow.github.io/MiniLibX/mlx-tutorial-create-image.html
- https://harm-smits.github.io/42docs/libs/minilibx/images.html
How to draw a line in a pixel map
How to represent a 3D figure in a 2D space
- https://www.youtube.com/watch?v=p4Iz0XJY-Qk
- https://en.wikipedia.org/wiki/Rotation_matrix
- https://clintbellanger.net/articles/isometric_math/
Gradients
Best walkthrough to understand how to calculate a gradient between 2 points
Virtual keys macOS
Clipping lines to optimise render with Cohen-Sutherland algorithm
