FdF is a 42 School project that renders a 3D wireframe representation of a landscape from a map file (.fdf).
It was completed and peer-graded at 42Barcelona, receiving a grade of 125/100.
The project uses MiniLibX for graphics and handles 3D projection, translation, rotation, zooming, and color effects.
FdF is part of the 42 curriculum, introducing 3D graphics and coordinate manipulation in C. It reinforces key programming and mathematical concepts:
- Trigonometry and linear algebra for 3D projections
- Event-driven programming
- Clean and modular code design
- Graphics rendering algorithms
The project is written in accordance with the 42 Norm, ensuring clean, readable, and maintainable code.
Peer-graded at 42Barcelona with a final grade of 125/100.
- Render 3D wireframes from
.fdfmap files - Isometric and parallel projections
- Smooth translation, rotation, zoom, and Z-axis scaling
- Color filters for red, green, and blue channels
- Tilt/plane inclination effect for dynamic 3D visualization
All required libraries (MiniLibX and Libft) are included in the repository.
To compile, simply run:
makeCompilation flags used (Linux / WSL):
-lXext -lX11 -lm -lbsd -lzYou may need to install these system libraries for MiniLibX to work on Linux/WSL.
To clean or rebuild:
make clean
make fclean
make re./fdf test_maps/42.fdfYou can use your own .fdf map or one from the provided test_maps/ folder.
The default window size is 1920x1080. You can change it by editing the
WIDTHandHEIGHTmacros infdf.h.
| Key | Action |
|---|---|
ESC |
❌ Close window / exit program |
← / → |
↔ Translate map along Y-axis |
↑ / ↓ |
↕ Translate map along X-axis |
Z / X |
⬆️⬇️ Translate map along Z-axis (height) |
A / D |
🔄 Rotate around Z-axis |
W / S |
🌀 Tilt / incline XY plane (creates dynamic 3D effect) |
N / M |
↕ Adjust Z-axis scale (stretch/compress height) |
+ / - |
🔍 Zoom in / out |
I |
🖼 Switch to isometric projection |
P |
🖼 Switch to parallel projection |
R / G / B |
🎨 Adjust color intensity of Red / Green / Blue |
Notes:
- Key mappings are optimized for Spanish keyboards; they may vary on other layouts.
- Only rectangular maps are accepted (same number of elements per line).
- Each number represents the altitude (Z-value) of a point.
- Optional colors can be added immediately after the number (no spaces):
<number>,0xRRGGBB
- Example line:
0 1 2 3,0xFF0000 4 5,0x00FF00
This represents a row of points, some with custom colors in hexadecimal.
- Reads the
.fdffile and stores points with altitudes and optional colors. - Uses linear algebra and trigonometry to calculate 3D positions and projection coordinates.
- Draws lines between points using Bresenham’s line algorithm.
- Handles real-time transformations (translation, rotation, zoom, tilt) and color adjustments.