Reemplazar Wave Grid por Lissajous Curve 3D

Cambiar figura "Wave Grid" (malla ondeante) por curva de Lissajous 3D,
con ecuaciones paramétricas más hipnóticas y resultónas visualmente.

## Cambios Principales

**Archivos renombrados:**
- `wave_grid_shape.h/cpp` → `lissajous_shape.h/cpp`
- Clase `WaveGridShape` → `LissajousShape`

**Ecuaciones implementadas:**
- x(t) = A * sin(3t + φx)  - Frecuencia 3 en X
- y(t) = A * sin(2t)       - Frecuencia 2 en Y
- z(t) = A * sin(t + φz)   - Frecuencia 1 en Z
- Ratio 3:2:1 produce patrón de "trenza elegante"

**Animación:**
- Rotación global dual (ejes X/Y)
- Animación de fase continua (morphing)
- Más dinámica y orgánica que Wave Grid

**defines.h:**
- `WAVE_GRID_*` → `LISSAJOUS_*` constantes
- `ShapeType::WAVE_GRID` → `ShapeType::LISSAJOUS`

**engine.cpp:**
- Actualizado include y instanciación
- Arrays de figuras DEMO actualizados
- Tecla W ahora activa Lissajous

## Resultado

Curva 3D paramétrica hipnótica con patrón entrelazado,
rotación continua y morphing de fase. Más espectacular
que el grid ondeante anterior. 🌀

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-07 12:31:38 +02:00
parent c55d6de687
commit 6cb3c2eef9
8 changed files with 233 additions and 232 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include <SDL3/SDL_stdinc.h> // for Uint64
#include <vector> // for std::vector in DynamicThemeKeyframe/DynamicTheme
// Configuración de ventana y pantalla
@@ -100,7 +101,7 @@ enum class ShapeType {
CUBE, // Cubo rotante
HELIX, // Espiral 3D
TORUS, // Toroide/donut
WAVE_GRID, // Malla ondeante
LISSAJOUS, // Malla ondeante
CYLINDER, // Cilindro rotante
ICOSAHEDRON, // Icosaedro D20
ATOM, // Átomo con órbitas
@@ -149,12 +150,14 @@ constexpr float HELIX_NUM_TURNS = 3.0f; // Número de vueltas completas
constexpr float HELIX_ROTATION_SPEED_Y = 1.2f; // Velocidad rotación eje Y (rad/s)
constexpr float HELIX_PHASE_SPEED = 0.5f; // Velocidad de animación vertical (rad/s)
// Configuración de Wave Grid (malla ondeante 3D)
constexpr float WAVE_GRID_SIZE_FACTOR = 0.35f; // Tamaño del grid (proporción de altura)
constexpr float WAVE_GRID_AMPLITUDE = 0.15f; // Amplitud de las ondas (proporción de altura)
constexpr float WAVE_GRID_FREQUENCY = 3.0f; // Frecuencia de ondas (ciclos por grid)
constexpr float WAVE_GRID_PHASE_SPEED = 2.0f; // Velocidad de animación de ondas (rad/s)
constexpr float WAVE_GRID_ROTATION_SPEED_Y = 0.4f; // Velocidad rotación eje Y (rad/s)
// Configuración de Lissajous Curve 3D (curva paramétrica)
constexpr float LISSAJOUS_SIZE_FACTOR = 0.35f; // Amplitud de la curva (proporción de altura)
constexpr float LISSAJOUS_FREQ_X = 3.0f; // Frecuencia en eje X (ratio 3:2:1)
constexpr float LISSAJOUS_FREQ_Y = 2.0f; // Frecuencia en eje Y
constexpr float LISSAJOUS_FREQ_Z = 1.0f; // Frecuencia en eje Z
constexpr float LISSAJOUS_PHASE_SPEED = 1.0f; // Velocidad de animación de fase (rad/s)
constexpr float LISSAJOUS_ROTATION_SPEED_X = 0.4f; // Velocidad rotación global X (rad/s)
constexpr float LISSAJOUS_ROTATION_SPEED_Y = 0.6f; // Velocidad rotación global Y (rad/s)
// Configuración de Torus (toroide/donut 3D)
constexpr float TORUS_MAJOR_RADIUS_FACTOR = 0.25f; // Radio mayor R (centro torus a centro tubo)
@@ -254,11 +257,11 @@ constexpr float PI = 3.14159265358979323846f; // Constante PI
#ifdef _WIN32
#include <windows.h>
#elif defined(__APPLE__)
#include <limits.h>
#include <mach-o/dyld.h>
#include <limits.h>
#else
#include <unistd.h>
#include <limits.h>
#include <unistd.h>
#endif
inline std::string getExecutableDirectory() {

View File

@@ -30,10 +30,10 @@
#include "shapes/cylinder_shape.h" // for CylinderShape
#include "shapes/helix_shape.h" // for HelixShape
#include "shapes/icosahedron_shape.h" // for IcosahedronShape
#include "shapes/lissajous_shape.h" // for LissajousShape
#include "shapes/png_shape.h" // for PNGShape
#include "shapes/sphere_shape.h" // for SphereShape
#include "shapes/torus_shape.h" // for TorusShape
#include "shapes/wave_grid_shape.h" // for WaveGridShape
// getExecutableDirectory() ya está definido en defines.h como inline
@@ -175,8 +175,7 @@ bool Engine::initialize(int width, int height, int zoom, bool fullscreen) {
}
// Ordenar por tamaño (grande → pequeño): big(16) → normal(10) → small(6) → tiny(4)
std::sort(texture_files.begin(), texture_files.end(),
[](const TextureInfo& a, const TextureInfo& b) {
std::sort(texture_files.begin(), texture_files.end(), [](const TextureInfo& a, const TextureInfo& b) {
return a.width > b.width; // Descendente por tamaño
});
@@ -405,7 +404,7 @@ void Engine::handleEvents() {
break;
case SDLK_W:
activateShape(ShapeType::WAVE_GRID);
activateShape(ShapeType::LISSAJOUS);
break;
case SDLK_E:
@@ -1461,41 +1460,54 @@ void Engine::initializeDynamicThemes() {
dynamic_themes_[0] = {
"SUNRISE",
"AMANECER",
255, 200, 100, // Color texto: amarillo cálido
255,
200,
100, // Color texto: amarillo cálido
{
// Keyframe 0: Noche oscura (estado inicial)
{
20.0f / 255.0f, 25.0f / 255.0f, 60.0f / 255.0f, // Fondo superior: azul medianoche
10.0f / 255.0f, 10.0f / 255.0f, 30.0f / 255.0f, // Fondo inferior: azul muy oscuro
{{100, 100, 150}, {120, 120, 170}, {90, 90, 140}, {110, 110, 160},
{95, 95, 145}, {105, 105, 155}, {100, 100, 150}, {115, 115, 165}}, // Pelotas azules tenues
20.0f / 255.0f,
25.0f / 255.0f,
60.0f / 255.0f, // Fondo superior: azul medianoche
10.0f / 255.0f,
10.0f / 255.0f,
30.0f / 255.0f, // Fondo inferior: azul muy oscuro
{{100, 100, 150}, {120, 120, 170}, {90, 90, 140}, {110, 110, 160}, {95, 95, 145}, {105, 105, 155}, {100, 100, 150}, {115, 115, 165}}, // Pelotas azules tenues
0.0f // Sin transición (estado inicial)
},
// Keyframe 1: Alba naranja-rosa
{
180.0f / 255.0f, 100.0f / 255.0f, 120.0f / 255.0f, // Fondo superior: naranja-rosa
255.0f / 255.0f, 140.0f / 255.0f, 100.0f / 255.0f, // Fondo inferior: naranja cálido
{{255, 180, 100}, {255, 160, 80}, {255, 200, 120}, {255, 150, 90},
{255, 190, 110}, {255, 170, 95}, {255, 185, 105}, {255, 165, 88}}, // Pelotas naranjas
180.0f / 255.0f,
100.0f / 255.0f,
120.0f / 255.0f, // Fondo superior: naranja-rosa
255.0f / 255.0f,
140.0f / 255.0f,
100.0f / 255.0f, // Fondo inferior: naranja cálido
{{255, 180, 100}, {255, 160, 80}, {255, 200, 120}, {255, 150, 90}, {255, 190, 110}, {255, 170, 95}, {255, 185, 105}, {255, 165, 88}}, // Pelotas naranjas
4.0f // 4 segundos para llegar aquí
},
// Keyframe 2: Día brillante amarillo
{
255.0f / 255.0f, 240.0f / 255.0f, 180.0f / 255.0f, // Fondo superior: amarillo claro
255.0f / 255.0f, 255.0f / 255.0f, 220.0f / 255.0f, // Fondo inferior: amarillo muy claro
{{255, 255, 200}, {255, 255, 180}, {255, 255, 220}, {255, 255, 190},
{255, 255, 210}, {255, 255, 185}, {255, 255, 205}, {255, 255, 195}}, // Pelotas amarillas brillantes
255.0f / 255.0f,
240.0f / 255.0f,
180.0f / 255.0f, // Fondo superior: amarillo claro
255.0f / 255.0f,
255.0f / 255.0f,
220.0f / 255.0f, // Fondo inferior: amarillo muy claro
{{255, 255, 200}, {255, 255, 180}, {255, 255, 220}, {255, 255, 190}, {255, 255, 210}, {255, 255, 185}, {255, 255, 205}, {255, 255, 195}}, // Pelotas amarillas brillantes
3.0f // 3 segundos para llegar aquí
},
// Keyframe 3: Vuelta a noche (para loop)
{
20.0f / 255.0f, 25.0f / 255.0f, 60.0f / 255.0f, // Fondo superior: azul medianoche
10.0f / 255.0f, 10.0f / 255.0f, 30.0f / 255.0f, // Fondo inferior: azul muy oscuro
{{100, 100, 150}, {120, 120, 170}, {90, 90, 140}, {110, 110, 160},
{95, 95, 145}, {105, 105, 155}, {100, 100, 150}, {115, 115, 165}}, // Pelotas azules tenues
20.0f / 255.0f,
25.0f / 255.0f,
60.0f / 255.0f, // Fondo superior: azul medianoche
10.0f / 255.0f,
10.0f / 255.0f,
30.0f / 255.0f, // Fondo inferior: azul muy oscuro
{{100, 100, 150}, {120, 120, 170}, {90, 90, 140}, {110, 110, 160}, {95, 95, 145}, {105, 105, 155}, {100, 100, 150}, {115, 115, 165}}, // Pelotas azules tenues
5.0f // 5 segundos para volver a noche
}
},
}},
true // Loop = true
};
@@ -1505,33 +1517,43 @@ void Engine::initializeDynamicThemes() {
dynamic_themes_[1] = {
"OCEAN WAVES",
"OLAS OCEANICAS",
100, 220, 255, // Color texto: cian claro
100,
220,
255, // Color texto: cian claro
{
// Keyframe 0: Profundidad oceánica (azul oscuro)
{
20.0f / 255.0f, 50.0f / 255.0f, 100.0f / 255.0f, // Fondo superior: azul marino
10.0f / 255.0f, 30.0f / 255.0f, 60.0f / 255.0f, // Fondo inferior: azul muy oscuro
{{60, 100, 180}, {50, 90, 170}, {70, 110, 190}, {55, 95, 175},
{65, 105, 185}, {58, 98, 172}, {62, 102, 182}, {52, 92, 168}}, // Pelotas azul oscuro
20.0f / 255.0f,
50.0f / 255.0f,
100.0f / 255.0f, // Fondo superior: azul marino
10.0f / 255.0f,
30.0f / 255.0f,
60.0f / 255.0f, // Fondo inferior: azul muy oscuro
{{60, 100, 180}, {50, 90, 170}, {70, 110, 190}, {55, 95, 175}, {65, 105, 185}, {58, 98, 172}, {62, 102, 182}, {52, 92, 168}}, // Pelotas azul oscuro
0.0f // Estado inicial
},
// Keyframe 1: Aguas poco profundas (turquesa brillante)
{
100.0f / 255.0f, 200.0f / 255.0f, 230.0f / 255.0f, // Fondo superior: turquesa claro
50.0f / 255.0f, 150.0f / 255.0f, 200.0f / 255.0f, // Fondo inferior: turquesa medio
{{100, 220, 255}, {90, 210, 245}, {110, 230, 255}, {95, 215, 250},
{105, 225, 255}, {98, 218, 248}, {102, 222, 252}, {92, 212, 242}}, // Pelotas turquesa brillante
100.0f / 255.0f,
200.0f / 255.0f,
230.0f / 255.0f, // Fondo superior: turquesa claro
50.0f / 255.0f,
150.0f / 255.0f,
200.0f / 255.0f, // Fondo inferior: turquesa medio
{{100, 220, 255}, {90, 210, 245}, {110, 230, 255}, {95, 215, 250}, {105, 225, 255}, {98, 218, 248}, {102, 222, 252}, {92, 212, 242}}, // Pelotas turquesa brillante
4.0f // 4 segundos para llegar
},
// Keyframe 2: Vuelta a profundidad (para loop)
{
20.0f / 255.0f, 50.0f / 255.0f, 100.0f / 255.0f, // Fondo superior: azul marino
10.0f / 255.0f, 30.0f / 255.0f, 60.0f / 255.0f, // Fondo inferior: azul muy oscuro
{{60, 100, 180}, {50, 90, 170}, {70, 110, 190}, {55, 95, 175},
{65, 105, 185}, {58, 98, 172}, {62, 102, 182}, {52, 92, 168}}, // Pelotas azul oscuro
20.0f / 255.0f,
50.0f / 255.0f,
100.0f / 255.0f, // Fondo superior: azul marino
10.0f / 255.0f,
30.0f / 255.0f,
60.0f / 255.0f, // Fondo inferior: azul muy oscuro
{{60, 100, 180}, {50, 90, 170}, {70, 110, 190}, {55, 95, 175}, {65, 105, 185}, {58, 98, 172}, {62, 102, 182}, {52, 92, 168}}, // Pelotas azul oscuro
4.0f // 4 segundos para volver
}
},
}},
true // Loop = true
};
@@ -1541,33 +1563,43 @@ void Engine::initializeDynamicThemes() {
dynamic_themes_[2] = {
"NEON PULSE",
"PULSO NEON",
255, 60, 255, // Color texto: magenta brillante
255,
60,
255, // Color texto: magenta brillante
{
// Keyframe 0: Apagado (negro)
{
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo superior: negro
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo inferior: negro
{{40, 40, 40}, {50, 50, 50}, {45, 45, 45}, {48, 48, 48},
{42, 42, 42}, {47, 47, 47}, {44, 44, 44}, {46, 46, 46}}, // Pelotas grises muy oscuras
0.0f / 255.0f,
0.0f / 255.0f,
0.0f / 255.0f, // Fondo superior: negro
0.0f / 255.0f,
0.0f / 255.0f,
0.0f / 255.0f, // Fondo inferior: negro
{{40, 40, 40}, {50, 50, 50}, {45, 45, 45}, {48, 48, 48}, {42, 42, 42}, {47, 47, 47}, {44, 44, 44}, {46, 46, 46}}, // Pelotas grises muy oscuras
0.0f // Estado inicial
},
// Keyframe 1: Encendido (neón cian-magenta)
{
20.0f / 255.0f, 20.0f / 255.0f, 40.0f / 255.0f, // Fondo superior: azul oscuro
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo inferior: negro
{{0, 255, 255}, {255, 0, 255}, {0, 255, 200}, {255, 50, 255},
{50, 255, 255}, {255, 0, 200}, {0, 255, 230}, {255, 80, 255}}, // Pelotas neón vibrante
20.0f / 255.0f,
20.0f / 255.0f,
40.0f / 255.0f, // Fondo superior: azul oscuro
0.0f / 255.0f,
0.0f / 255.0f,
0.0f / 255.0f, // Fondo inferior: negro
{{0, 255, 255}, {255, 0, 255}, {0, 255, 200}, {255, 50, 255}, {50, 255, 255}, {255, 0, 200}, {0, 255, 230}, {255, 80, 255}}, // Pelotas neón vibrante
1.5f // 1.5 segundos para encender (rápido)
},
// Keyframe 2: Vuelta a apagado (para loop ping-pong)
{
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo superior: negro
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo inferior: negro
{{40, 40, 40}, {50, 50, 50}, {45, 45, 45}, {48, 48, 48},
{42, 42, 42}, {47, 47, 47}, {44, 44, 44}, {46, 46, 46}}, // Pelotas grises muy oscuras
0.0f / 255.0f,
0.0f / 255.0f,
0.0f / 255.0f, // Fondo superior: negro
0.0f / 255.0f,
0.0f / 255.0f,
0.0f / 255.0f, // Fondo inferior: negro
{{40, 40, 40}, {50, 50, 50}, {45, 45, 45}, {48, 48, 48}, {42, 42, 42}, {47, 47, 47}, {44, 44, 44}, {46, 46, 46}}, // Pelotas grises muy oscuras
1.5f // 1.5 segundos para apagar
}
},
}},
true // Loop = true
};
}
@@ -1925,7 +1957,7 @@ void Engine::performDemoAction(bool is_lite) {
// Activar figura 3D (25%) - PNG_SHAPE excluido (reservado para Logo Mode)
accumulated_weight += DEMO_LITE_WEIGHT_SHAPE;
if (random_value < accumulated_weight) {
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::WAVE_GRID, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
int shape_index = rand() % 8;
activateShape(shapes[shape_index]);
return;
@@ -1968,7 +2000,7 @@ void Engine::performDemoAction(bool is_lite) {
// Activar figura 3D (20%) - PNG_SHAPE excluido (reservado para Logo Mode)
accumulated_weight += DEMO_WEIGHT_SHAPE;
if (random_value < accumulated_weight) {
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::WAVE_GRID, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
int shape_index = rand() % 8;
activateShape(shapes[shape_index]);
return;
@@ -2063,7 +2095,7 @@ void Engine::randomizeOnDemoStart(bool is_lite) {
}
} else {
// Modo figura: elegir figura aleatoria (excluir PNG_SHAPE - es logo especial)
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::WAVE_GRID, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
activateShape(shapes[rand() % 8]);
}
@@ -2099,7 +2131,7 @@ void Engine::randomizeOnDemoStart(bool is_lite) {
}
} else {
// Modo figura: elegir figura aleatoria (excluir PNG_SHAPE - es logo especial)
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::WAVE_GRID, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::LISSAJOUS, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
activateShape(shapes[rand() % 8]);
// 5. Profundidad (solo si estamos en figura)
@@ -2403,8 +2435,8 @@ void Engine::activateShape(ShapeType type) {
case ShapeType::TORUS:
active_shape_ = std::make_unique<TorusShape>();
break;
case ShapeType::WAVE_GRID:
active_shape_ = std::make_unique<WaveGridShape>();
case ShapeType::LISSAJOUS:
active_shape_ = std::make_unique<LissajousShape>();
break;
case ShapeType::CYLINDER:
active_shape_ = std::make_unique<CylinderShape>();

View File

@@ -0,0 +1,64 @@
#include "lissajous_shape.h"
#include "../defines.h"
#include <cmath>
void LissajousShape::generatePoints(int num_points, float screen_width, float screen_height) {
num_points_ = num_points;
amplitude_ = screen_height * LISSAJOUS_SIZE_FACTOR;
// Inicializar frecuencias desde defines.h
freq_x_ = LISSAJOUS_FREQ_X;
freq_y_ = LISSAJOUS_FREQ_Y;
freq_z_ = LISSAJOUS_FREQ_Z;
}
void LissajousShape::update(float delta_time, float screen_width, float screen_height) {
// Recalcular amplitud por si cambió resolución (F4)
amplitude_ = screen_height * LISSAJOUS_SIZE_FACTOR;
// Actualizar rotación global
rotation_x_ += LISSAJOUS_ROTATION_SPEED_X * delta_time;
rotation_y_ += LISSAJOUS_ROTATION_SPEED_Y * delta_time;
// Actualizar fase para animación (morphing de la curva)
phase_x_ += LISSAJOUS_PHASE_SPEED * delta_time;
phase_z_ += LISSAJOUS_PHASE_SPEED * delta_time * 0.7f; // Z rota más lento para variación
}
void LissajousShape::getPoint3D(int index, float& x, float& y, float& z) const {
// Mapear índice [0, num_points-1] a parámetro t [0, 2π]
float t = (static_cast<float>(index) / static_cast<float>(num_points_)) * 2.0f * PI;
// Ecuaciones de Lissajous 3D
// x(t) = A * sin(freq_x * t + phase_x)
// y(t) = A * sin(freq_y * t)
// z(t) = A * sin(freq_z * t + phase_z)
float x_local = amplitude_ * sinf(freq_x_ * t + phase_x_);
float y_local = amplitude_ * sinf(freq_y_ * t);
float z_local = amplitude_ * sinf(freq_z_ * t + phase_z_);
// Aplicar rotación global en eje X
float cos_x = cosf(rotation_x_);
float sin_x = sinf(rotation_x_);
float y_rot = y_local * cos_x - z_local * sin_x;
float z_rot = y_local * sin_x + z_local * cos_x;
// Aplicar rotación global en eje Y
float cos_y = cosf(rotation_y_);
float sin_y = sinf(rotation_y_);
float x_final = x_local * cos_y - z_rot * sin_y;
float z_final = x_local * sin_y + z_rot * cos_y;
// Retornar coordenadas rotadas
x = x_final;
y = y_rot;
z = z_final;
}
float LissajousShape::getScaleFactor(float screen_height) const {
// Factor de escala para física: proporcional a la amplitud de la curva
// Amplitud base = 84px (0.35 * 240px en resolución 320x240)
const float BASE_SIZE = 84.0f;
float current_size = screen_height * LISSAJOUS_SIZE_FACTOR;
return current_size / BASE_SIZE;
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "shape.h"
// Figura: Curva de Lissajous 3D
// Comportamiento: Curva paramétrica 3D con rotación global y animación de fase
// Ecuaciones: x(t) = A*sin(freq_x*t + phase_x), y(t) = A*sin(freq_y*t), z(t) = A*sin(freq_z*t + phase_z)
class LissajousShape : public Shape {
private:
float freq_x_ = 0.0f; // Frecuencia en eje X
float freq_y_ = 0.0f; // Frecuencia en eje Y
float freq_z_ = 0.0f; // Frecuencia en eje Z
float phase_x_ = 0.0f; // Desfase X (animado)
float phase_z_ = 0.0f; // Desfase Z (animado)
float rotation_x_ = 0.0f; // Rotación global en eje X (rad)
float rotation_y_ = 0.0f; // Rotación global en eje Y (rad)
float amplitude_ = 0.0f; // Amplitud de la curva (píxeles)
int num_points_ = 0; // Cantidad total de puntos
public:
void generatePoints(int num_points, float screen_width, float screen_height) override;
void update(float delta_time, float screen_width, float screen_height) override;
void getPoint3D(int index, float& x, float& y, float& z) const override;
const char* getName() const override { return "LISSAJOUS"; }
float getScaleFactor(float screen_height) const override;
};

View File

@@ -267,7 +267,7 @@ std::vector<PNGShape::Point2D> PNGShape::extractCornerVertices(const std::vector
void PNGShape::update(float delta_time, float screen_width, float screen_height) {
if (!is_flipping_) {
// Estado IDLE: texto de frente con pivoteo sutil (como WAVE_GRID)
// Estado IDLE: texto de frente con pivoteo sutil
idle_timer_ += delta_time;
// Pivoteo sutil constante (movimiento orgánico)
@@ -340,7 +340,7 @@ void PNGShape::getPoint3D(int index, float& x, float& y, float& z) const {
z_base = -extrusion_depth_ * 0.5f + layer_index * layer_step;
}
// Añadir pivoteo sutil en estado IDLE (similar a WAVE_GRID)
// Añadir pivoteo sutil en estado IDLE
// Calcular tamaño del logo en pantalla para normalizar correctamente
float logo_width = image_width_ * scale_factor_;
float logo_height = image_height_ * scale_factor_;
@@ -350,9 +350,9 @@ void PNGShape::getPoint3D(int index, float& x, float& y, float& z) const {
float u = x_base / (logo_size * 0.5f);
float v = y_base / (logo_size * 0.5f);
// Calcular pivoteo (amplitudes más grandes, similar a WAVE_GRID)
float tilt_amount_x = sinf(tilt_x_) * 0.15f; // 15% como WAVE_GRID
float tilt_amount_y = sinf(tilt_y_) * 0.1f; // 10% como WAVE_GRID
// Calcular pivoteo (amplitudes más grandes)
float tilt_amount_x = sinf(tilt_x_) * 0.15f; // 15%
float tilt_amount_y = sinf(tilt_y_) * 0.1f; // 10%
// Aplicar pivoteo proporcional al tamaño del logo
float z_tilt = (u * tilt_amount_y + v * tilt_amount_x) * logo_size;

View File

@@ -36,7 +36,7 @@ private:
bool is_flipping_ = false; // Estado: quieto o voltereta
int flip_axis_ = 0; // Eje de voltereta (0=X, 1=Y, 2=ambos)
// Pivoteo sutil en estado IDLE (similar a WAVE_GRID)
// Pivoteo sutil en estado IDLE
float tilt_x_ = 0.0f; // Oscilación sutil en eje X
float tilt_y_ = 0.0f; // Oscilación sutil en eje Y

View File

@@ -1,99 +0,0 @@
#include "wave_grid_shape.h"
#include "../defines.h"
#include <cmath>
void WaveGridShape::generatePoints(int num_points, float screen_width, float screen_height) {
num_points_ = num_points;
grid_size_ = screen_height * WAVE_GRID_SIZE_FACTOR;
amplitude_ = screen_height * WAVE_GRID_AMPLITUDE;
// Calcular grid cuadrado aproximado basado en número de puntos
// Queremos grid_cols * grid_rows ≈ num_points
grid_cols_ = static_cast<int>(sqrtf(static_cast<float>(num_points)));
grid_rows_ = grid_cols_;
// Ajustar para que grid_cols * grid_rows no exceda num_points
while (grid_cols_ * grid_rows_ > num_points && grid_rows_ > 1) {
grid_rows_--;
}
// Si tenemos menos puntos que celdas, ajustar columnas también
if (grid_cols_ * grid_rows_ > num_points) {
grid_cols_ = num_points / grid_rows_;
}
// Casos especiales para pocos puntos
if (num_points < 4) {
grid_cols_ = num_points;
grid_rows_ = 1;
}
}
void WaveGridShape::update(float delta_time, float screen_width, float screen_height) {
// Recalcular dimensiones por si cambió resolución (F4)
grid_size_ = screen_height * WAVE_GRID_SIZE_FACTOR;
amplitude_ = screen_height * WAVE_GRID_AMPLITUDE;
// Pivoteo sutil en ejes X e Y (esquinas adelante/atrás, izq/der)
// Usamos velocidades lentas para movimiento sutil y orgánico
tilt_x_ += 0.3f * delta_time; // Pivoteo vertical (esquinas arriba/abajo)
tilt_y_ += 0.5f * delta_time; // Pivoteo horizontal (esquinas izq/der)
// Actualizar fase de las ondas (animación)
phase_ += WAVE_GRID_PHASE_SPEED * delta_time;
}
void WaveGridShape::getPoint3D(int index, float& x, float& y, float& z) const {
// Convertir índice lineal a coordenadas 2D del grid
int col = index % grid_cols_;
int row = index / grid_cols_;
// Si el índice está fuera del grid válido, colocar en origen
if (row >= grid_rows_) {
x = 0.0f;
y = 0.0f;
z = 0.0f;
return;
}
// Normalizar coordenadas del grid a rango [-1, 1]
float u = (static_cast<float>(col) / static_cast<float>(grid_cols_ - 1)) * 2.0f - 1.0f;
float v = (static_cast<float>(row) / static_cast<float>(grid_rows_ - 1)) * 2.0f - 1.0f;
// Casos especiales para grids de 1 columna/fila
if (grid_cols_ == 1) u = 0.0f;
if (grid_rows_ == 1) v = 0.0f;
// Posición base en el grid (escalada por tamaño)
float x_base = u * grid_size_;
float y_base = v * grid_size_;
// Calcular Z usando función de onda 2D
// z = amplitude * sin(frequency * x + phase) * cos(frequency * y + phase)
float kx = WAVE_GRID_FREQUENCY * PI; // Frecuencia en X
float ky = WAVE_GRID_FREQUENCY * PI; // Frecuencia en Y
float z_wave = amplitude_ * sinf(kx * u + phase_) * cosf(ky * v + phase_);
// Añadir pivoteo sutil: esquinas se mueven adelante/atrás según posición
// tilt_x oscila esquinas arriba/abajo, tilt_y oscila esquinas izq/der
float tilt_amount_x = sinf(tilt_x_) * 0.15f; // Máximo 15% del grid_size
float tilt_amount_y = sinf(tilt_y_) * 0.1f; // Máximo 10% del grid_size
float z_tilt = (u * tilt_amount_y + v * tilt_amount_x) * grid_size_;
// Z final = ondas + pivoteo
float z_final = z_wave + z_tilt;
// Retornar coordenadas (grid paralelo a pantalla, sin rotación global)
x = x_base;
y = y_base;
z = z_final;
}
float WaveGridShape::getScaleFactor(float screen_height) const {
// Factor de escala para física: proporcional al tamaño del grid
// Grid base = 84px (0.35 * 240px en resolución 320x240)
const float BASE_SIZE = 84.0f;
float current_size = screen_height * WAVE_GRID_SIZE_FACTOR;
return current_size / BASE_SIZE;
}

View File

@@ -1,25 +0,0 @@
#pragma once
#include "shape.h"
// Figura: Malla ondeante 3D (Wave Grid)
// Comportamiento: Grid 2D paralelo a pantalla con ondas + pivoteo sutil en esquinas
// Ecuaciones: z = A * sin(kx*x + phase) * cos(ky*y + phase) + pivoteo
class WaveGridShape : public Shape {
private:
float tilt_x_ = 0.0f; // Ángulo de pivoteo en eje X (esquinas adelante/atrás)
float tilt_y_ = 0.0f; // Ángulo de pivoteo en eje Y (esquinas izq/der)
float phase_ = 0.0f; // Fase de animación de ondas (rad)
float grid_size_ = 0.0f; // Tamaño del grid (píxeles)
float amplitude_ = 0.0f; // Amplitud de las ondas (píxeles)
int grid_cols_ = 0; // Número de columnas del grid
int grid_rows_ = 0; // Número de filas del grid
int num_points_ = 0; // Cantidad total de puntos
public:
void generatePoints(int num_points, float screen_width, float screen_height) override;
void update(float delta_time, float screen_width, float screen_height) override;
void getPoint3D(int index, float& x, float& y, float& z) const override;
const char* getName() const override { return "WAVE GRID"; }
float getScaleFactor(float screen_height) const override;
};