FdF is a project from 42 School where we transform a file containing a grid of height values into a 3D wireframe using the MiniLibX graphics library. Think of it as turning numbers into art!
The main goal of FdF is to read a file with height values arranged in a grid and render it as a stunning 3D wireframe model. We use the MiniLibX library to handle graphics rendering.
Here is an example of a small map file:
0 0 0 0 0 0 0 0 0 0
0 10 10 10 10 10 10 10 10 0
0 10 20 15 12 15 17 20 10 0
0 10 15 10 12 15 15 15 10 0
0 5 15 10 12 15 15 13 10 0
0 5 10 5 7 12 12 12 10 0
0 5 7 1 2 7 5 5 7 0
0 3 0 0 1 2 2 2 5 0
0 1 0 0 0 0 0 0 3 0
0 0 0 0 0 0 0 0 0 0
And here’s how it looks when rendered:
Want to try FdF on your own? Follow these steps:
-
Clone the repository and its submodules:
git clone https://github.com/Liammmmmmmm/42-FdF.git --recurse-submodules
If you’ve already cloned the repository, initialize the submodules with:
git submodule update --init --recursive
-
Build the project:
make all
-
Run the program with a map file:
./fdf <map.fdf>
That’s it! You’re ready to explore your wireframe world. 🌟
Wondering what to do inside the window? Don’t worry—controls are displayed by default! You can hide them with [C]
.
Need more details? Activate the real-time information panel with [I]
. A lot of informations are here, enjoy nerds!
Some maps have exaggerated heights that look out of proportion. You can adjust the Z-axis scaling with [-]
and [+]
.
Enable perspective projection for a more realistic 3D effect.
With perspective enabled, you can tweak parameters like the field of view (FOV) using [<]
and [>]
. The default FOV is 60.
Explore your wireframe in free camera mode! Move around the scene with the WASD
keys for an immersive experience. It pairs beautifully with perspective mode.
By default, lines are drawn in the same order for every frame. This can cause visual glitches where lines that should be behind others appear in front.
Toggle Z-ordering with [Z]
to fix this issue. Note: it’s disabled by default due to performance costs.
Switch between various color presets to change the wireframe’s appearance. Use the numpad keys to select one of four presets:
- Default: White at the lowest points, purple at the highest.
- Earth-like (smooth): Great for maps like
MGDS_WHOLE_WORLD_OCEAN1_M/L/XL.fdf
. - Earth-like (non-smooth): Same as preset 2 but without smoothing.
- Moon-like: Perfect for maps like
USGS_ULCN2005_grid.txt_OCEAN1_M/L.fdf
.
Flat maps are boring! With my FdF, maps can become spherical for a more realistic touch. Science says the Earth is round, and so is ours. 🌍
(As you see we can also here play with the z-axe ratio)
This works for any map not just Earth. Check out the Moon in all its spherical glory:
FdF is an exciting project that teaches you file parsing tricks and how to project 3D points (x, y, z)
onto a 2D screen. You’ll sharpen your matrix calculation skills and discover the joy of bringing numbers to life. With bonuses and extra features, this project becomes even more fun and rewarding.