The fifth project of 42 curriculum introduces students to the fundamentals of graphic programming with MiniLibX. This project is about representing a landscape as a 3D object in which all surfaces are outlined in lines. FdF is short for fil de fer in French which means wireframe model.
Since the project in quite big, the diagram below helps to get an overview of the whole project. Each .c
file has functions that can be global or static, which means respectively the functions in red and blue. As you can see, the core of the project corresponds to five files:
fdf.h
: contains all the necessary functions and helpers to be called by the program.instance.c
: inicializes all variables necessary to render the map.file.c
: reads a file to get its dimension and coordinates values.render.c
: renders the map with minilibx once the file has been successfully read.events.c
: manages user events toggled by specific keys.
git clone git@github.com:ygor-sena/42cursus-FdF.git
make
./fdf maps/10-2.fdf
You can also run make
and a number between 1 and 21 as a shortkey to render the files in folder maps
with valgrind to check for memory leaks. For example, the command below is equivalent to valgrind ./fdf maps/elem2.fdf
. To see other commands with make
, refer to Makefile
.
make 11
Key | Command |
---|---|
←↑↓→ | Moves the map to left, up, down and right. |
Esc | Closes the program. |
-+ | Zooms the maps out and in. |
ZX | Increases and decreases map altitude. |
O | Renders the map in orthogonal projection. |
I | Renders the map in isometric projection. |
AS | Rotates the X axis of the map, i.e. roll rotation. |
DF | Rotates the Y axis of the map, i.e. pitch rotation. |
GH | Rotates the Z axis of the map, i.e. yaw rotation. |
R | Resets the map to its original state. |
-
General references:
- Introduction to isometric projection in games by Pikuma.
- X Windows System Basics by Jasper Pierre.
- DDA vs. Bresenham by Koiti Yasojima.
-
About algorithms to draw a line:
-
About color rendering:
- A probably terrible way to render gradients by Crystal Schuller.
-
About roll, pitch and yaw rotations:
- Roll, pitch and yaw rotations by Wikipedia
- 3D point rotation algorithm by Stack Overflow
-
Other interesting 42's students FdF: