# Rendering tutorial

In this tutorial, I'll give an overview of the basics of 3d to 2d projections, better known as "rendering". So if you're planning on writing some code to generate two dimensional graphics from 3d data, this could be a starting point for you. I'll try to explain everything as I'm perceiving it, so there might be plenty of differences with other tutorials. I'll try to give a full overview of all the assumptions I'm making, and I'll try to explain everything to the smallest detail.

Note that this tutorial aims to give you the details of the basics. Don't expect to be able to build a first person shooter after reading this, as there's more to it than what I'm trying to explain here. I'm not familiar with all the advanced techniques needed for building those kind of 3D worlds, so I won't be able to give an introduction on those topics either. I just wrote this as part of my open-sourced brain web site, and this tutorial contains the stuff I needed for a project to display some 3D data.

## Contents

In order to make this tutorial available in a readable format, I have split it up into a couple of pages. A table of contents is shown below. If you're planning on reading it, start with the first section first. I know it'll only get cool by the third chapter, but start from the beginning if you want to get all the details at once.

## About (the graphics in) this tutorial

For my work, I needed a couple of routines such that I can easily read some 3D data from a file and display it my way in a vector format (think postscript and PDF).

A couple of years ago, I have written some C++ classes that can output the FIG file format (http://www.xfig.org/). This is a vectorial format used a lot when editing LaTeX files in Unix operating systems. A couple of standard tools that come with this format allow to easily convert FIG files to postscript or PDF files. As the FIG file format is really easy to understand, and implement code to export it or import it in your own programs, I started a quest to write a complete C++ library for generating these files. The whole library has been pretty helpful to me when I need to display funky things in a vectorial format, where manually drawing the graphics wasn't an option. I'm using the library for many of my drawing needs, as it can easily handle all kinds of things.

I have recently written a 3D layer on top of this FIG library so I can easily generate all kinds of 3D images and export them to postscript of PDF files. I don't like resorting to pixel based graphics fromats when i don't need them. What's more, the resulting graphics from my library are vector based so I wouldn't have to worry about bad looking graphics in my PhD thesis. And some of graphs I need for my thesis are simply not possible to make in any standard graphing application (like displaying data that sits in a triangular or hexagonal grid). While writing the 3D layer I had to relearn the concepts of 3D rendering and projections. I wrote down the stuff I learned, and this tutorial is the result.

All of the graphics in the tutorial were outputted from small programs written with this FIG library and its 3D layer I recently added. I have written a program that can show world and camera views of all kinds of things, and these graphics can be seen all over the tutorial. In order to generate them, I ran my tutorial program, sent its output to a FIG file, used fig2dev to generate EPS files from these FIG files, and then used convert to generate the GIF files you can find in the tutorial. I could also have routed the FIG file through fig2dev in order to create the GIF files, but I would lose the cool looking anti-aliasing that you can find in the GIF files. Indeed, the anti-aliasing you can find in the GIF files is a reminder to show you that everything was generated in a vectorial way.