GithubHelp home page GithubHelp logo

orpheus-3145 / fdf Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 4.98 MB

Graphic rendering

CMake 0.64% C 89.39% C++ 7.85% GLSL 0.15% Batchfile 0.11% Shell 0.10% Python 1.40% Makefile 0.35%
clanguage graphics isometric-graphics mlx42 projections

fdf's Introduction

FdF

Fdf, or ’fil de fer' (wireframe model), is a graphic mapping application designed to render a set of 3D points in isometric projection. The input is a map (file .fdf inside folder maps/ ), every map has some rows an columns of numbers: the row and column of the number is going to be the y and x coordinates, the value of that number is the z value.

Overview

The program works as follows:

  • first thing the map is going to be parsed and checked if it satisfies the requirements:
    • .fdf extension and inside map folder
    • the map hase the same numbers of columns and rows
    • restrictions of values:
      • symbols allowed, except for digits: '+' '-' ',' '.' (and hexadecimal symbols, see later)
      • decimal or hexadecimal format, in the latter the number must begin with '0x' or have '0x' after the comma/point (in that case the whole part is going to be considered as decimal, the decimal part as hexadecimal)
  • every 3D point parsed must be rotated, because right now the map is in front of us, perpendicular to our sight: we would see just a flat rectangule/square with no elevation, the rotation we are going to apply are:
    • rotate by -45° along the z-axis (the one that goes perpenicularly from the monitor towards us)
    • rotate byt 60° along the x axis (goes increasingly from left to rigth)

alpha roation on x-axis:

X Y Z
1 0 0
0 cos(a) -sin(a)
0 sin(a) cos(a)

alpha roation on y-axis:

X Y Z
cos(a) 0 sin(a)
0 1 0
-sin(a) 0 cos(a)

alpha roation on z-axis:

X Y Z
cos(a) -sin(a) 0
sin(a) cos(a) 0
0 0 1
  • now that every point is correctly rotated the rendering starts: for every point only the (x,y) tuple is going to be considered, also the whole set will be shifted, so it is printed in the middle of the image (80% of the size), the image is also centered in the background and it has the same reduction rate (80%) of the graph on the img.

Requirements

The graphic part relies of the MLX42 library (Codam) which in turn depends on GLFW (see #Recerences for info). My project Libft is also included in Fdf as a submodule (as for MLX42) do git submodule update --init [--remote] if necessary, feel free to text me (again, see #References) if some piece of Libft is in conflit with FdF.

  • sudo apt install libglfw3 libglfw3-dev --> install glfw
  • sudo apt install cmake --> install cmake utility

Execute

  • the command make creates the executable
  • the executable runs with a parameter, which is the path of the .fdf file (there are some of them inside the maps/ folder)
  • key ESC -> kills the app
  • key WASD -> moves the subject in the window
  • mouse drag-and-drop -> rotates the subject on X or Y axis
  • (resizable window)
  • other make commands: re, clean, fclean

Structure

include/	--> header files
libft/		--> libft directory with auxiliary functions (git submodule)
maps/		--> files to render
MLX42/		--> graphic library (git submodule)
objects/	--> deposit for object files
tmp/		--> working examples provided
sources/	--> source files:
	- app.c				--> higher level functions to manage the MLX42
							library and the map parsed (open, close,
							draw, ...)
	- draw.c			--> draws the single pixel, a line from p1 to p2,
							and the	whole graph
	- fdf.c				--> main file 
	- finder.c			--> functions to find certain target inside the map
	- hooks.c			--> callbacks binded to the presson of certain keys
	- manipulate_map.c	--> middle-level operations on map (rotate, shift, resize)
	- map.c				--> functions to manage maps objects (create,
							deallocate, render, ...)
	- rotations.c		--> low-level rotations (matrix rotations)
	- tools.c			--> checks and helper functions

References

fdf's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.