The FDF project at 42 is designed to introduce students to graphical programming by rendering 3D wireframe maps using the MiniLibX graphics library. The objective is to read a file containing a 3D map representation and project it onto a 2D window, applying
Concept
FDF (Fil De Fer, meaning "wireframe" in French) involves reading a heightmap file (a .fdf file) and displaying the corresponding
-
2D and 3D coordinate systems
-
Mathematical transformations (scaling, rotation, translation, projection)
-
Bresenham's line-drawing algorithm
-
Handling user inputs for interactivity
-
Using MiniLibX for graphics rendering
-
Read a
.fdffile containing a grid of integers representing heights. -
Render a wireframe model using
$\color{LimeGreen}{\textbf{line segments}}$ . -
Implement at least one type of projection:
-
$\color{LightSkyBlue}{\textbf{Isometric Projection}}$ (default, giving a 3D effect) -
$\color{LimeGreen}{\textbf{Parallel Projection}}$ (optional for a different perspective)
-
-
Handle user interactions, such as:
-
Zooming in/out
-
Rotating the model
-
Translating the view
-
Changing projection type
-
-
Use MiniLibX for graphical rendering.
-
No external graphics libraries are allowed.
-
Additional Projections (e.g., orthographic, perspective)
-
Color Gradients based on height values
-
Smooth Animations for transformations
-
Mouse Controls for rotation and zoom
-
Multiple File Support to load different maps dynamically
The .fdf file contains a grid of numbers separated by spaces, where each number represents a height value:
0 1 2 3
1 2 3 4
2 3 4 5The program must:
-
Read the file and store the height values in a structured format (e.g., a 2D array).
-
Normalize the data for rendering.
-
Convert 3D points into 2D projections.
Uses a standard formula to project 3D points onto a 2D plane:
x_iso = (x - y) * cos(θ)
y_iso = (x + y) * sin(θ) - z-
Keeps the coordinate alignment without perspective distortion.
-
Ideal for technical or blueprint-like views.
-
$\color{YellowGreen}{\textbf{Bresenham’s Algorithm}}$ is used to draw lines between projected points efficiently.
-
$\color{SeaGreen}{\textbf{Keyboard controls}}$ for rotating, zooming, and moving the map. -
$\color{SeaGreen}{\textbf{Mouse support}}$ (optional for smooth user experience).
To compile the project, use:
makeTo run the program:
./fdf maps/42.fdf-
$\color{Crimson}{\textbf{Incorrect parsing}}$ .fdffiles leading to segmentation faults. -
$\color{Crimson}{\textbf{Not handling edge cases}}$ , such as missing files or incorrect formats. -
$\color{Crimson}{\textbf{Floating-point precision errors}}$ affecting line drawing and transformations. -
$\color{Crimson}{\textbf{Inefficient rendering}}$ , causing performance issues on large maps.
The FDF project is an excellent introduction to