📋 Table of Contents

  1. Introduction
  2. High-Level Architecture
  3. Plugin System Overview
    1. Purpose
    2. Primitive Interface
      1. Abstract Base (APrimitive)
      2. Plugin Entry Point
      3. Class Responsibilities
      4. Extending the Engine
      5. Example
    3. Light Interface
      1. Abstract Base (ALight)
      2. Plugin Entry Point
      3. Class Responsibilities
      4. Extending the Engine
      5. Example

🧭 Introduction

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.


🧱 High-Level Architecture

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 │                
                                              │         │                
                                              └─────────┘