Loading [MathJax]/extensions/tex2jax.js
ProtoTracer  1.0
Real-time 3D rendering and animation engine
All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
TriangleGroup.h
Go to the documentation of this file.
1/**
2 * @file TriangleGroup.h
3 * @brief Defines the TriangleGroup class for dynamic manipulation of triangles in 3D space.
4 *
5 * The TriangleGroup class represents a group of triangles and provides methods for
6 * accessing and managing their vertices, indices, and optional UV mappings.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "Triangle3D.h"
16#include "ITriangleGroup.h"
17#include "IndexGroup.h"
19
20/**
21 * @class TriangleGroup
22 * @brief Represents a dynamic group of 3D triangles.
23 *
24 * This class allows manipulation of a group of triangles based on a static triangle group.
25 * It supports optional UV mapping and provides methods to retrieve triangle and vertex data.
26 *
27 * @tparam vertexCount Number of vertices in the group.
28 * @tparam triangleCount Number of triangles in the group.
29 */
30template<int vertexCount, int triangleCount>
32private:
33 Triangle3D triangles[triangleCount]; ///< Array of triangles in the group.
34 Vector3D vertices[vertexCount]; ///< Array of vertices in the group.
35 const IndexGroup* indexGroup; ///< Pointer to the index group defining triangle vertices.
36 const IndexGroup* uvIndexGroup; ///< Pointer to the UV index group defining texture coordinates.
37 const Vector2D* uvVertices; ///< Pointer to the array of UV coordinates.
38 bool hasUV = false; ///< Indicates whether UV mapping is enabled.
39
40public:
41 /**
42 * @brief Constructs a TriangleGroup from a static triangle group.
43 * @param triangleGroup Pointer to a static triangle group to initialize this group.
44 */
46
47 /**
48 * @brief Gets the index group defining triangle vertices.
49 * @return Pointer to the index group.
50 */
51 const IndexGroup* GetIndexGroup() override;
52
53 /**
54 * @brief Gets the number of triangles in the group.
55 * @return Number of triangles.
56 */
57 int GetTriangleCount() override;
58
59 /**
60 * @brief Gets the array of vertices in the group.
61 * @return Pointer to the array of vertices.
62 */
63 Vector3D* GetVertices() override;
64
65 /**
66 * @brief Gets the number of vertices in the group.
67 * @return Number of vertices.
68 */
69 int GetVertexCount() override;
70
71 /**
72 * @brief Gets the array of triangles in the group.
73 * @return Pointer to the array of triangles.
74 */
76
77 /**
78 * @brief Gets the array of UV vertices in the group.
79 * @return Pointer to the array of UV vertices.
80 */
81 const Vector2D* GetUVVertices() override;
82
83 /**
84 * @brief Gets the UV index group defining texture coordinates.
85 * @return Pointer to the UV index group.
86 */
87 const IndexGroup* GetUVIndexGroup() override;
88};
89
90#include "TriangleGroup.tpp"
Defines the IStaticTriangleGroup interface for managing a collection of static 3D triangles.
Defines the ITriangleGroup interface for managing a collection of mutable 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.
Interface for managing a dynamic group of 3D triangles and associated data.
Represents a group of three unsigned integer indices.
Definition IndexGroup.h:22
Represents a 3D triangle with support for UV mapping and ray intersection testing.
Definition Triangle3D.h:22
Represents a dynamic group of 3D triangles.
Triangle3D triangles[triangleCount]
Array of triangles in the group.
const IndexGroup * uvIndexGroup
Pointer to the UV index group defining texture coordinates.
const IndexGroup * GetIndexGroup() override
Gets the index group defining triangle vertices.
Vector3D * GetVertices() override
Gets the array of vertices in the group.
int GetTriangleCount() override
Gets the number of triangles in the group.
const Vector2D * GetUVVertices() override
Gets the array of UV vertices in the group.
Vector3D vertices[vertexCount]
Array of vertices in the group.
const IndexGroup * indexGroup
Pointer to the index group defining triangle vertices.
const IndexGroup * GetUVIndexGroup() override
Gets the UV index group defining texture coordinates.
bool hasUV
Indicates whether UV mapping is enabled.
const Vector2D * uvVertices
Pointer to the array of UV coordinates.
TriangleGroup(IStaticTriangleGroup *triangleGroup)
Constructs a TriangleGroup from a static triangle group.
Triangle3D * GetTriangles() override
Gets the array of triangles in the group.
int GetVertexCount() override
Gets the number of vertices in the group.
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