https://github.com/ygor-sena/42cursus-fdf
The fifth project of 42 curriculum introduces students to the fundamentals of graphic programming with MiniLibX. Between three projects to pick out, I chose FdF which aims to represent "iron wire" meshing in 3D.
https://github.com/ygor-sena/42cursus-fdf
3d-graphics 42 42cursus 42saopaulo 42school 42sp ansi-c c ecole42 minilibx wireframe
Last synced: about 2 months ago
JSON representation
The fifth project of 42 curriculum introduces students to the fundamentals of graphic programming with MiniLibX. Between three projects to pick out, I chose FdF which aims to represent "iron wire" meshing in 3D.
- Host: GitHub
- URL: https://github.com/ygor-sena/42cursus-fdf
- Owner: ygor-sena
- License: gpl-3.0
- Created: 2022-08-05T19:55:30.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-04T16:41:12.000Z (about 1 year ago)
- Last Synced: 2025-02-24T06:17:36.966Z (2 months ago)
- Topics: 3d-graphics, 42, 42cursus, 42saopaulo, 42school, 42sp, ansi-c, c, ecole42, minilibx, wireframe
- Language: C
- Homepage:
- Size: 590 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
![]()
![]()
![]()
![]()
## π£ Introduction
The fifth project of 42 curriculum introduces students to the fundamentals of graphic programming with [MiniLibX](https://github.com/42Paris/minilibx-linux). 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.## π Project diagram
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.
## βοΈ How to compile and run the project
#### 1) Copy this repository to your local workstation
```html
git clone [email protected]:ygor-sena/42cursus-FdF.git
```#### 2) Compile the project with Makefile
```html
make
```#### 3) Choose a map from folder `maps` to be rendered by the program
```html
./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
```## π‘ How to use the project
| 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. |## π References
- General references:
- [Introduction to isometric projection in games](https://pikuma.com/blog/isometric-projection-in-games) by [Pikuma](https://www.youtube.com/@pikuma).
- [X Windows System Basics](https://magcius.github.io/xplain/article/index.html) by Jasper Pierre.
- [DDA vs. Bresenham](https://www.youtube.com/watch?v=K92zQcSrc7Y&list=PL9k0QJ76ydSTPF_cOXArVyae6VflQJFOH&index=3) by Koiti Yasojima.- About algorithms to draw a line:
- [Bresenham's Line Drawing Algorithm](https://www.youtube.com/watch?v=RGB-wlatStc&t=2286s) by [Abdul Bari](https://www.youtube.com/@abdul_bari).
- [How to code your first algorithm - Draw a line](https://jstutorial.medium.com/how-to-code-your-first-algorithm-draw-a-line-ca121f9a1395) by Ghost.
- [How to calculate the height and width of an isometric rectangle/square](https://stackoverflow.com/questions/4615116/how-to-calculate-the-height-and-width-of-an-isometric-rectangle-square) by Stack Overflow.- About color rendering:
- [A probably terrible way to render gradients](https://dev.to/freerangepixels/a-probably-terrible-way-to-render-gradients-1p3n) by Crystal Schuller.
- About roll, pitch and yaw rotations:
- [Roll, pitch and yaw rotations](https://de.wikipedia.org/wiki/Roll-Nick-Gier-Winkel) by Wikipedia
- [3D point rotation algorithm](https://stackoverflow.com/questions/34050929/3d-point-rotation-algorithm) by Stack Overflow
- Other interesting 42's students FdF:
- [ailopez's FdF](https://github.com/ailopez-o/42Barcelona-FdF) by [Aitor AudΓcana](https://github.com/ailopez-o).
- [caroldaniel's FdF](https://github.com/caroldaniel/42sp-cursus-fdf) by [Carol Daniel](https://github.com/caroldaniel/).