Skip to content

theVeryPulse/FdF-3D-Wireframe-Renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A 3D Wireframe Renderer

FDF (A 3D Wireframe Renderer)

rotating 42

FDF is a simple isometric 3D wireframe renderer written in C. It takes a map file as input, representing a grid of points in 3D space, and renders it as a wireframe projection on the screen.

Table of Contents

Features

julia.fdf

  • Renders 3D wireframe models in real-time.
  • Simple and intuitive controls.
  • Isometric and cavalier projections.

Installation

  1. Clone the repository

    git clone https://github.com/theVeryPulse/fdf.git
  2. Run make in terminal

  3. Run make bonus to compile fdf of cavalier projection

Usage

Run the executable fdf with the map as command line argument

./fdf test_maps/42.fdf

42.fdf

Map File Format

42.fdf from above as an example, its map files looks like this

0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0 10 10  0  0 10 10  0  0  0 10 10 10 10 10  0  0  0
0  0 10 10  0  0 10 10  0  0  0  0  0  0  0 10 10  0  0
0  0 10 10  0  0 10 10  0  0  0  0  0  0  0 10 10  0  0
0  0 10 10 10 10 10 10  0  0  0  0 10 10 10 10  0  0  0
0  0  0 10 10 10 10 10  0  0  0 10 10  0  0  0  0  0  0
0  0  0  0  0  0 10 10  0  0  0 10 10  0  0  0  0  0  0
0  0  0  0  0  0 10 10  0  0  0 10 10 10 10 10 10  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0

where the row and column represent the coordinates on horizontal plane, and the number value represents the height of that point.

Controls

Key(s) Action
Move the model
i o Zoom in / out
w s Rotate up / down
a d Rotate counter-clockwise / clockwise
q e Rotate left / right
Esc Exit the program

Note: Cavalier projection does not support rotation

Conventions

Points, vectors are represented in column-major vectors. To support translation by matrix, the extra homogenous coordinate is added. Matrices are stored in 4x4 arrays.

[v'] = [Transformation matrix][v]

The world coordinate system has its origin at the centre of the screen, with x-axis pointing rightwards, y-axis pointing upwards, and z-axis pointing outwards the screem.

The camera coordinate system is the same as the world coordinate system.

There is no scaling between world/camera coordinate and screen coordinate, meaning a number in world system corresponds to the same amount of pixels on screen.

Because of this uniformity between screen and raster spaces, the conversion of Normalized Device Coordinates is omitted, and all coordinates are directly converted to raster space (actual pixels).

Useful Links

MiniLibX

Introduction to the minilibX : a simple X-Window programming API in C | YouTube

MiniLibX Manual

MiniLibX Introduction

Line Drawing Algorithm

Bresenham’s Line Drawing Algorithm | Medium

Bresenham's line algorithm | Wikipedia

Render practice (projection, rotation)

Coding Challenge #112: 3D Rendering with Rotation and Projection | YouTube

Computer Graphics General

Scratchapixel

About

A simple 3D wireframe renderer

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published