Building the thing

This project was divided into 4 parts

  1. The first part concerns parsing and reading input files

  2. The second part is a little more mathematical and concerns intersections and ray tracing

  3. Then the management of light, shadows and colors

  4. And finally all the graphic management (windows, hooks, etc.). with the minilibx

Let's look at each of the 4 parts in detail

Parsing

Parsing isn't very complicated, but it does take a long time... a very long time! Here is the list of almost everything that you need to check:

Visually it would look like this:

There are a LOT of parameters to take into account. Just try to make sure it doesn't segfault when you take a scene in the parameter of your program ! :)

Intersections and raytracing

Here, the focus shifts to a core challenge: finding intersections. The goal is to determine where the rays cast from the camera hit different objects in the scene.

This process involves intricate steps to calculate intersections with various shapes like spheres, planes, and cylinders.

  • For spheres, it requires solving quadratic equations to find the points where the ray and the sphere's surface meet.

  • Planes involve straightforward geometric calculations to determine where the ray intersects the plane.

  • Cylinders require a bit more complexity, involving calculations to find where the ray crosses the cylindrical surface.

Successfully mastering these calculations is essential as it forms the foundation for accurately tracing rays and creating the visual representation of the scene.

To sum up, here's a little to-do list of what you can do:

Lights and shadows

In this step, we make things look real with light and shadows. We check if objects are lit or in shadow by sending rays to light sources. We use angles to decide how bright things should be. Background light and distance effects are also added.

Graphic Management

This part involves creating a graphical interface using the minilibx library to display the rendered image. The library provides tools to open windows, handle keyboard inputs, and interact with the user. Here's a breakdown of the steps:

And that's it ! Don't forget other basic things such as error handling and leaks management ;) I really hop that you'll have as much fun as we've had on this project! And we wish you good luck and a lovely adventure. don't forget that if you have any questions, you can come and ask me.

Last updated