FDF (Fil de Fer - Fransฤฑzca "tel kafes" anlamฤฑna gelir), 42 School'un grafik programlama projeleridendir. Bu proje, 3D harita verilerini izometrik projeksiyon kullanarak 2D ekranda wireframe (tel kafes) gรถrselleลtirmesi yapar.
Proje, MiniLibX grafik kรผtรผphanesini kullanarak matematiksel transformasyonlarฤฑ ve รงizgi รงizim algoritmalarฤฑnฤฑ uygulamanฤฑzฤฑ gerektirir.
- โ
.fdfuzantฤฑlฤฑ harita dosyalarฤฑnฤฑ okuma - โ ฤฐzometrik projeksiyon ile 3D gรถrselleลtirme
- โ Bresenham algoritmasฤฑ ile รงizgi รงizimi
- โ Z ekseni (yรผkseklik) desteฤi
- โ Renk interpolasyonu
- โ Hata yรถnetimi
- โ ESC tuลu ile programdan รงฤฑkฤฑล
- โ Pencere kapatma tuลu (X) ile รงฤฑkฤฑล
- โ รoklu Projeksiyon: ฤฐzometrik ve paralel projeksiyon arasฤฑ geรงiล
- โ Rotasyon: Haritayฤฑ Z ekseni etrafฤฑnda dรถndรผrme
- โ Yakฤฑnlaลtฤฑrma/Uzaklaลtฤฑrma: Dinamik รถlรงeklendirme
- โ Hareket: Haritayฤฑ ekranda kaydฤฑrma
- โ
Video Modu:
.fdfsdosyalarฤฑ ile animasyonlu gรถrselleลtirme - โ Renk Desteฤi: Hex renk kodlarฤฑ ile รถzel renklendirme
- โ Akฤฑcฤฑ Animasyon: Frame tabanlฤฑ yumuลak geรงiลler
| Tuล | ฤฐลlev |
|---|---|
ESC |
Programdan รงฤฑk |
โ โ โ โ |
Haritayฤฑ hareket ettir |
+ / - |
Yakฤฑnlaลtฤฑr / Uzaklaลtฤฑr |
R / T |
Z ekseni etrafฤฑnda dรถndรผr |
P |
Projeksiyon deฤiลtir (ฤฐzometrik โ Paralel) |
SPACE |
Animasyonu duraklat/devam ettir |
- GCC veya Clang derleyici
- Make
- Git
- X11 kรผtรผphaneleri (Linux)
- MiniLibX kรผtรผphanesi (otomatik indirilecek)
# Depoyu klonlayฤฑn
git clone https://github.com/CilginSinek/fdf.git
cd fdf
# X11 geliลtirme kรผtรผphanelerini yรผkleyin (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install libx11-dev libxext-dev
# Zorunlu versiyonu derleyin
make
# Veya bonus versiyonu derleyin
make bonus./fdf maps/42.fdf./fdf_bonus maps/42.fdf./fdf_bonus maps/output.fdfs./fdf_bonus maps/pyramide.fdf 1 # 1: ฤฐzometrik (varsayฤฑlan)
./fdf_bonus maps/mars.fdf 0 # 0: Paralel projeksiyon0 0 0 0 0
0 10 10 10 0
0 10 20 10 0
0 10 10 10 0
0 0 0 0 0
0,0xFF0000 0,0x00FF00 0,0x0000FF
0,0xFFFF00 10,0xFF00FF 10,0x00FFFF
Video formatฤฑ, birden fazla frame iรงeren dosyalardฤฑr. Her frame, --- ayฤฑrฤฑcฤฑsฤฑ ile ayrฤฑlฤฑr:
0 0 0
0 10 0
0 0 0
---
0 0 0
0 20 0
0 0 0
---
fdf/
โโโ mandatory/ # Zorunlu versiyon dosyalarฤฑ
โ โโโ main.c # Ana program
โ โโโ drawmap.c # รizim algoritmalarฤฑ
โ โโโ filehandler.c # Dosya okuma
โ โโโ utils.c # Yardฤฑmcฤฑ fonksiyonlar
โ โโโ exit_utils.c # Bellek temizleme
โ โโโ fdf.h # Ana header dosyasฤฑ
โโโ bonus/ # Bonus versiyon dosyalarฤฑ
โ โโโ main_bonus.c # Ana program (bonus)
โ โโโ handlevision_bonus.c # Gรถrรผntรผleme yรถnetimi
โ โโโ imagehandler_bonus.c # ฤฐmaj iลleme
โ โโโ video_handle_bonus.c # Video/animasyon
โ โโโ key_utils.c # Klavye kontrolleri
โ โโโ fdf_bonus.h # Bonus header dosyasฤฑ
โโโ libft/ # รzel C kรผtรผphanesi
โโโ get_next_line/ # Dosya okuma fonksiyonu
โโโ maps/ # รrnek harita dosyalarฤฑ
โโโ Makefile # Derleme yapฤฑlandฤฑrmasฤฑ
โโโ README.md # Bu dosya
Projenin รงekirdeฤinde izometrik projeksiyon formรผlรผ bulunur:
x' = (x - y) * cos(30ยฐ)
y' = (x + y) * sin(30ยฐ) - zรzel bir รงizgi รงizim algoritmasฤฑ kullanฤฑlฤฑr:
- Her noktadan saฤa ve aลaฤฤฑya doฤru รงizgiler รงizer
- En saฤ ve en aลaฤฤฑ noktalarda ek รงizgi รงizmez
- Grid tabanlฤฑ wireframe yapฤฑsฤฑ oluลturur
- Basit ve verimli piksel bazlฤฑ รงizim
- Varsayฤฑlan Renk: Beyaz (
0xFFFFFF) - Hex Renk Desteฤi:
0xRRGGBBformatฤฑnda - Renk Interpolasyonu: ฤฐki nokta arasฤฑnda yumuลak geรงiลler
- Z-bazlฤฑ Renklendirme: Yรผkseklik haritalarฤฑ iรงin otomatik gradyan
Proje ile birlikte gelen รถrnek haritalar:
| Dosya | Aรงฤฑklama |
|---|---|
42.fdf |
42 logosu |
pyramide.fdf |
Piramit yapฤฑsฤฑ |
mars.fdf |
Mars yรผzey haritasฤฑ |
julia.fdf |
Julia kรผmesi fraktalฤฑ |
elem-col.fdf |
Renkli รถฤeler |
output.fdfs |
Animasyonlu video รถrneฤi |
Proje, 42 School'un Norminette kurallarฤฑna uygun olarak yazฤฑlmฤฑลtฤฑr:
# Tรผm kodu kontrol et
make norm
# Sadece mandatory'yi kontrol et
make normmandatory
# Sadece bonus'u kontrol et
make normbonusProgram aลaฤฤฑdaki durumlarda dรผzgรผn ลekilde hata mesajฤฑ verir:
- โ Geรงersiz dosya formatฤฑ
- โ Dosya bulunamadฤฑ
- โ Bellek ayฤฑrma hatasฤฑ
- โ MLX baลlatma hatasฤฑ
- โ Geรงersiz harita verisi
make # Zorunlu versiyonu derle
make bonus # Bonus versiyonu derle
make clean # Object dosyalarฤฑnฤฑ temizle
make fclean # Tรผm derleme รงฤฑktฤฑlarฤฑnฤฑ temizle
make re # Yeniden derle
make norm # Norminette kontrolรผ yap# X11 kรผtรผphanelerini yรผkleyin
sudo apt-get install libx11-dev libxext-dev libbsd-dev
# MiniLibX'i manuel olarak derleyin
cd minilibx-linux
makevalgrind --leak-check=full --show-leak-kinds=all ./fdf maps/42.fdf- Fork yapฤฑn
- Feature branch oluลturun (
git checkout -b feature/amazing-feature) - Deฤiลikliklerinizi commit edin (
git commit -m 'Add some amazing feature') - Branch'inizi push edin (
git push origin feature/amazing-feature) - Pull Request aรงฤฑn
Bu proje 42 School mรผfredatฤฑnฤฑn bir parรงasฤฑdฤฑr ve eฤitim amaรงlฤฑdฤฑr.
iduman - @CilginSinek
- 42 Istanbul
- MiniLibX geliลtiricileri
- 42 topluluฤu
- FDF Video Maker - FDF iรงin
.fdfsanimasyon dosyalarฤฑ oluลturmak iรงin Python aracฤฑ
FDF (Fil de Fer - French for "wireframe") is a 42 School graphics programming project. This project visualizes 3D map data on a 2D screen using isometric projection in a wireframe format.
The project requires implementing mathematical transformations and line drawing algorithms using the MiniLibX graphics library.
- โ
Read map files with
.fdfextension - โ 3D visualization with isometric projection
- โ Line drawing using Bresenham's algorithm
- โ Z-axis (height) support
- โ Color interpolation
- โ Error handling
- โ Exit with ESC key
- โ Exit with window close button (X)
- โ Multiple Projections: Switch between isometric and parallel projection
- โ Rotation: Rotate the map around Z-axis
- โ Zoom In/Out: Dynamic scaling
- โ Translation: Move the map on screen
- โ
Video Mode: Animated visualization with
.fdfsfiles - โ Color Support: Custom coloring with hex color codes
- โ Smooth Animation: Frame-based smooth transitions
| Key | Function |
|---|---|
ESC |
Exit program |
โ โ โ โ |
Move the map |
+ / - |
Zoom in / Zoom out |
R / T |
Rotate around Z-axis |
P |
Change projection (Isometric โ Parallel) |
SPACE |
Pause/Resume animation |
- GCC or Clang compiler
- Make
- Git
- X11 libraries (Linux)
- MiniLibX library (will be downloaded automatically)
# Clone the repository
git clone https://github.com/CilginSinek/fdf.git
cd fdf
# Install X11 development libraries (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install libx11-dev libxext-dev
# Compile mandatory version
make
# Or compile bonus version
make bonus./fdf maps/42.fdf./fdf_bonus maps/42.fdf./fdf_bonus maps/output.fdfs./fdf_bonus maps/pyramide.fdf 1 # 1: Isometric (default)
./fdf_bonus maps/mars.fdf 0 # 0: Parallel projection0 0 0 0 0
0 10 10 10 0
0 10 20 10 0
0 10 10 10 0
0 0 0 0 0
0,0xFF0000 0,0x00FF00 0,0x0000FF
0,0xFFFF00 10,0xFF00FF 10,0x00FFFF
Video format contains multiple frames separated by ---:
0 0 0
0 10 0
0 0 0
---
0 0 0
0 20 0
0 0 0
---
fdf/
โโโ mandatory/ # Mandatory version files
โ โโโ main.c # Main program
โ โโโ drawmap.c # Drawing algorithms
โ โโโ filehandler.c # File reading
โ โโโ utils.c # Utility functions
โ โโโ exit_utils.c # Memory cleanup
โ โโโ fdf.h # Main header file
โโโ bonus/ # Bonus version files
โ โโโ main_bonus.c # Main program (bonus)
โ โโโ handlevision_bonus.c # Vision management
โ โโโ imagehandler_bonus.c # Image processing
โ โโโ video_handle_bonus.c # Video/animation
โ โโโ key_utils.c # Keyboard controls
โ โโโ fdf_bonus.h # Bonus header file
โโโ libft/ # Custom C library
โโโ get_next_line/ # File reading function
โโโ maps/ # Sample map files
โโโ Makefile # Build configuration
โโโ README.md # This file
The core of the project uses isometric projection formula:
x' = (x - y) * cos(30ยฐ)
y' = (x + y) * sin(30ยฐ) - zA custom line drawing algorithm is used:
- Draws lines to the right and downward from each point
- No additional lines are drawn at rightmost and bottommost points
- Creates a grid-based wireframe structure
- Simple and efficient pixel-based drawing
- Default Color: White (
0xFFFFFF) - Hex Color Support: In
0xRRGGBBformat - Color Interpolation: Smooth transitions between two points
- Z-based Coloring: Automatic gradient for height maps
Sample maps included with the project:
| File | Description |
|---|---|
42.fdf |
42 logo |
pyramide.fdf |
Pyramid structure |
mars.fdf |
Mars surface map |
julia.fdf |
Julia set fractal |
elem-col.fdf |
Colored elements |
output.fdfs |
Animated video example |
The project is written in compliance with 42 School's Norminette rules:
# Check all code
make norm
# Check only mandatory
make normmandatory
# Check only bonus
make normbonusThe program properly handles errors in the following cases:
- โ Invalid file format
- โ File not found
- โ Memory allocation failure
- โ MLX initialization failure
- โ Invalid map data
make # Compile mandatory version
make bonus # Compile bonus version
make clean # Clean object files
make fclean # Clean all build outputs
make re # Recompile
make norm # Run Norminette check# Install X11 libraries
sudo apt-get install libx11-dev libxext-dev libbsd-dev
# Manually compile MiniLibX
cd minilibx-linux
makevalgrind --leak-check=full --show-leak-kinds=all ./fdf maps/42.fdf- Fork it
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is part of the 42 School curriculum and is for educational purposes.
iduman - @CilginSinek
- 42 Istanbul
- MiniLibX developers
- 42 community
- FDF Video Maker - Python tool to create
.fdfsanimation files for FDF
Made with โค๏ธ at 42 Istanbul
โญ Star this repo if you found it helpful!