66 lines
2.1 KiB
Markdown
66 lines
2.1 KiB
Markdown
# FDF - fil de fer (french for Wire)
|
|
---
|
|
|
|
This project is an introduction to 3D drawing. It takes a map file and render it with its height. It listen to keyboard events to apply transformations, such as translation, rotations, zoom, and change in altitude factor.
|
|
|
|
the input map is a simple text file that looks like this :
|
|
|
|
```
|
|
$> cat -e map_test.fdf
|
|
0 0 0 0 0$
|
|
0 0 0 0 0$
|
|
0 10 0 0 0$
|
|
0 0 0 0 0$
|
|
0 0 0 0 0$
|
|
$>
|
|
```
|
|
|
|
and the program converts it into a rectangular net, like a landscape with the height equal to the numbers :
|
|
|
|

|
|
|
|
we can modify the map to see a new 3D model :
|
|
|
|
```
|
|
$> cat -e map_test.fdf
|
|
0 0 0 0 0$
|
|
1 2 3 4 5$
|
|
0 10 8 0 0$
|
|
0 0 0 9 0$
|
|
0 0 0 0 0$
|
|
$>
|
|
```
|
|
|
|

|
|
|
|
# ressources
|
|
---
|
|
|
|
- it is based on a library called minilibx : https://github.com/42Paris/minilibx-linux
|
|
- equations to transform a 2D drawing into a perspective : https://math.stackexchange.com/questions/2305792/3d-projection-on-a-2d-plane-weak-maths-ressources/2306853#2306853
|
|
- drawing a line between two points : https://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
|
|
- bits manipulation for colors shifting : https://dev.to/freerangepixels/a-probably-terrible-way-to-render-gradients-1p3n
|
|
- optimizing events response with debouncing and throttling : https://stackoverflow.com/questions/25991367/difference-between-throttling-and-debouncing-a-function
|
|
- building images instead of asking the X library to draw each pixel one by one : https://github.com/Gontjarow/MiniLibX/blob/master/docs/mlx-tutorial-create-image.md
|
|
|
|
# transformations :
|
|
---
|
|
|
|
**zoom :**
|
|
|
|

|
|
|
|
**turn :**
|
|
|
|

|
|

|
|
|
|
**move :**
|
|
|
|

|
|
|
|
**altitude factor :**
|
|
|
|

|
|
|