ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Object3D.h
Go to the documentation of this file.
1/**
2 * @file Object3D.h
3 * @brief Defines the `Object3D` class, representing a 3D object with geometry, material, and transformation data.
4 *
5 * This class provides methods for managing 3D objects, including transformations,
6 * material assignments, and geometric modifications.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "../Materials/Material.h"
16#include "../../Utils/Math/Transform.h"
17#include "../../Renderer/Utils/TriangleGroup.h"
18#include "../../Renderer/Utils/StaticTriangleGroup.h"
19
20/**
21 * @class Object3D
22 * @brief Represents a 3D object with geometry, material, and transformation data.
23 *
24 * The `Object3D` class manages the geometric representation, transformation, and material
25 * properties of a 3D object. It provides methods to enable or disable the object, modify
26 * its transformations, reset its geometry, and retrieve its material or geometry data.
27 */
28class Object3D {
29private:
30 Transform transform; ///< Transform object representing the object's position, rotation, and scale.
31 IStaticTriangleGroup* originalTriangles; ///< Pointer to the static representation of the object's geometry.
32 ITriangleGroup* modifiedTriangles; ///< Pointer to the modifiable representation of the object's geometry.
33 Material* material; ///< Pointer to the material assigned to the object.
34 bool enabled = true; ///< Indicates whether the object is currently enabled.
35
36public:
37 /**
38 * @brief Constructs an `Object3D` instance.
39 *
40 * @param originalTriangles Pointer to the static representation of the object's geometry.
41 * @param modifiedTriangles Pointer to the modifiable representation of the object's geometry.
42 * @param material Pointer to the material assigned to the object.
43 */
45
46 /**
47 * @brief Destructor for `Object3D`.
48 */
49 ~Object3D();
50
51 /**
52 * @brief Enables the object, making it visible and active.
53 */
54 void Enable();
55
56 /**
57 * @brief Disables the object, making it invisible and inactive.
58 */
59 void Disable();
60
61 /**
62 * @brief Checks if the object is enabled.
63 * @return True if the object is enabled, otherwise false.
64 */
65 bool IsEnabled();
66
67 /**
68 * @brief Retrieves the object's center offset.
69 * @return A `Vector3D` representing the object's center offset.
70 */
72
73 /**
74 * @brief Retrieves the minimum and maximum dimensions of the object.
75 *
76 * @param minimum Reference to a `Vector3D` to store the minimum dimensions.
77 * @param maximum Reference to a `Vector3D` to store the maximum dimensions.
78 */
79 void GetMinMaxDimensions(Vector3D& minimum, Vector3D& maximum);
80
81 /**
82 * @brief Retrieves the size of the object.
83 * @return A `Vector3D` representing the object's size.
84 */
86
87 /**
88 * @brief Retrieves the object's transformation data.
89 * @return Pointer to the `Transform` object.
90 */
92
93 /**
94 * @brief Sets the object's transformation data.
95 *
96 * @param t Reference to the new `Transform`.
97 */
98 void SetTransform(Transform& t);
99
100 /**
101 * @brief Resets the object's vertices to their original positions.
102 */
103 void ResetVertices();
104
105 /**
106 * @brief Updates the object's geometry based on its transformation data.
107 */
108 void UpdateTransform();
109
110 /**
111 * @brief Retrieves the modifiable geometry of the object.
112 * @return Pointer to the `ITriangleGroup` representing the object's modifiable geometry.
113 */
115
116 /**
117 * @brief Retrieves the material assigned to the object.
118 * @return Pointer to the `Material` assigned to the object.
119 */
121
122 /**
123 * @brief Sets the material for the object.
124 *
125 * @param material Pointer to the new `Material` to be assigned.
126 */
128};
Interface for managing a static group of 3D triangles and associated data.
Interface for managing a dynamic group of 3D triangles and associated data.
Abstract base class for rendering materials.
Definition Material.h:27
Represents a 3D object with geometry, material, and transformation data.
Definition Object3D.h:28
void Disable()
Disables the object, making it invisible and inactive.
Definition Object3D.cpp:13
bool IsEnabled()
Checks if the object is enabled.
Definition Object3D.cpp:17
ITriangleGroup * modifiedTriangles
Pointer to the modifiable representation of the object's geometry.
Definition Object3D.h:32
IStaticTriangleGroup * originalTriangles
Pointer to the static representation of the object's geometry.
Definition Object3D.h:31
Transform transform
Transform object representing the object's position, rotation, and scale.
Definition Object3D.h:30
void ResetVertices()
Resets the object's vertices to their original positions.
Definition Object3D.cpp:54
void SetTransform(Transform &t)
Sets the object's transformation data.
Definition Object3D.cpp:50
Material * GetMaterial()
Retrieves the material assigned to the object.
Definition Object3D.cpp:76
Vector3D GetSize()
Retrieves the size of the object.
Definition Object3D.cpp:38
bool enabled
Indicates whether the object is currently enabled.
Definition Object3D.h:34
~Object3D()
Destructor for Object3D.
Definition Object3D.cpp:7
Vector3D GetCenterOffset()
Retrieves the object's center offset.
Definition Object3D.cpp:21
void Enable()
Enables the object, making it visible and active.
Definition Object3D.cpp:9
void UpdateTransform()
Updates the object's geometry based on its transformation data.
Definition Object3D.cpp:60
void SetMaterial(Material *material)
Sets the material for the object.
Definition Object3D.cpp:80
ITriangleGroup * GetTriangleGroup()
Retrieves the modifiable geometry of the object.
Definition Object3D.cpp:72
void GetMinMaxDimensions(Vector3D &minimum, Vector3D &maximum)
Retrieves the minimum and maximum dimensions of the object.
Definition Object3D.cpp:31
Material * material
Pointer to the material assigned to the object.
Definition Object3D.h:33
Transform * GetTransform()
Retrieves the object's transformation data.
Definition Object3D.cpp:46
Represents a 3D transformation including position, rotation, and scale.
Definition Transform.h:22
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26