This document explains the internal structure of the Raytracer project and how to extend it using a plugin-based architecture. The goal is to allow the addition of new primitives and lights without modifying or recompiling the core engine.
The high-level architecture flow is shown below:
┌──────────┐
│ │
│ Parser │
│ │
└────┬─────┘
│
▼
┌────────────────┐
│ │
│ Plugins loader │
│ │
└───────┬────────┘
│
▼
┌─────────┐
│ │
│ Factory │
│ │
└────┬────┘
│
▼
┌──────────┐
│ │
│ Renderer │
│ │
└────┬─────┘
│
▼
┌────────────────┐
│ │
│ Graphic Render │
│ │
└────────────────┘
This is the Raytracer execution process
┌─────────────────────┐
│ │
│ Antialiasing Config │
┌───►│ │
│ └─────────────────────┘
│ ┌───────────────┐
│ │ │
├───►│ Camera Config │
│ │ │
│ └───────────────┘
┌────────────┐ ┌──────────┐ │ ┌───────────────┐
│ │ │ │ │ │ │
│ config.cfg ├─────►│ Parser │───────┼───►│ Lights Config │
│ │ │ │ │ │ │
└────────────┘ └──────────┘ │ └───────────────┘
│ ┌───────────────────┐
│ │ │
│ │ Primitives Config │
├───►│ │
│ └───────────────────┘
│ ┌──────────────────┐
│ │ │
└───►│ Rendering Config │
│ │
└──────────────────┘
┌────────────┐
┌────────────────┐ ┌────────────────────┐ ┌───►│ IPrimitive │
│ │ (.so) │ │(or)│ └────────────┘
│ ./plugins/*.so ├──────►│ Plugins loader ├────┤
│ │ │ │ │ ┌────────┐
└────────────────┘ └────────────────────┘ └───►│ ILight │
└────────┘
┌───────────────┐ ┌────────────┐
│ │ ┌─────────┐ │ │
│ Camera Config ┼────┐ │ │ ┌──►│ Primitives │
│ │ │ │ │ │ │ │
└───────────────┘ │ │ │ │ └────────────┘
┌───────────────┐ │ ┌─────────┐ │ │ │ ┌────────┐
│ │ │ │ │ │ │ │ │ │
│ Lights Config ├────┼►│ Factory ├────►│ Plugins │─┼──►│ Lights │
│ │ │ │ │ │ │ │ │ │
└───────────────┘ │ └─────────┘ │ │ │ └────────┘
┌───────────────────┐ │ │ │ │ ┌────────┐
│ │ │ │ │ │ │ │
│ Primitives Config ├────┘ │ │ └──►│ Camera │
│ │ └─────────┘ │ │
└───────────────────┘ └────────┘
┌────────────┐
│ │
│ Primitives ├─┐
│ │ │
└────────────┘ │
┌────────┐ │ ┌──────────┐ ┌──────────┐
│ │ │ │ │ │ │
│ Lights ├─┼─►│ Renderer ├────►│ file.ppm │
│ │ │ │ │ │ │
└────────┘ │ └──────────┘ └──────────┘
┌────────┐ │
│ │ │
│ Camera ├─┘
│ │
└────────┘
┌──────────┐
│ │
┌──────────┐ ┌────────────────┐ ┌─►│ file.png │
│ │ │ ├───┘ │ │
│ file.ppm ├───►│ Graphic Render │ └──────────┘
│ │ │ ├───┐ ┌─────────┐
└──────────┘ └────────────────┘ │ │ │
└─►│ preview │
│ │
└─────────┘
Parser Load the .cfg file passed in input and create config class.