Skip to content

CilginSinek/fdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

37 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

FDF - Fil de Fer (Wireframe 3D Renderer)

42 School Project Language Graphics Grade


๐Ÿ‡น๐Ÿ‡ท Tรผrkรงe

๐Ÿ“– Proje Hakkฤฑnda

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.

โœจ ร–zellikler

๐ŸŽฏ Zorunlu ร–zellikler (Mandatory)

  • โœ… .fdf uzantฤฑ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ฤฑลŸ

๐ŸŒŸ Bonus ร–zellikler

  • โœ… ร‡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: .fdfs dosyalarฤฑ ile animasyonlu gรถrselleลŸtirme
  • โœ… Renk DesteฤŸi: Hex renk kodlarฤฑ ile รถzel renklendirme
  • โœ… Akฤฑcฤฑ Animasyon: Frame tabanlฤฑ yumuลŸak geรงiลŸler

๐ŸŽฎ Kontroller (Bonus)

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

๐Ÿ› ๏ธ Kurulum

Gereksinimler

  • GCC veya Clang derleyici
  • Make
  • Git
  • X11 kรผtรผphaneleri (Linux)
  • MiniLibX kรผtรผphanesi (otomatik indirilecek)

Linux/WSL iรงin Kurulum

# 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

๐Ÿš€ Kullanฤฑm

Zorunlu Versiyon

./fdf maps/42.fdf

Bonus Versiyon - Statik Harita

./fdf_bonus maps/42.fdf

Bonus Versiyon - Animasyonlu Video

./fdf_bonus maps/output.fdfs

Projeksiyon SeรงeneฤŸi ile BaลŸlatma

./fdf_bonus maps/pyramide.fdf 1  # 1: ฤฐzometrik (varsayฤฑlan)
./fdf_bonus maps/mars.fdf 0      # 0: Paralel projeksiyon

๐Ÿ“ Dosya Formatฤฑ

.fdf Format - Statik Harita

0  0  0  0  0
0 10 10 10  0
0 10 20 10  0
0 10 10 10  0
0  0  0  0  0

Renkli Harita (Hex Renk Kodlarฤฑ)

0,0xFF0000  0,0x00FF00  0,0x0000FF
0,0xFFFF00 10,0xFF00FF 10,0x00FFFF

.fdfs Format - Video/Animasyon

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
---

๐Ÿ“š Proje Yapฤฑsฤฑ

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

๐Ÿงฎ Algoritma ve Matematik

ฤฐzometrik Projeksiyon

Projenin รงekirdeฤŸinde izometrik projeksiyon formรผlรผ bulunur:

x' = (x - y) * cos(30ยฐ)
y' = (x + y) * sin(30ยฐ) - z

ร‡izgi ร‡izim Algoritmasฤฑ

ร–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

๐ŸŽจ Renk Sistemi

  • Varsayฤฑlan Renk: Beyaz (0xFFFFFF)
  • Hex Renk DesteฤŸi: 0xRRGGBB formatฤฑnda
  • Renk Interpolasyonu: ฤฐki nokta arasฤฑnda yumuลŸak geรงiลŸler
  • Z-bazlฤฑ Renklendirme: Yรผkseklik haritalarฤฑ iรงin otomatik gradyan

๐Ÿงช Test Haritalarฤฑ

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

๐Ÿ“ Norminette UyumluluฤŸu

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 normbonus

๐Ÿ›‘ Hata Yรถnetimi

Program 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

๐Ÿ”ง Makefile Komutlarฤฑ

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

๐Ÿ› Sorun Giderme

MiniLibX Hatalarฤฑ

# X11 kรผtรผphanelerini yรผkleyin
sudo apt-get install libx11-dev libxext-dev libbsd-dev

# MiniLibX'i manuel olarak derleyin
cd minilibx-linux
make

Bellek Sฤฑzฤฑntฤฑlarฤฑ Kontrolรผ

valgrind --leak-check=full --show-leak-kinds=all ./fdf maps/42.fdf

