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,7 +1,8 @@
#pragma once #pragma once
#include <SDL3/SDL_stdinc.h> // for Uint64 #include <SDL3/SDL_stdinc.h> // for Uint64
#include <vector> // for std::vector in DynamicThemeKeyframe/DynamicTheme
#include <vector> // for std::vector in DynamicThemeKeyframe/DynamicTheme
// Configuración de ventana y pantalla // Configuración de ventana y pantalla
constexpr char WINDOW_CAPTION[] = "ViBe3 Physics (JailDesigner 2025)"; constexpr char WINDOW_CAPTION[] = "ViBe3 Physics (JailDesigner 2025)";
@@ -100,7 +101,7 @@ enum class ShapeType {
CUBE, // Cubo rotante CUBE, // Cubo rotante
HELIX, // Espiral 3D HELIX, // Espiral 3D
TORUS, // Toroide/donut TORUS, // Toroide/donut
WAVE_GRID, // Malla ondeante LISSAJOUS, // Malla ondeante
CYLINDER, // Cilindro rotante CYLINDER, // Cilindro rotante
ICOSAHEDRON, // Icosaedro D20 ICOSAHEDRON, // Icosaedro D20
ATOM, // Átomo con órbitas 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_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) constexpr float HELIX_PHASE_SPEED = 0.5f; // Velocidad de animación vertical (rad/s)
// Configuración de Wave Grid (malla ondeante 3D) // Configuración de Lissajous Curve 3D (curva paramétrica)
constexpr float WAVE_GRID_SIZE_FACTOR = 0.35f; // Tamaño del grid (proporción de altura) constexpr float LISSAJOUS_SIZE_FACTOR = 0.35f; // Amplitud de la curva (proporción de altura)
constexpr float WAVE_GRID_AMPLITUDE = 0.15f; // Amplitud de las ondas (proporción de altura) constexpr float LISSAJOUS_FREQ_X = 3.0f; // Frecuencia en eje X (ratio 3:2:1)
constexpr float WAVE_GRID_FREQUENCY = 3.0f; // Frecuencia de ondas (ciclos por grid) constexpr float LISSAJOUS_FREQ_Y = 2.0f; // Frecuencia en eje Y
constexpr float WAVE_GRID_PHASE_SPEED = 2.0f; // Velocidad de animación de ondas (rad/s) constexpr float LISSAJOUS_FREQ_Z = 1.0f; // Frecuencia en eje Z
constexpr float WAVE_GRID_ROTATION_SPEED_Y = 0.4f; // Velocidad rotación eje Y (rad/s) 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) // Configuración de Torus (toroide/donut 3D)
constexpr float TORUS_MAJOR_RADIUS_FACTOR = 0.25f; // Radio mayor R (centro torus a centro tubo) constexpr float TORUS_MAJOR_RADIUS_FACTOR = 0.25f; // Radio mayor R (centro torus a centro tubo)
@@ -187,12 +190,12 @@ constexpr float PNG_EXTRUSION_DEPTH_FACTOR = 0.12f; // Profundidad de extrusió
constexpr int PNG_NUM_EXTRUSION_LAYERS = 15; // Capas de extrusión (más capas = más pegajosidad) constexpr int PNG_NUM_EXTRUSION_LAYERS = 15; // Capas de extrusión (más capas = más pegajosidad)
constexpr bool PNG_USE_EDGES_ONLY = false; // true = solo bordes, false = relleno completo constexpr bool PNG_USE_EDGES_ONLY = false; // true = solo bordes, false = relleno completo
// Rotación "legible" (texto de frente con volteretas ocasionales) // Rotación "legible" (texto de frente con volteretas ocasionales)
constexpr float PNG_IDLE_TIME_MIN = 0.5f; // Tiempo mínimo de frente (segundos) - modo MANUAL constexpr float PNG_IDLE_TIME_MIN = 0.5f; // Tiempo mínimo de frente (segundos) - modo MANUAL
constexpr float PNG_IDLE_TIME_MAX = 2.0f; // Tiempo máximo de frente (segundos) - modo MANUAL constexpr float PNG_IDLE_TIME_MAX = 2.0f; // Tiempo máximo de frente (segundos) - modo MANUAL
constexpr float PNG_IDLE_TIME_MIN_LOGO = 3.0f; // Tiempo mínimo de frente en LOGO MODE constexpr float PNG_IDLE_TIME_MIN_LOGO = 3.0f; // Tiempo mínimo de frente en LOGO MODE
constexpr float PNG_IDLE_TIME_MAX_LOGO = 5.0f; // Tiempo máximo de frente en LOGO MODE constexpr float PNG_IDLE_TIME_MAX_LOGO = 5.0f; // Tiempo máximo de frente en LOGO MODE
constexpr float PNG_FLIP_SPEED = 3.0f; // Velocidad voltereta (rad/s) constexpr float PNG_FLIP_SPEED = 3.0f; // Velocidad voltereta (rad/s)
constexpr float PNG_FLIP_DURATION = 1.5f; // Duración voltereta (segundos) constexpr float PNG_FLIP_DURATION = 1.5f; // Duración voltereta (segundos)
// Control manual de escala de figuras 3D (Numpad +/-) // Control manual de escala de figuras 3D (Numpad +/-)
constexpr float SHAPE_SCALE_MIN = 0.3f; // Escala mínima (30%) constexpr float SHAPE_SCALE_MIN = 0.3f; // Escala mínima (30%)
@@ -231,21 +234,21 @@ constexpr int DEMO_LITE_WEIGHT_IMPULSE = 10; // Aplicar impulso (10%)
// TOTAL: 100 // TOTAL: 100
// Configuración de Modo LOGO (easter egg - "marca de agua") // Configuración de Modo LOGO (easter egg - "marca de agua")
constexpr int LOGO_MODE_MIN_BALLS = 500; // Mínimo de pelotas para activar modo logo constexpr int LOGO_MODE_MIN_BALLS = 500; // Mínimo de pelotas para activar modo logo
constexpr float LOGO_MODE_SHAPE_SCALE = 1.2f; // Escala de figura en modo logo (120%) constexpr float LOGO_MODE_SHAPE_SCALE = 1.2f; // Escala de figura en modo logo (120%)
constexpr float LOGO_ACTION_INTERVAL_MIN = 3.0f; // Tiempo mínimo entre alternancia SHAPE/PHYSICS (escalado con resolución) constexpr float LOGO_ACTION_INTERVAL_MIN = 3.0f; // Tiempo mínimo entre alternancia SHAPE/PHYSICS (escalado con resolución)
constexpr float LOGO_ACTION_INTERVAL_MAX = 5.0f; // Tiempo máximo entre alternancia SHAPE/PHYSICS (escalado con resolución) constexpr float LOGO_ACTION_INTERVAL_MAX = 5.0f; // Tiempo máximo entre alternancia SHAPE/PHYSICS (escalado con resolución)
constexpr int LOGO_WEIGHT_TOGGLE_PHYSICS = 100; // Único peso: alternar SHAPE ↔ PHYSICS (100%) constexpr int LOGO_WEIGHT_TOGGLE_PHYSICS = 100; // Único peso: alternar SHAPE ↔ PHYSICS (100%)
// Sistema de convergencia para LOGO MODE (evita interrupciones prematuras en resoluciones altas) // Sistema de convergencia para LOGO MODE (evita interrupciones prematuras en resoluciones altas)
constexpr float LOGO_CONVERGENCE_MIN = 0.75f; // 75% mínimo (permite algo de movimiento al disparar) constexpr float LOGO_CONVERGENCE_MIN = 0.75f; // 75% mínimo (permite algo de movimiento al disparar)
constexpr float LOGO_CONVERGENCE_MAX = 1.00f; // 100% máximo (completamente formado) constexpr float LOGO_CONVERGENCE_MAX = 1.00f; // 100% máximo (completamente formado)
constexpr float LOGO_CONVERGENCE_DISTANCE = 20.0f; // Distancia (px) para considerar pelota "convergida" (más permisivo que SHAPE_NEAR) constexpr float LOGO_CONVERGENCE_DISTANCE = 20.0f; // Distancia (px) para considerar pelota "convergida" (más permisivo que SHAPE_NEAR)
// Probabilidad de salto a Logo Mode desde DEMO/DEMO_LITE (%) // Probabilidad de salto a Logo Mode desde DEMO/DEMO_LITE (%)
// Relación DEMO:LOGO = 6:1 (pasa 6x más tiempo en DEMO que en LOGO) // Relación DEMO:LOGO = 6:1 (pasa 6x más tiempo en DEMO que en LOGO)
constexpr int LOGO_JUMP_PROBABILITY_FROM_DEMO = 5; // 5% probabilidad en DEMO normal (más raro) constexpr int LOGO_JUMP_PROBABILITY_FROM_DEMO = 5; // 5% probabilidad en DEMO normal (más raro)
constexpr int LOGO_JUMP_PROBABILITY_FROM_DEMO_LITE = 3; // 3% probabilidad en DEMO LITE (aún más raro) constexpr int LOGO_JUMP_PROBABILITY_FROM_DEMO_LITE = 3; // 3% probabilidad en DEMO LITE (aún más raro)
constexpr float PI = 3.14159265358979323846f; // Constante PI constexpr float PI = 3.14159265358979323846f; // Constante PI
@@ -254,11 +257,11 @@ constexpr float PI = 3.14159265358979323846f; // Constante PI
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#elif defined(__APPLE__) #elif defined(__APPLE__)
#include <limits.h>
#include <mach-o/dyld.h> #include <mach-o/dyld.h>
#include <limits.h>
#else #else
#include <unistd.h>
#include <limits.h> #include <limits.h>
#include <unistd.h>
#endif #endif
inline std::string getExecutableDirectory() { inline std::string getExecutableDirectory() {

View File

@@ -30,10 +30,10 @@
#include "shapes/cylinder_shape.h" // for CylinderShape #include "shapes/cylinder_shape.h" // for CylinderShape
#include "shapes/helix_shape.h" // for HelixShape #include "shapes/helix_shape.h" // for HelixShape
#include "shapes/icosahedron_shape.h" // for IcosahedronShape #include "shapes/icosahedron_shape.h" // for IcosahedronShape
#include "shapes/lissajous_shape.h" // for LissajousShape
#include "shapes/png_shape.h" // for PNGShape #include "shapes/png_shape.h" // for PNGShape
#include "shapes/sphere_shape.h" // for SphereShape #include "shapes/sphere_shape.h" // for SphereShape
#include "shapes/torus_shape.h" // for TorusShape #include "shapes/torus_shape.h" // for TorusShape
#include "shapes/wave_grid_shape.h" // for WaveGridShape
// getExecutableDirectory() ya está definido en defines.h como inline // getExecutableDirectory() ya está definido en defines.h como inline
@@ -48,8 +48,8 @@ bool Engine::initialize(int width, int height, int zoom, bool fullscreen) {
} }
int num_displays = 0; int num_displays = 0;
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays); SDL_DisplayID* displays = SDL_GetDisplays(&num_displays);
const auto *dm = (displays && num_displays > 0) ? SDL_GetCurrentDisplayMode(displays[0]) : nullptr; const auto* dm = (displays && num_displays > 0) ? SDL_GetCurrentDisplayMode(displays[0]) : nullptr;
int screen_w = dm ? dm->w : 1920; // Fallback si falla int screen_w = dm ? dm->w : 1920; // Fallback si falla
int screen_h = dm ? dm->h - WINDOW_DECORATION_HEIGHT : 1080; int screen_h = dm ? dm->h - WINDOW_DECORATION_HEIGHT : 1080;
@@ -132,9 +132,9 @@ bool Engine::initialize(int width, int height, int zoom, bool fullscreen) {
std::string balls_dir = resources_dir + "/data/balls"; std::string balls_dir = resources_dir + "/data/balls";
struct TextureInfo { struct TextureInfo {
std::string name; std::string name;
std::shared_ptr<Texture> texture; std::shared_ptr<Texture> texture;
int width; int width;
}; };
std::vector<TextureInfo> texture_files; std::vector<TextureInfo> texture_files;
@@ -162,7 +162,7 @@ bool Engine::initialize(int width, int height, int zoom, bool fullscreen) {
// Filtrar solo los recursos en balls/ con extensión .png // Filtrar solo los recursos en balls/ con extensión .png
for (const auto& resource : pack_resources) { for (const auto& resource : pack_resources) {
if (resource.substr(0, 6) == "balls/" && resource.substr(resource.size() - 4) == ".png") { if (resource.substr(0, 6) == "balls/" && resource.substr(resource.size() - 4) == ".png") {
std::string tex_name = resource.substr(6); // Quitar "balls/" std::string tex_name = resource.substr(6); // Quitar "balls/"
std::string name = tex_name.substr(0, tex_name.find('.')); // Quitar extensión std::string name = tex_name.substr(0, tex_name.find('.')); // Quitar extensión
auto texture = std::make_shared<Texture>(renderer_, resource); auto texture = std::make_shared<Texture>(renderer_, resource);
@@ -175,10 +175,9 @@ 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) // Ordenar por tamaño (grande → pequeño): big(16) → normal(10) → small(6) → tiny(4)
std::sort(texture_files.begin(), texture_files.end(), std::sort(texture_files.begin(), texture_files.end(), [](const TextureInfo& a, const TextureInfo& b) {
[](const TextureInfo& a, const TextureInfo& b) { return a.width > b.width; // Descendente por tamaño
return a.width > b.width; // Descendente por tamaño });
});
// Guardar texturas ya cargadas en orden (0=big, 1=normal, 2=small, 3=tiny) // Guardar texturas ya cargadas en orden (0=big, 1=normal, 2=small, 3=tiny)
for (const auto& info : texture_files) { for (const auto& info : texture_files) {
@@ -405,7 +404,7 @@ void Engine::handleEvents() {
break; break;
case SDLK_W: case SDLK_W:
activateShape(ShapeType::WAVE_GRID); activateShape(ShapeType::LISSAJOUS);
break; break;
case SDLK_E: case SDLK_E:
@@ -1461,41 +1460,54 @@ void Engine::initializeDynamicThemes() {
dynamic_themes_[0] = { dynamic_themes_[0] = {
"SUNRISE", "SUNRISE",
"AMANECER", "AMANECER",
255, 200, 100, // Color texto: amarillo cálido 255,
200,
100, // Color texto: amarillo cálido
{ {
// Keyframe 0: Noche oscura (estado inicial) // Keyframe 0: Noche oscura (estado inicial)
{ {
20.0f / 255.0f, 25.0f / 255.0f, 60.0f / 255.0f, // Fondo superior: azul medianoche 20.0f / 255.0f,
10.0f / 255.0f, 10.0f / 255.0f, 30.0f / 255.0f, // Fondo inferior: azul muy oscuro 25.0f / 255.0f,
{{100, 100, 150}, {120, 120, 170}, {90, 90, 140}, {110, 110, 160}, 60.0f / 255.0f, // Fondo superior: azul medianoche
{95, 95, 145}, {105, 105, 155}, {100, 100, 150}, {115, 115, 165}}, // Pelotas azules tenues 10.0f / 255.0f,
0.0f // Sin transición (estado inicial) 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 // Keyframe 1: Alba naranja-rosa
{ {
180.0f / 255.0f, 100.0f / 255.0f, 120.0f / 255.0f, // Fondo superior: naranja-rosa 180.0f / 255.0f,
255.0f / 255.0f, 140.0f / 255.0f, 100.0f / 255.0f, // Fondo inferior: naranja cálido 100.0f / 255.0f,
{{255, 180, 100}, {255, 160, 80}, {255, 200, 120}, {255, 150, 90}, 120.0f / 255.0f, // Fondo superior: naranja-rosa
{255, 190, 110}, {255, 170, 95}, {255, 185, 105}, {255, 165, 88}}, // Pelotas naranjas 255.0f / 255.0f,
4.0f // 4 segundos para llegar aquí 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 // 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, 255.0f / 255.0f, 220.0f / 255.0f, // Fondo inferior: amarillo muy claro 240.0f / 255.0f,
{{255, 255, 200}, {255, 255, 180}, {255, 255, 220}, {255, 255, 190}, 180.0f / 255.0f, // Fondo superior: amarillo claro
{255, 255, 210}, {255, 255, 185}, {255, 255, 205}, {255, 255, 195}}, // Pelotas amarillas brillantes 255.0f / 255.0f,
3.0f // 3 segundos para llegar aquí 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) // Keyframe 3: Vuelta a noche (para loop)
{ {
20.0f / 255.0f, 25.0f / 255.0f, 60.0f / 255.0f, // Fondo superior: azul medianoche 20.0f / 255.0f,
10.0f / 255.0f, 10.0f / 255.0f, 30.0f / 255.0f, // Fondo inferior: azul muy oscuro 25.0f / 255.0f,
{{100, 100, 150}, {120, 120, 170}, {90, 90, 140}, {110, 110, 160}, 60.0f / 255.0f, // Fondo superior: azul medianoche
{95, 95, 145}, {105, 105, 155}, {100, 100, 150}, {115, 115, 165}}, // Pelotas azules tenues 10.0f / 255.0f,
5.0f // 5 segundos para volver a noche 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 true // Loop = true
}; };
@@ -1505,33 +1517,43 @@ void Engine::initializeDynamicThemes() {
dynamic_themes_[1] = { dynamic_themes_[1] = {
"OCEAN WAVES", "OCEAN WAVES",
"OLAS OCEANICAS", "OLAS OCEANICAS",
100, 220, 255, // Color texto: cian claro 100,
220,
255, // Color texto: cian claro
{ {
// Keyframe 0: Profundidad oceánica (azul oscuro) // Keyframe 0: Profundidad oceánica (azul oscuro)
{ {
20.0f / 255.0f, 50.0f / 255.0f, 100.0f / 255.0f, // Fondo superior: azul marino 20.0f / 255.0f,
10.0f / 255.0f, 30.0f / 255.0f, 60.0f / 255.0f, // Fondo inferior: azul muy oscuro 50.0f / 255.0f,
{{60, 100, 180}, {50, 90, 170}, {70, 110, 190}, {55, 95, 175}, 100.0f / 255.0f, // Fondo superior: azul marino
{65, 105, 185}, {58, 98, 172}, {62, 102, 182}, {52, 92, 168}}, // Pelotas azul oscuro 10.0f / 255.0f,
0.0f // Estado inicial 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) // Keyframe 1: Aguas poco profundas (turquesa brillante)
{ {
100.0f / 255.0f, 200.0f / 255.0f, 230.0f / 255.0f, // Fondo superior: turquesa claro 100.0f / 255.0f,
50.0f / 255.0f, 150.0f / 255.0f, 200.0f / 255.0f, // Fondo inferior: turquesa medio 200.0f / 255.0f,
{{100, 220, 255}, {90, 210, 245}, {110, 230, 255}, {95, 215, 250}, 230.0f / 255.0f, // Fondo superior: turquesa claro
{105, 225, 255}, {98, 218, 248}, {102, 222, 252}, {92, 212, 242}}, // Pelotas turquesa brillante 50.0f / 255.0f,
4.0f // 4 segundos para llegar 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) // Keyframe 2: Vuelta a profundidad (para loop)
{ {
20.0f / 255.0f, 50.0f / 255.0f, 100.0f / 255.0f, // Fondo superior: azul marino 20.0f / 255.0f,
10.0f / 255.0f, 30.0f / 255.0f, 60.0f / 255.0f, // Fondo inferior: azul muy oscuro 50.0f / 255.0f,
{{60, 100, 180}, {50, 90, 170}, {70, 110, 190}, {55, 95, 175}, 100.0f / 255.0f, // Fondo superior: azul marino
{65, 105, 185}, {58, 98, 172}, {62, 102, 182}, {52, 92, 168}}, // Pelotas azul oscuro 10.0f / 255.0f,
4.0f // 4 segundos para volver 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 true // Loop = true
}; };
@@ -1541,33 +1563,43 @@ void Engine::initializeDynamicThemes() {
dynamic_themes_[2] = { dynamic_themes_[2] = {
"NEON PULSE", "NEON PULSE",
"PULSO NEON", "PULSO NEON",
255, 60, 255, // Color texto: magenta brillante 255,
60,
255, // Color texto: magenta brillante
{ {
// Keyframe 0: Apagado (negro) // 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, 0.0f / 255.0f, // Fondo inferior: negro 0.0f / 255.0f,
{{40, 40, 40}, {50, 50, 50}, {45, 45, 45}, {48, 48, 48}, 0.0f / 255.0f, // Fondo superior: negro
{42, 42, 42}, {47, 47, 47}, {44, 44, 44}, {46, 46, 46}}, // Pelotas grises muy oscuras 0.0f / 255.0f,
0.0f // Estado inicial 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) // Keyframe 1: Encendido (neón cian-magenta)
{ {
20.0f / 255.0f, 20.0f / 255.0f, 40.0f / 255.0f, // Fondo superior: azul oscuro 20.0f / 255.0f,
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo inferior: negro 20.0f / 255.0f,
{{0, 255, 255}, {255, 0, 255}, {0, 255, 200}, {255, 50, 255}, 40.0f / 255.0f, // Fondo superior: azul oscuro
{50, 255, 255}, {255, 0, 200}, {0, 255, 230}, {255, 80, 255}}, // Pelotas neón vibrante 0.0f / 255.0f,
1.5f // 1.5 segundos para encender (rápido) 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) // 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, 0.0f / 255.0f, // Fondo inferior: negro 0.0f / 255.0f,
{{40, 40, 40}, {50, 50, 50}, {45, 45, 45}, {48, 48, 48}, 0.0f / 255.0f, // Fondo superior: negro
{42, 42, 42}, {47, 47, 47}, {44, 44, 44}, {46, 46, 46}}, // Pelotas grises muy oscuras 0.0f / 255.0f,
1.5f // 1.5 segundos para apagar 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 true // Loop = true
}; };
} }
@@ -1641,7 +1673,7 @@ void Engine::updateDynamicTheme() {
target_keyframe_index_ = 0; // Volver al inicio target_keyframe_index_ = 0; // Volver al inicio
} else { } else {
target_keyframe_index_ = theme.keyframes.size() - 1; // Quedarse en el último target_keyframe_index_ = theme.keyframes.size() - 1; // Quedarse en el último
dynamic_theme_active_ = false; // Detener animación dynamic_theme_active_ = false; // Detener animación
} }
} }
@@ -1925,7 +1957,7 @@ void Engine::performDemoAction(bool is_lite) {
// Activar figura 3D (25%) - PNG_SHAPE excluido (reservado para Logo Mode) // Activar figura 3D (25%) - PNG_SHAPE excluido (reservado para Logo Mode)
accumulated_weight += DEMO_LITE_WEIGHT_SHAPE; accumulated_weight += DEMO_LITE_WEIGHT_SHAPE;
if (random_value < accumulated_weight) { 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; int shape_index = rand() % 8;
activateShape(shapes[shape_index]); activateShape(shapes[shape_index]);
return; return;
@@ -1968,7 +2000,7 @@ void Engine::performDemoAction(bool is_lite) {
// Activar figura 3D (20%) - PNG_SHAPE excluido (reservado para Logo Mode) // Activar figura 3D (20%) - PNG_SHAPE excluido (reservado para Logo Mode)
accumulated_weight += DEMO_WEIGHT_SHAPE; accumulated_weight += DEMO_WEIGHT_SHAPE;
if (random_value < accumulated_weight) { 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; int shape_index = rand() % 8;
activateShape(shapes[shape_index]); activateShape(shapes[shape_index]);
return; return;
@@ -2063,7 +2095,7 @@ void Engine::randomizeOnDemoStart(bool is_lite) {
} }
} else { } else {
// Modo figura: elegir figura aleatoria (excluir PNG_SHAPE - es logo especial) // 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]); activateShape(shapes[rand() % 8]);
} }
@@ -2099,7 +2131,7 @@ void Engine::randomizeOnDemoStart(bool is_lite) {
} }
} else { } else {
// Modo figura: elegir figura aleatoria (excluir PNG_SHAPE - es logo especial) // 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]); activateShape(shapes[rand() % 8]);
// 5. Profundidad (solo si estamos en figura) // 5. Profundidad (solo si estamos en figura)
@@ -2403,8 +2435,8 @@ void Engine::activateShape(ShapeType type) {
case ShapeType::TORUS: case ShapeType::TORUS:
active_shape_ = std::make_unique<TorusShape>(); active_shape_ = std::make_unique<TorusShape>();
break; break;
case ShapeType::WAVE_GRID: case ShapeType::LISSAJOUS:
active_shape_ = std::make_unique<WaveGridShape>(); active_shape_ = std::make_unique<LissajousShape>();
break; break;
case ShapeType::CYLINDER: case ShapeType::CYLINDER:
active_shape_ = std::make_unique<CylinderShape>(); 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) { void PNGShape::update(float delta_time, float screen_width, float screen_height) {
if (!is_flipping_) { 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; idle_timer_ += delta_time;
// Pivoteo sutil constante (movimiento orgánico) // 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; 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 // Calcular tamaño del logo en pantalla para normalizar correctamente
float logo_width = image_width_ * scale_factor_; float logo_width = image_width_ * scale_factor_;
float logo_height = image_height_ * 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 u = x_base / (logo_size * 0.5f);
float v = y_base / (logo_size * 0.5f); float v = y_base / (logo_size * 0.5f);
// Calcular pivoteo (amplitudes más grandes, similar a WAVE_GRID) // Calcular pivoteo (amplitudes más grandes)
float tilt_amount_x = sinf(tilt_x_) * 0.15f; // 15% como WAVE_GRID float tilt_amount_x = sinf(tilt_x_) * 0.15f; // 15%
float tilt_amount_y = sinf(tilt_y_) * 0.1f; // 10% como WAVE_GRID float tilt_amount_y = sinf(tilt_y_) * 0.1f; // 10%
// Aplicar pivoteo proporcional al tamaño del logo // Aplicar pivoteo proporcional al tamaño del logo
float z_tilt = (u * tilt_amount_y + v * tilt_amount_x) * logo_size; 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 bool is_flipping_ = false; // Estado: quieto o voltereta
int flip_axis_ = 0; // Eje de voltereta (0=X, 1=Y, 2=ambos) 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_x_ = 0.0f; // Oscilación sutil en eje X
float tilt_y_ = 0.0f; // Oscilación sutil en eje Y 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;
};