ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
ObjectDeformer.h
Go to the documentation of this file.
1/**
2 * @file ObjectDeformer.h
3 * @brief Defines the `ObjectDeformer` class for deforming 3D objects using various transformations.
4 *
5 * This class provides methods for applying perspective, sinusoidal, and other custom deformations
6 * to one or more 3D objects.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "Object3D.h"
16
17/**
18 * @class ObjectDeformer
19 * @brief Applies geometric transformations to one or more 3D objects.
20 *
21 * The `ObjectDeformer` class allows for various deformations, including perspective,
22 * sinusoidal waves, and surface-based transformations. It supports operations on both
23 * individual objects and collections of objects.
24 */
26public:
27 /**
28 * @enum Axis
29 * @brief Represents the axis of deformation or clipping.
30 */
31 enum Axis {
32 XAxis, ///< X-axis
33 YAxis, ///< Y-axis
34 ZAxis ///< Z-axis
35 };
36
37private:
38 Object3D** objects; ///< Array of pointers to `Object3D` instances to be deformed.
39 int objectCount = 0; ///< Number of objects in the `objects` array.
40
41 /**
42 * @brief Checks if a given axis value exceeds a clipping threshold.
43 *
44 * @param base The base vector to check.
45 * @param positive Determines whether the check is for positive or negative values.
46 * @param valueCheckAxis The axis to check for clipping.
47 * @return True if the value exceeds the threshold, false otherwise.
48 */
49 bool CheckClipAxis(Vector3D base, bool positive, Axis valueCheckAxis);
50
51public:
52 /**
53 * @brief Constructs an `ObjectDeformer` for a single object.
54 *
55 * @param object Pointer to the `Object3D` to be deformed.
56 */
57 ObjectDeformer(Object3D* object);
58
59 /**
60 * @brief Constructs an `ObjectDeformer` for multiple objects.
61 *
62 * @param objects Pointer to an array of `Object3D` pointers.
63 * @param objectCount Number of objects in the array.
64 */
66
67 /**
68 * @brief Applies a perspective deformation to the object(s).
69 *
70 * @param scaleRatio Scaling factor for the deformation.
71 * @param center Center point for the perspective effect.
72 * @param axis Axis along which the deformation is applied.
73 */
74 void PerspectiveDeform(float scaleRatio, Vector3D center, Axis axis);
75
76 /**
77 * @brief Applies a sinusoidal deformation to the object(s).
78 *
79 * @param magnitude Magnitude of the sinusoidal wave.
80 * @param timeRatio Ratio for time-based animation.
81 * @param periodModifier Modifier for the wave's period.
82 * @param frequencyModifier Modifier for the wave's frequency.
83 * @param axis Axis along which the deformation is applied.
84 */
85 void SinusoidalDeform(float magnitude, float timeRatio, float periodModifier, float frequencyModifier, Axis axis);
86
87 /**
88 * @brief Applies a dropwave deformation to the object(s).
89 *
90 * @param magnitude Magnitude of the dropwave effect.
91 * @param timeRatio Ratio for time-based animation.
92 * @param periodModifier Modifier for the wave's period.
93 * @param frequencyModifier Modifier for the wave's frequency.
94 * @param axis Axis along which the deformation is applied.
95 */
96 void DropwaveDeform(float magnitude, float timeRatio, float periodModifier, float frequencyModifier, Axis axis);
97
98 /**
99 * @brief Applies a sine wave surface deformation to the object(s).
100 *
101 * @param offset Offset for the deformation center.
102 * @param magnitude Magnitude of the wave.
103 * @param timeRatio Ratio for time-based animation.
104 * @param periodModifier Modifier for the wave's period.
105 * @param frequencyModifier Modifier for the wave's frequency.
106 * @param axis Axis along which the deformation is applied.
107 */
108 void SineWaveSurfaceDeform(Vector3D offset, float magnitude, float timeRatio, float periodModifier, float frequencyModifier, Axis axis);
109
110 /**
111 * @brief Applies cosine interpolation deformation to the object(s).
112 *
113 * @param pointMultiplier Array of multipliers for point deformation.
114 * @param points Number of points to deform.
115 * @param scale Scaling factor for the deformation.
116 * @param minAxis Minimum axis value for the deformation range.
117 * @param maxAxis Maximum axis value for the deformation range.
118 * @param selectionAxis Axis used for selecting points to deform.
119 * @param deformAxis Axis along which the deformation is applied.
120 */
121 void CosineInterpolationDeformer(float* pointMultiplier, int points, float scale, float minAxis, float maxAxis, Axis selectionAxis, Axis deformAxis);
122
123 /**
124 * @brief Clips the object(s) along a specified axis.
125 *
126 * @param positive Determines whether to clip positive or negative values.
127 * @param clipAxis Axis along which clipping is performed.
128 * @param valueCheckAxis Axis used for value checks during clipping.
129 */
130 void AxisZeroClipping(bool positive, Axis clipAxis, Axis valueCheckAxis);
131};
Defines the Object3D class, representing a 3D object with geometry, material, and transformation data...
Represents a 3D object with geometry, material, and transformation data.
Definition Object3D.h:28
Applies geometric transformations to one or more 3D objects.
Object3D ** objects
Array of pointers to Object3D instances to be deformed.
void DropwaveDeform(float magnitude, float timeRatio, float periodModifier, float frequencyModifier, Axis axis)
Applies a dropwave deformation to the object(s).
void SineWaveSurfaceDeform(Vector3D offset, float magnitude, float timeRatio, float periodModifier, float frequencyModifier, Axis axis)
Applies a sine wave surface deformation to the object(s).
void CosineInterpolationDeformer(float *pointMultiplier, int points, float scale, float minAxis, float maxAxis, Axis selectionAxis, Axis deformAxis)
Applies cosine interpolation deformation to the object(s).
void AxisZeroClipping(bool positive, Axis clipAxis, Axis valueCheckAxis)
Clips the object(s) along a specified axis.
bool CheckClipAxis(Vector3D base, bool positive, Axis valueCheckAxis)
Checks if a given axis value exceeds a clipping threshold.
void SinusoidalDeform(float magnitude, float timeRatio, float periodModifier, float frequencyModifier, Axis axis)
Applies a sinusoidal deformation to the object(s).
void PerspectiveDeform(float scaleRatio, Vector3D center, Axis axis)
Applies a perspective deformation to the object(s).
Axis
Represents the axis of deformation or clipping.
int objectCount
Number of objects in the objects array.
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26