Skip to content

dmitrijslasko/42_fdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FDF, a wireframe model (School 42 project)

The FDF (Fil de Fer) project at 42 is a graphics programming task where you create a program in C to display a 3D wireframe map from a set of 2D coordinates.
The input is a file containing a grid of elevation points, and the program visualizes the map using isometric projection.

Key features of the project include:

  • Parsing the map file: Read and interpret a grid of elevation values from a text file.
  • Rendering: Convert the 2D grid data into a 3D representation with lines connecting the points to form a mesh.
  • Isometric projection: Display the 3D map in a 2D isometric perspective to provide depth and structure.
  • Controls: Implement interactivity for zooming, rotating, and translating the view, allowing dynamic exploration of the map.
  • Graphics library: Typically, the project uses the MiniLibX library to handle window management and drawing. The project emphasizes skills in graphics programming, data manipulation, and mastering low-level rendering concepts.

Score:

✅ 125/125 (with bonus)

42.fdf map


Installation and launch 🚀

1. Clone the repo:

git clone https://github.com/dmitrijslasko/fdf42.git

2. Go into the folder:

cd fdf42

3. Build the program:

make

4. Launch the program with the selected map:

./fdf ./maps/42.fdf

Other maps are stored in the ./maps/ folder.


Implemented functionality 🤖

fdf-demo

  1. Welcome screen (not allowed by the project's subject, but using it via a workaround in the Makefile)
  2. Mouse / keyboard rotation and zoom
  3. Map height & color information parser
  4. Height scaling
  5. Relative height color output (with easily customizable color schemes)
  6. Control panel overlay
  7. Control panel language switch (English, German)
  8. 2 projections: Isometric / parallel
  9. Rotation angle information panel
  10. Special visual admin mode
  11. Show / hide nodes (not shown in the GIF above)

Controls 🕹️

  • Zoom: Scroll or [+] / [-]
  • Move: Hold left mouse button or Arrows
  • Flatten / raise height: [[] / []]
  • Rotate: Hold right mouse button & Move
  • Enable autorotation: [K]
  • Toggle autorotation mode: [M]
  • X-Axis - [Q] / [W]
  • Y-Axis - [A] / [S]
  • Z-Axis - [Z] / [W]
  • Switch projections: ISO: [I], Top-view: [P]
  • Show / hide nodes: [N]
  • Reset view: [R]
  • Map colors: [1][2][3][4]
  • Switch language: [L]
  • Secret admin mode: [/]

Known issues 🚨

  1. macOS not working out of the box (the project was written on Linux Ubuntu 22/24)
  2. Due to the limitation of the MLX library, the control panel text is output to the window, not the image. This sometimes results in blinking (because of the constant rerendering). However, it perfectly shows why we should use the image pre-render for the main part of the program.
    It's best to reimplement this functionality with an XPM image.

Reading list 📚

  1. Getting started with the minilibx https://aurelienbrabant.fr/blog/getting-started-with-the-minilibx

Inspirations 💡

  1. Awesome project with implemented spherical projection https://github.com/ailopez-o/42Barcelona-FdF
  2. A simple fdf implementation that works on MacOS (was a great starting point for me; helped to implement mouse rotations) https://github.com/VBrazhnik/FdF
  3. This article mentions using an XPM image for the control panel https://medium.com/@amehri_tarik/fdf-42-a-detailed-walkthrough-7184cca317fc

Questions? 🤔

Feel free to contact me: Slack: @dmlasko
E-mail: dmitrijs.lasko@gmail.com
Telegram: @lalamoose

About

A 42 project written in C that visualizes 3D terrain maps as isometric wireframes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors