ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
StaticTriangleGroup.h
Go to the documentation of this file.
1/**
2 * @file StaticTriangleGroup.h
3 * @brief Defines the StaticTriangleGroup class for managing 3D triangle geometry.
4 *
5 * The StaticTriangleGroup class represents a fixed collection of 3D triangles,
6 * vertices, and associated UV data. It provides methods to access and manipulate
7 * this data for rendering or simulation purposes.
8 *
9 * @date 22/12/2024
10 * @version 1.0
11 * @tparam vertexCount The number of vertices in the group.
12 * @tparam triangleCount The number of triangles in the group.
13 * @author Coela Can't
14 */
15
16#pragma once
17
18#include "Triangle3D.h"
19#include "IndexGroup.h"
21
22/**
23 * @class StaticTriangleGroup
24 * @brief Represents a static collection of 3D triangles and associated vertex/UV data.
25 * @tparam vertexCount Number of vertices in the group.
26 * @tparam triangleCount Number of triangles in the group.
27 */
28template<int vertexCount, int triangleCount>
30private:
31 Triangle3D triangles[triangleCount]; ///< Array of 3D triangles in the group.
32 Vector3D* vertices; ///< Array of vertex positions.
33 const IndexGroup* indexGroup; ///< Index group defining triangle vertex indices.
34 const IndexGroup* uvIndexGroup; ///< Index group for UV coordinates (if available).
35 const Vector2D* uvVertices; ///< Array of UV coordinates for texture mapping.
36 const bool hasUVB; ///< Indicates whether the group contains UV data.
37
38public:
39 /**
40 * @brief Constructor for a group without UV data.
41 * @param vertices Array of vertex positions.
42 * @param indexGroup Index group defining triangle vertex indices.
43 */
45
46 /**
47 * @brief Constructor for a group with UV data.
48 * @param vertices Array of vertex positions.
49 * @param indexGroup Index group defining triangle vertex indices.
50 * @param uvIndexGroup Index group for UV coordinates.
51 * @param uvVertices Array of UV coordinates for texture mapping.
52 */
54
55 /**
56 * @brief Checks if the group has UV data.
57 * @return True if UV data is present, otherwise false.
58 */
59 const bool HasUV() override;
60
61 /**
62 * @brief Retrieves the triangle index group.
63 * @return Pointer to the IndexGroup defining triangle vertex indices.
64 */
65 const IndexGroup* GetIndexGroup() override;
66
67 /**
68 * @brief Gets the total number of triangles in the group.
69 * @return The number of triangles.
70 */
71 const int GetTriangleCount() override;
72
73 /**
74 * @brief Retrieves the array of vertex positions.
75 * @return Pointer to the array of vertices.
76 */
77 Vector3D* GetVertices() override;
78
79 /**
80 * @brief Gets the total number of vertices in the group.
81 * @return The number of vertices.
82 */
83 const int GetVertexCount() override;
84
85 /**
86 * @brief Retrieves the array of triangles in the group.
87 * @return Pointer to the array of triangles.
88 */
90
91 /**
92 * @brief Retrieves the array of UV coordinates.
93 * @return Pointer to the array of UV coordinates, or nullptr if not available.
94 */
95 const Vector2D* GetUVVertices() override;
96
97 /**
98 * @brief Retrieves the UV index group.
99 * @return Pointer to the UV IndexGroup, or nullptr if not available.
100 */
101 const IndexGroup* GetUVIndexGroup() override;
102};
103
Defines the IStaticTriangleGroup interface for managing a collection of static 3D triangles.
Defines the IndexGroup class for handling a group of three unsigned integer indices.
Defines the Triangle3D class for representing and manipulating 3D triangles.
Interface for managing a static group of 3D triangles and associated data.
Represents a group of three unsigned integer indices.
Definition IndexGroup.h:22
Represents a static collection of 3D triangles and associated vertex/UV data.
Triangle3D triangles[triangleCount]
Array of 3D triangles in the group.
const IndexGroup * uvIndexGroup
Index group for UV coordinates (if available).
const int GetTriangleCount() override
Gets the total number of triangles in the group.
StaticTriangleGroup(Vector3D *vertices, const IndexGroup *indexGroup)
Constructor for a group without UV data.
const bool hasUVB
Indicates whether the group contains UV data.
const IndexGroup * GetIndexGroup() override
Retrieves the triangle index group.
Vector3D * GetVertices() override
Retrieves the array of vertex positions.
const Vector2D * GetUVVertices() override
Retrieves the array of UV coordinates.
Vector3D * vertices
Array of vertex positions.
const IndexGroup * indexGroup
Index group defining triangle vertex indices.
const IndexGroup * GetUVIndexGroup() override
Retrieves the UV index group.
const Vector2D * uvVertices
Array of UV coordinates for texture mapping.
Triangle3D * GetTriangles() override
Retrieves the array of triangles in the group.
const int GetVertexCount() override
Gets the total number of vertices in the group.
StaticTriangleGroup(Vector3D *vertices, const IndexGroup *indexGroup, const IndexGroup *uvIndexGroup, const Vector2D *uvVertices)
Constructor for a group with UV data.
const bool HasUV() override
Checks if the group has UV data.
Represents a 3D triangle with support for UV mapping and ray intersection testing.
Definition Triangle3D.h:22
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26