![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
A class for managing and rendering 2D vector fields. More...
#include <VectorField2D.h>
Public Member Functions | |
VectorField2D (uint16_t x, uint16_t y) | |
Constructs a 2D vector field with specified dimensions. | |
~VectorField2D () | |
Destructor for the VectorField2D class. | |
void | Boundary () |
Applies boundary conditions to the vector field. | |
void | Diffuse (float viscosity, float dt) |
Performs diffusion on the vector field. | |
void | Advect (float dt) |
Advances the vector field using advection. | |
void | SineField (float ratio, float period, float amplitude) |
Creates a sine wave effect in the vector field. | |
void | StepField (float ratio, float period, float intensity) |
Creates a stepped pattern effect in the vector field. | |
void | MovingSquareField (float ratio, float period, float intensity) |
Creates a moving square pattern in the vector field. | |
void | SpiralField (float ratio, float period, float amplitude) |
Creates a spiral pattern in the vector field. | |
void | ObjectField (Object3D *object, float intensity) |
Generates a field effect based on a 3D object's position and shape. | |
uint16_t | GetCountX () |
Retrieves the number of vectors along the X-axis. | |
uint16_t | GetCountY () |
Retrieves the number of vectors along the Y-axis. | |
void | RenderDensity () |
Renders the density values of the vector field. | |
void | RenderVector () |
Renders the vector field as arrows. | |
void | SetSize (float sizeX, float sizeY) |
Sets the size of the vector field. | |
void | SetPosition (float posX, float posY) |
Sets the position of the vector field. | |
void | SetRotation (float rotation) |
Sets the rotation of the vector field. | |
uint32_t | GetVectorAtPosition (float x, float y, bool &inBounds) |
Retrieves the vector at a specific position in the field. | |
RGBColor | GetRGB (const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override |
Retrieves the RGB color corresponding to a position in the field. | |
![]() | |
virtual | ~Material ()=default |
Virtual destructor for proper cleanup in derived classes. | |
Private Attributes | |
int8_t * | vecXP |
X-component of previous vectors. | |
int8_t * | vecYP |
Y-component of previous vectors. | |
int8_t * | vecDP |
Density of previous vectors. | |
int8_t * | vecX |
X-component of current vectors. | |
int8_t * | vecY |
Y-component of current vectors. | |
int8_t * | vecD |
Density of current vectors. | |
Vector2D | size |
Size of the vector field. | |
Vector2D | position |
Position of the vector field. | |
const uint16_t | countX |
Number of vectors along the X-axis. | |
const uint16_t | countY |
Number of vectors along the Y-axis. | |
float | rotation = 0.0f |
Rotation of the field in degrees. | |
bool | density = false |
Indicates if the field should render density values. | |
Additional Inherited Members | |
![]() | |
enum | Method { Base , Add , Subtract , Multiply , Divide , Darken , Lighten , Screen , Overlay , SoftLight , Replace , EfficientMask , Bypass } |
Defines blending methods for combining colors. More... | |
A class for managing and rendering 2D vector fields.
Definition at line 24 of file VectorField2D.h.
VectorField2D | ( | uint16_t | x, |
uint16_t | y | ||
) |
~VectorField2D | ( | ) |
Destructor for the VectorField2D
class.
Definition at line 13 of file VectorField2D.cpp.
Advances the vector field using advection.
dt | The time step for advection. |
Definition at line 51 of file VectorField2D.cpp.
References Mathematics::Constrain(), countX, countY, vecD, vecDP, vecX, and vecY.
Referenced by VectorFieldAnimation::Update().
void Boundary | ( | ) |
Applies boundary conditions to the vector field.
Definition at line 22 of file VectorField2D.cpp.
Performs diffusion on the vector field.
viscosity | The viscosity of the field. |
dt | The time step for diffusion. |
Definition at line 26 of file VectorField2D.cpp.
References Mathematics::Constrain(), countX, countY, vecD, and vecDP.
Referenced by VectorFieldAnimation::Update().
uint16_t GetCountX | ( | ) |
Retrieves the number of vectors along the X-axis.
Definition at line 217 of file VectorField2D.cpp.
References countX.
uint16_t GetCountY | ( | ) |
Retrieves the number of vectors along the Y-axis.
Definition at line 221 of file VectorField2D.cpp.
References countY.
|
overridevirtual |
Retrieves the RGB color corresponding to a position in the field.
position | The 3D position in the field. |
normal | The normal vector at the position. |
uvw | UVW coordinates at the position. |
Implements Material.
Definition at line 291 of file VectorField2D.cpp.
References GetVectorAtPosition(), size, Vector2D::X, Vector3D::X, Vector2D::Y, and Vector3D::Y.
Retrieves the vector at a specific position in the field.
x | The X-coordinate of the position. |
y | The Y-coordinate of the position. |
inBounds | Output parameter indicating if the position is within bounds. |
Definition at line 247 of file VectorField2D.cpp.
References Mathematics::BilinearInterpolation(), countX, countY, Mathematics::IsClose(), Mathematics::Map(), position, Vector2D::Rotate(), rotation, size, vecD, Vector2D::X, and Vector2D::Y.
Referenced by GetRGB().
Creates a moving square pattern in the vector field.
ratio | The frequency multiplier. |
period | The period of the movement. |
intensity | The intensity of the movement. |
Definition at line 129 of file VectorField2D.cpp.
References Mathematics::Constrain(), countX, countY, Mathematics::MPI, size, vecD, Vector2D::X, and Vector2D::Y.
Generates a field effect based on a 3D object's position and shape.
object | Pointer to the 3D object. |
intensity | The intensity of the effect. |
Definition at line 167 of file VectorField2D.cpp.
References Mathematics::Constrain(), countX, countY, Object3D::GetTriangleGroup(), ITriangleGroup::GetTriangles(), size, vecD, vecX, vecY, Vector2D::X, and Vector2D::Y.
Referenced by VectorFieldAnimation::Update().
void RenderDensity | ( | ) |
Renders the density values of the vector field.
Definition at line 225 of file VectorField2D.cpp.
References density.
Referenced by VectorFieldAnimation::Update().
void RenderVector | ( | ) |
Renders the vector field as arrows.
Definition at line 229 of file VectorField2D.cpp.
References density.
Sets the position of the vector field.
posX | The X-coordinate of the position. |
posY | The Y-coordinate of the position. |
Definition at line 238 of file VectorField2D.cpp.
References position, Vector2D::X, and Vector2D::Y.
Referenced by VectorFieldAnimation::Update().
Sets the rotation of the vector field.
rotation | The rotation angle in degrees. |
Definition at line 243 of file VectorField2D.cpp.
References rotation.
Sets the size of the vector field.
sizeX | The width of the field. |
sizeY | The height of the field. |
Definition at line 233 of file VectorField2D.cpp.
References size, Vector2D::X, and Vector2D::Y.
Referenced by VectorFieldAnimation::Update().
Creates a sine wave effect in the vector field.
ratio | The frequency multiplier. |
period | The period of the sine wave. |
amplitude | The amplitude of the sine wave. |
Definition at line 93 of file VectorField2D.cpp.
References Mathematics::Constrain(), countX, countY, size, vecD, vecX, vecY, Vector2D::X, and Vector2D::Y.
Creates a spiral pattern in the vector field.
ratio | The frequency multiplier. |
period | The period of the spiral. |
amplitude | The amplitude of the spiral. |
Definition at line 151 of file VectorField2D.cpp.
References Mathematics::Constrain(), countX, countY, size, vecX, vecY, Vector2D::X, and Vector2D::Y.
Creates a stepped pattern effect in the vector field.
ratio | The frequency multiplier. |
period | The period of the steps. |
intensity | The intensity of the steps. |
Definition at line 108 of file VectorField2D.cpp.
References Mathematics::Constrain(), countX, countY, Mathematics::MPI, size, vecD, vecX, vecY, Vector2D::X, and Vector2D::Y.
Number of vectors along the X-axis.
Definition at line 35 of file VectorField2D.h.
Referenced by Advect(), Diffuse(), GetCountX(), GetVectorAtPosition(), MovingSquareField(), ObjectField(), SineField(), SpiralField(), and StepField().
Number of vectors along the Y-axis.
Definition at line 36 of file VectorField2D.h.
Referenced by Advect(), Diffuse(), GetCountY(), GetVectorAtPosition(), MovingSquareField(), ObjectField(), SineField(), SpiralField(), and StepField().
Indicates if the field should render density values.
Definition at line 38 of file VectorField2D.h.
Referenced by RenderDensity(), and RenderVector().
|
private |
Position of the vector field.
Definition at line 34 of file VectorField2D.h.
Referenced by GetVectorAtPosition(), and SetPosition().
|
private |
Rotation of the field in degrees.
Definition at line 37 of file VectorField2D.h.
Referenced by GetVectorAtPosition(), and SetRotation().
|
private |
Size of the vector field.
Definition at line 33 of file VectorField2D.h.
Referenced by GetRGB(), GetVectorAtPosition(), MovingSquareField(), ObjectField(), SetSize(), SineField(), SpiralField(), and StepField().
|
private |
Density of current vectors.
Definition at line 31 of file VectorField2D.h.
Referenced by Advect(), Diffuse(), GetVectorAtPosition(), MovingSquareField(), ObjectField(), SineField(), StepField(), VectorField2D(), and ~VectorField2D().
|
private |
Density of previous vectors.
Definition at line 28 of file VectorField2D.h.
Referenced by Advect(), Diffuse(), VectorField2D(), and ~VectorField2D().
|
private |
X-component of current vectors.
Definition at line 29 of file VectorField2D.h.
Referenced by Advect(), ObjectField(), SineField(), SpiralField(), StepField(), VectorField2D(), and ~VectorField2D().
|
private |
X-component of previous vectors.
Definition at line 26 of file VectorField2D.h.
Referenced by VectorField2D(), and ~VectorField2D().
|
private |
Y-component of current vectors.
Definition at line 30 of file VectorField2D.h.
Referenced by Advect(), ObjectField(), SineField(), SpiralField(), StepField(), VectorField2D(), and ~VectorField2D().
|
private |
Y-component of previous vectors.
Definition at line 27 of file VectorField2D.h.
Referenced by VectorField2D(), and ~VectorField2D().