ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Rasterizer.h
Go to the documentation of this file.
1/**
2 * @file Rasterizer.h
3 * @brief Provides functionality for rasterizing 3D scenes into 2D camera views.
4 *
5 * The Rasterizer class handles rendering a 3D scene by projecting it onto a 2D camera view.
6 * It supports triangle-based rasterization with optional acceleration structures for efficiency.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't, moepforfreedom
11 */
12
13#pragma once
14
17#include "../../Camera/Camera.h"
18#include "../../Scene/Scene.h"
19#include "../Utils/Triangle2D.h"
20#include "../Utils/QuadTree.h"
21#include "../Utils/Node.h"
22
23/**
24 * @class Rasterizer
25 * @brief Provides static methods for rasterizing 3D scenes into 2D camera views.
26 */
28private:
29 static Quaternion rayDirection; ///< Direction of the ray cast for rasterization.
30
31 /**
32 * @brief Determines the color of a pixel by checking which triangle it intersects.
33 * @param triangles Array of 2D triangles to check against.
34 * @param numTriangles Number of triangles in the array.
35 * @param pixelRay The 2D pixel ray to test.
36 * @return The color of the intersected triangle, or a default color if no intersection.
37 */
38 static RGBColor CheckRasterPixel(Triangle2D** triangles, int numTriangles, Vector2D pixelRay);
39
40 /**
41 * @brief Optimized version of `CheckRasterPixel` using acceleration structures.
42 * @param triangles Array of 2D triangles to check against.
43 * @param numTriangles Number of triangles in the array.
44 * @param pixelRay The 2D pixel ray to test.
45 * @return The color of the intersected triangle, or a default color if no intersection.
46 */
47 static RGBColor CheckRasterPixelAccel(Triangle2D** triangles, int numTriangles, Vector2D pixelRay);
48
49public:
50 /**
51 * @brief Rasterizes a 3D scene onto a 2D camera view.
52 * @param scene Pointer to the 3D scene to render.
53 * @param camera Pointer to the camera used for projection.
54 */
55 static void Rasterize(Scene* scene, CameraBase* camera);
56};
Declares the Camera template class for managing camera behavior and pixel groups.
Defines the Node class for quadtree spatial partitioning in 2D space.
Defines the QuadTree class for spatial partitioning in 2D space.
Defines the Quaternion class for 3D rotations and transformations.
Defines the Scene class for managing objects and effects in a 3D environment.
Defines the Transform class for managing position, rotation, and scale of objects.
Defines the Triangle2D class for representing and manipulating 2D triangles.
Base class for managing camera properties and transformations.
Definition CameraBase.h:26
A mathematical construct representing a rotation in 3D space.
Definition Quaternion.h:30
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
Provides static methods for rasterizing 3D scenes into 2D camera views.
Definition Rasterizer.h:27
static void Rasterize(Scene *scene, CameraBase *camera)
Rasterizes a 3D scene onto a 2D camera view.
static RGBColor CheckRasterPixel(Triangle2D **triangles, int numTriangles, Vector2D pixelRay)
Determines the color of a pixel by checking which triangle it intersects.
static RGBColor CheckRasterPixelAccel(Triangle2D **triangles, int numTriangles, Vector2D pixelRay)
Optimized version of CheckRasterPixel using acceleration structures.
Definition Rasterizer.cpp:5
static Quaternion rayDirection
Direction of the ray cast for rasterization.
Definition Rasterizer.h:29
Manages a collection of 3D objects and applies optional screen-space effects.
Definition Scene.h:25
Represents a 2D triangle with support for UV mapping, depth, and intersection testing.
Definition Triangle2D.h:25
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27