๐Ÿค Katkฤฑda Bulunma

  1. Fork yapฤฑn
  2. Feature branch oluลŸturun (git checkout -b feature/amazing-feature)
  3. DeฤŸiลŸikliklerinizi commit edin (git commit -m 'Add some amazing feature')
  4. Branch'inizi push edin (git push origin feature/amazing-feature)
  5. Pull Request aรงฤฑn

๐Ÿ“„ Lisans

Bu proje 42 School mรผfredatฤฑnฤฑn bir parรงasฤฑdฤฑr ve eฤŸitim amaรงlฤฑdฤฑr.

๐Ÿ‘จโ€๐Ÿ’ป Yazar

iduman - @CilginSinek

๐Ÿ™ TeลŸekkรผrler

  • 42 Istanbul
  • MiniLibX geliลŸtiricileri
  • 42 topluluฤŸu

๐Ÿ”— ฤฐlgili Projeler

  • FDF Video Maker - FDF iรงin .fdfs animasyon dosyalarฤฑ oluลŸturmak iรงin Python aracฤฑ

๐Ÿ‡ฌ๐Ÿ‡ง English

๐Ÿ“– About the Project

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.

โœจ Features

๐ŸŽฏ Mandatory Features

  • โœ… Read map files with .fdf extension
  • โœ… 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)

๐ŸŒŸ Bonus Features

  • โœ… 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 .fdfs files
  • โœ… Color Support: Custom coloring with hex color codes
  • โœ… Smooth Animation: Frame-based smooth transitions

๐ŸŽฎ Controls (Bonus)

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

๐Ÿ› ๏ธ Installation

Requirements

  • GCC or Clang compiler
  • Make
  • Git
  • X11 libraries (Linux)
  • MiniLibX library (will be downloaded automatically)

Installation for Linux/WSL

# 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

๐Ÿš€ Usage

Mandatory Version

./fdf maps/42.fdf

Bonus Version - Static Map

./fdf_bonus maps/42.fdf

Bonus Version - Animated Video

./fdf_bonus maps/output.fdfs

Launch with Projection Option

./fdf_bonus maps/pyramide.fdf 1  # 1: Isometric (default)
./fdf_bonus maps/mars.fdf 0      # 0: Parallel projection

๐Ÿ“ File Format

.fdf Format - Static Map

0  0  0  0  0
0 10 10 10  0
0 10 20 10  0
0 10 10 10  0
0  0  0  0  0

Colored Map (Hex Color Codes)

0,0xFF0000  0,0x00FF00  0,0x0000FF
0,0xFFFF00 10,0xFF00FF 10,0x00FFFF

.fdfs Format - Video/Animation

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
---

๐Ÿ“š Project Structure

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

๐Ÿงฎ Algorithms and Mathematics

Isometric Projection

The core of the project uses isometric projection formula:

x' = (x - y) * cos(30ยฐ)
y' = (x + y) * sin(30ยฐ) - z

Line Drawing Algorithm

A 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

๐ŸŽจ Color System

  • Default Color: White (0xFFFFFF)
  • Hex Color Support: In 0xRRGGBB format
  • Color Interpolation: Smooth transitions between two points
  • Z-based Coloring: Automatic gradient for height maps

๐Ÿงช Test 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

๐Ÿ“ Norminette Compliance

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 normbonus

๐Ÿ›‘ Error Handling

The program properly handles errors in the following cases:

  • โŒ Invalid file format
  • โŒ File not found
  • โŒ Memory allocation failure
  • โŒ MLX initialization failure
  • โŒ Invalid map data

๐Ÿ”ง Makefile Commands

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

๐Ÿ› Troubleshooting

MiniLibX Errors

# Install X11 libraries
sudo apt-get install libx11-dev libxext-dev libbsd-dev

# Manually compile MiniLibX
cd minilibx-linux
make

Memory Leak Check

valgrind --leak-check=full --show-leak-kinds=all ./fdf maps/42.fdf

๐Ÿค Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is part of the 42 School curriculum and is for educational purposes.

๐Ÿ‘จโ€๐Ÿ’ป Author

iduman - @CilginSinek

๐Ÿ™ Acknowledgments

  • 42 Istanbul
  • MiniLibX developers
  • 42 community

๐Ÿ”— Related Projects


Made with โค๏ธ at 42 Istanbul

โญ Star this repo if you found it helpful!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors