Compare commits
9 Commits
c4ca49b006
...
f0baa51415
| Author | SHA1 | Date | |
|---|---|---|---|
| f0baa51415 | |||
| db3d4d6630 | |||
| d030d4270e | |||
| fbd09b3201 | |||
| a04c1cba13 | |||
| 757bb9c525 | |||
| 723bb6d198 | |||
| 1e5c9f8f9d | |||
| e24f06ed90 |
91
ROADMAP.md
91
ROADMAP.md
@@ -30,33 +30,24 @@
|
||||
|
||||
## Mejoras de Presentación 🎨
|
||||
|
||||
### 1. ⏳ Mejorar Animaciones de Figuras 3D
|
||||
### 1. ✅ Mejorar Animaciones de Figuras 3D
|
||||
**Descripción:** Añadir movimientos más dinámicos e interesantes a algunas figuras
|
||||
**Prioridad:** Media
|
||||
**Estimación:** 1.5 horas
|
||||
**Estado:** ✅ COMPLETADO
|
||||
**Detalles:**
|
||||
|
||||
#### CYLINDER (Y):
|
||||
- **Rotación actual:** Solo eje Y (spin horizontal continuo)
|
||||
- **Mejora propuesta:** Rotaciones multi-eje con cambios periódicos
|
||||
- Rotación principal en eje Y (como ahora)
|
||||
- Cada 3-5 segundos: tumbling en eje X o Z durante 1-2 segundos
|
||||
- Efecto visual: "dar una vuelta" sobre otro eje ocasionalmente
|
||||
- Transiciones suaves con aceleración/desaceleración
|
||||
- ✅ **Rotación principal en eje Y** (spin horizontal continuo)
|
||||
- ✅ **Tumbling ocasional en eje X** cada 3-5 segundos
|
||||
- ✅ Transiciones suaves con ease-in-out (1.5s duración)
|
||||
- ✅ Efecto visual: cilindro "se da una vuelta" ocasionalmente
|
||||
|
||||
#### WAVE_GRID (W):
|
||||
- **Rotación actual:** XY girando como esfera (confuso)
|
||||
- **Mejora propuesta:** Vista frontal con pivoteo sutil
|
||||
- **Vista principal:** Paralela a pantalla (mirando de frente)
|
||||
- **Movimiento:** Pivoteo en centro con esquinas hacia adelante/atrás
|
||||
- Ejemplo: esquina superior-derecha se aleja (Z-), inferior-izquierda se acerca (Z+)
|
||||
- Movimiento ondulatorio sincronizado: olas + pivoteo crea efecto "océano"
|
||||
- **Opcional:** Rotación completa ocasional (cada 10-15s) como transición
|
||||
|
||||
**Implementación técnica:**
|
||||
- Añadir `rotation_mode_` y `mode_timer_` a cada shape
|
||||
- Estados: NORMAL, TRANSITION, ALTERNATIVE
|
||||
- Interpolación suave entre modos de rotación
|
||||
- ✅ **Vista frontal paralela a pantalla** (sin rotación confusa)
|
||||
- ✅ **Pivoteo sutil en ejes X e Y**
|
||||
- ✅ Esquinas se mueven adelante/atrás según posición
|
||||
- ✅ Movimiento ondulatorio + pivoteo = efecto "océano"
|
||||
- ✅ Velocidades lentas (0.3-0.5 rad/s) para organicidad
|
||||
|
||||
### 2. ✅ Modo DEMO (Auto-play)
|
||||
**Descripción:** Modo demostración automática con acciones aleatorias
|
||||
@@ -83,7 +74,57 @@
|
||||
- ✅ Help text con `--help`
|
||||
- Ejemplo: `./vibe3_physics -w 1920 -h 1080 -f`
|
||||
|
||||
### 4. 🐛 Corregir Escalado de Pelotas en Reposo
|
||||
### 4. 🎯 Implementar Modo Logo (Easter Egg)
|
||||
**Descripción:** Modo especial que muestra el logo JAILGAMES como "marca de agua"
|
||||
**Prioridad:** Alta (característica distintiva)
|
||||
**Estimación:** 2 horas
|
||||
**Detalles:**
|
||||
|
||||
#### Configuración Modo Logo:
|
||||
- **Figura:** Solo PNG_SHAPE (logo JAILGAMES)
|
||||
- **Textura:** Siempre "tiny" (pelota más pequeña)
|
||||
- **Tema:** Siempre MONOCHROME (blanco puro)
|
||||
- **Escala:** 120% (figuras más grandes que normal)
|
||||
- **Pelotas mínimas:** 500
|
||||
- **Tecla manual:** K (activa/desactiva modo logo)
|
||||
|
||||
#### Comportamiento en Modo Logo:
|
||||
- Alterna entre modo SHAPE y modo PHYSICS (como DEMO)
|
||||
- Mantiene configuración fija (no cambia tema/textura/escala)
|
||||
- Es como un "DEMO específico del logo"
|
||||
|
||||
#### Integración con DEMO LITE:
|
||||
- **Requisitos para salto automático:**
|
||||
- Mínimo 500 pelotas
|
||||
- Tema MONOCHROME activo
|
||||
- Si se cumplen → cambia automáticamente textura a "tiny" y escala a 120%
|
||||
- **Duración:** Menos tiempo que DEMO normal (es un "recordatorio")
|
||||
- **Después:** Vuelve a DEMO LITE normal
|
||||
|
||||
#### Integración con DEMO:
|
||||
- **Requisitos:** Mínimo 500 pelotas
|
||||
- **Acción:** Cambia automáticamente a: MONOCHROME + tiny + escala 120%
|
||||
- **Duración:** Menos tiempo que acciones normales
|
||||
- **Después:** Vuelve a DEMO normal
|
||||
|
||||
#### Proporción temporal sugerida:
|
||||
- DEMO/DEMO_LITE normal: 80-90% del tiempo
|
||||
- Modo Logo: 10-20% del tiempo (aparición ocasional como "easter egg")
|
||||
|
||||
### 5. ⏳ Mejorar Sistema de Vértices PNG_SHAPE
|
||||
**Descripción:** Con 50 pelotas no activa modo vértices correctamente
|
||||
**Prioridad:** Baja (mejora visual)
|
||||
**Estimación:** 1 hora
|
||||
**Detalles:**
|
||||
- **Comportamiento actual:** Con 50 pelotas usa filas alternas en bordes
|
||||
- **Comportamiento deseado:** Activar modo VÉRTICES (extremos izq/der de cada fila)
|
||||
- **Problema:** Condición `num_points < 150` no es suficientemente agresiva
|
||||
- **Solución propuesta:**
|
||||
- Ajustar umbrales de activación de vértices
|
||||
- Mejorar algoritmo extractCornerVertices() para detectar puntos clave
|
||||
- Considerar densidad de píxeles en decisión (no solo cantidad absoluta)
|
||||
|
||||
### 5. 🐛 Corregir Escalado de Pelotas en Reposo
|
||||
**Descripción:** Las pelotas cambian de tamaño cuando están quietas (bug visual)
|
||||
**Prioridad:** Alta (bug visible)
|
||||
**Estimación:** 30 minutos
|
||||
@@ -96,7 +137,7 @@
|
||||
- **Investigar:** Ball::render(), scale calculations, depth brightness
|
||||
- **Solución esperada:** Tamaño constante independiente de velocidad
|
||||
|
||||
### 5. ⏳ Sistema de Release
|
||||
### 6. ⏳ Sistema de Release
|
||||
**Descripción:** Empaquetado para distribución standalone
|
||||
**Prioridad:** Baja
|
||||
**Estimación:** 30 minutos
|
||||
@@ -165,13 +206,15 @@
|
||||
- ✅ Resolución configurable (mínimo 640x480)
|
||||
- 📝 Preparado para voxelización 3D (Enfoque B) en futuro
|
||||
|
||||
### 2025-10-04 (Sesión 4) - Modo DEMO
|
||||
### 2025-10-04 (Sesión 4) - Modo DEMO + Mejoras Animaciones
|
||||
- ✅ **Implementado Modo DEMO (auto-play)** - Tecla D para toggle
|
||||
- ✅ Sistema de acciones aleatorias cada 3-8 segundos (configurable)
|
||||
- ✅ 8 tipos de acciones con pesos de probabilidad ajustables
|
||||
- ✅ Totalmente interactivo - usuario puede seguir controlando
|
||||
- ✅ Display visual "DEMO MODE" centrado en naranja
|
||||
- ✅ Mejoras animaciones 3D: tumbling en cilindro + pivoteo en wave grid
|
||||
- ✅ **Mejoras animaciones 3D**: tumbling en cilindro + pivoteo en wave grid
|
||||
- ✅ CYLINDER: tumbling ocasional en eje X cada 3-5s con ease-in-out
|
||||
- ✅ WAVE_GRID: pivoteo sutil paralelo a pantalla (efecto océano)
|
||||
- ❌ Eliminado sistema auto-restart antiguo (ya no necesario)
|
||||
|
||||
### 2025-10-04 (Sesión 3)
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 720 B After Width: | Height: | Size: 618 B |
@@ -5,10 +5,10 @@
|
||||
// Configuración de ventana y pantalla
|
||||
constexpr char WINDOW_CAPTION[] = "vibe3_physics";
|
||||
|
||||
constexpr int SCREEN_WIDTH = 320; // Ancho de la pantalla lógica (píxeles)
|
||||
constexpr int SCREEN_HEIGHT = 240; // Alto de la pantalla lógica (píxeles)
|
||||
constexpr int WINDOW_ZOOM = 3; // Zoom inicial de la ventana
|
||||
// BALL_SIZE eliminado: ahora se obtiene dinámicamente desde texture_->getWidth()
|
||||
// Resolución por defecto (usada si no se especifica en CLI)
|
||||
constexpr int DEFAULT_SCREEN_WIDTH = 320; // Ancho lógico por defecto (si no hay -w)
|
||||
constexpr int DEFAULT_SCREEN_HEIGHT = 240; // Alto lógico por defecto (si no hay -h)
|
||||
constexpr int DEFAULT_WINDOW_ZOOM = 3; // Zoom inicial de ventana (1x = sin zoom)
|
||||
|
||||
// Configuración de zoom dinámico de ventana
|
||||
constexpr int WINDOW_ZOOM_MIN = 1; // Zoom mínimo (320x240)
|
||||
@@ -38,6 +38,9 @@ constexpr float GRAVITY_CHANGE_LATERAL_MAX = 0.08f; // Velocidad lateral máxim
|
||||
// Configuración de spawn inicial de pelotas
|
||||
constexpr float BALL_SPAWN_MARGIN = 0.15f; // Margen lateral para spawn (0.25 = 25% a cada lado)
|
||||
|
||||
// Escenarios de número de pelotas (teclas 1-8)
|
||||
constexpr int BALL_COUNT_SCENARIOS[8] = {10, 50, 100, 500, 1000, 5000, 10000, 50000};
|
||||
|
||||
// Estructura para representar colores RGB
|
||||
struct Color {
|
||||
int r, g, b; // Componentes rojo, verde, azul (0-255)
|
||||
@@ -203,4 +206,15 @@ constexpr int DEMO_LITE_WEIGHT_TOGGLE_PHYSICS = 20;// Toggle física ↔ figura
|
||||
constexpr int DEMO_LITE_WEIGHT_IMPULSE = 10; // Aplicar impulso (10%)
|
||||
// TOTAL: 100
|
||||
|
||||
// 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 float LOGO_MODE_SHAPE_SCALE = 1.2f; // Escala de figura en modo logo (120%)
|
||||
constexpr float LOGO_ACTION_INTERVAL_MIN = 2.0f; // Tiempo mínimo entre alternancia SHAPE/PHYSICS
|
||||
constexpr float LOGO_ACTION_INTERVAL_MAX = 5.0f; // Tiempo máximo entre alternancia SHAPE/PHYSICS
|
||||
constexpr int LOGO_WEIGHT_TOGGLE_PHYSICS = 100; // Único peso: alternar SHAPE ↔ PHYSICS (100%)
|
||||
|
||||
// Probabilidad de salto a Logo Mode desde DEMO/DEMO_LITE (%)
|
||||
constexpr int LOGO_JUMP_PROBABILITY_FROM_DEMO = 15; // 15% probabilidad en DEMO normal
|
||||
constexpr int LOGO_JUMP_PROBABILITY_FROM_DEMO_LITE = 10; // 10% probabilidad en DEMO LITE
|
||||
|
||||
constexpr float PI = 3.14159265358979323846f; // Constante PI
|
||||
@@ -13,9 +13,9 @@
|
||||
#include <cstdlib> // for rand, srand
|
||||
#include <cstring> // for strlen
|
||||
#include <ctime> // for time
|
||||
#include <filesystem> // for path operations
|
||||
#include <iostream> // for cout
|
||||
#include <string> // for string
|
||||
#include <filesystem> // for path operations
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h> // for GetModuleFileName
|
||||
@@ -24,15 +24,15 @@
|
||||
#include "ball.h" // for Ball
|
||||
#include "external/dbgtxt.h" // for dbg_init, dbg_print
|
||||
#include "external/texture.h" // for Texture
|
||||
#include "shapes/sphere_shape.h" // for SphereShape
|
||||
#include "shapes/cube_shape.h" // for CubeShape
|
||||
#include "shapes/helix_shape.h" // for HelixShape
|
||||
#include "shapes/wave_grid_shape.h" // for WaveGridShape
|
||||
#include "shapes/torus_shape.h" // for TorusShape
|
||||
#include "shapes/cylinder_shape.h" // for CylinderShape
|
||||
#include "shapes/icosahedron_shape.h" // for IcosahedronShape
|
||||
#include "shapes/atom_shape.h" // for AtomShape
|
||||
#include "shapes/cube_shape.h" // for CubeShape
|
||||
#include "shapes/cylinder_shape.h" // for CylinderShape
|
||||
#include "shapes/helix_shape.h" // for HelixShape
|
||||
#include "shapes/icosahedron_shape.h" // for IcosahedronShape
|
||||
#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
|
||||
|
||||
// Función auxiliar para obtener la ruta del directorio del ejecutable
|
||||
std::string getExecutableDirectory() {
|
||||
@@ -48,19 +48,64 @@ std::string getExecutableDirectory() {
|
||||
}
|
||||
|
||||
// Implementación de métodos públicos
|
||||
bool Engine::initialize(int width, int height, bool fullscreen) {
|
||||
bool Engine::initialize(int width, int height, int zoom, bool fullscreen) {
|
||||
bool success = true;
|
||||
|
||||
// Usar parámetros o valores por defecto
|
||||
int window_width = (width > 0) ? width : SCREEN_WIDTH * WINDOW_ZOOM;
|
||||
int window_height = (height > 0) ? height : SCREEN_HEIGHT * WINDOW_ZOOM;
|
||||
int logical_width = (width > 0) ? width : SCREEN_WIDTH;
|
||||
int logical_height = (height > 0) ? height : SCREEN_HEIGHT;
|
||||
|
||||
// Obtener resolución de pantalla para validación
|
||||
if (!SDL_Init(SDL_INIT_VIDEO)) {
|
||||
std::cout << "¡SDL no se pudo inicializar! Error de SDL: " << SDL_GetError() << std::endl;
|
||||
success = false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
int num_displays = 0;
|
||||
SDL_DisplayID *displays = SDL_GetDisplays(&num_displays);
|
||||
const auto *dm = (displays && num_displays > 0) ? SDL_GetCurrentDisplayMode(displays[0]) : nullptr;
|
||||
|
||||
int screen_w = dm ? dm->w : 1920; // Fallback si falla
|
||||
int screen_h = dm ? dm->h - WINDOW_DECORATION_HEIGHT : 1080;
|
||||
|
||||
if (displays) SDL_free(displays);
|
||||
|
||||
// Usar parámetros o valores por defecto
|
||||
int logical_width = (width > 0) ? width : DEFAULT_SCREEN_WIDTH;
|
||||
int logical_height = (height > 0) ? height : DEFAULT_SCREEN_HEIGHT;
|
||||
int window_zoom = (zoom > 0) ? zoom : DEFAULT_WINDOW_ZOOM;
|
||||
|
||||
// VALIDACIÓN 1: Si resolución > pantalla → reset a default
|
||||
if (logical_width > screen_w || logical_height > screen_h) {
|
||||
std::cout << "Advertencia: Resolución " << logical_width << "x" << logical_height
|
||||
<< " excede pantalla " << screen_w << "x" << screen_h
|
||||
<< ". Usando default " << DEFAULT_SCREEN_WIDTH << "x" << DEFAULT_SCREEN_HEIGHT << "\n";
|
||||
logical_width = DEFAULT_SCREEN_WIDTH;
|
||||
logical_height = DEFAULT_SCREEN_HEIGHT;
|
||||
window_zoom = DEFAULT_WINDOW_ZOOM; // Reset zoom también
|
||||
}
|
||||
|
||||
// VALIDACIÓN 2: Calcular max_zoom y ajustar si es necesario
|
||||
int max_zoom = std::min(screen_w / logical_width, screen_h / logical_height);
|
||||
if (window_zoom > max_zoom) {
|
||||
std::cout << "Advertencia: Zoom " << window_zoom << " excede máximo " << max_zoom
|
||||
<< " para " << logical_width << "x" << logical_height << ". Ajustando a " << max_zoom << "\n";
|
||||
window_zoom = max_zoom;
|
||||
}
|
||||
|
||||
// Si se especificaron parámetros CLI y zoom no se especificó, usar zoom=1
|
||||
if ((width > 0 || height > 0) && zoom == 0) {
|
||||
window_zoom = 1;
|
||||
}
|
||||
|
||||
// Calcular tamaño de ventana
|
||||
int window_width = logical_width * window_zoom;
|
||||
int window_height = logical_height * window_zoom;
|
||||
|
||||
// Guardar resolución base (configurada por CLI o default)
|
||||
base_screen_width_ = logical_width;
|
||||
base_screen_height_ = logical_height;
|
||||
current_screen_width_ = logical_width;
|
||||
current_screen_height_ = logical_height;
|
||||
|
||||
// SDL ya inicializado arriba para validación
|
||||
{
|
||||
// Crear ventana principal (fullscreen si se especifica)
|
||||
Uint32 window_flags = SDL_WINDOW_OPENGL;
|
||||
if (fullscreen) {
|
||||
@@ -607,8 +652,7 @@ void Engine::render() {
|
||||
}
|
||||
|
||||
// Ordenar índices por profundidad Z (menor primero = fondo primero)
|
||||
std::sort(render_order.begin(), render_order.end(),
|
||||
[this](size_t a, size_t b) {
|
||||
std::sort(render_order.begin(), render_order.end(), [this](size_t a, size_t b) {
|
||||
return balls_[a]->getDepthBrightness() < balls_[b]->getDepthBrightness();
|
||||
});
|
||||
|
||||
@@ -620,8 +664,7 @@ void Engine::render() {
|
||||
float depth_scale = balls_[idx]->getDepthScale();
|
||||
|
||||
// Mapear brightness de 0-1 a rango MIN-MAX
|
||||
float brightness_factor = (ROTOBALL_MIN_BRIGHTNESS + brightness *
|
||||
(ROTOBALL_MAX_BRIGHTNESS - ROTOBALL_MIN_BRIGHTNESS)) / 255.0f;
|
||||
float brightness_factor = (ROTOBALL_MIN_BRIGHTNESS + brightness * (ROTOBALL_MAX_BRIGHTNESS - ROTOBALL_MIN_BRIGHTNESS)) / 255.0f;
|
||||
|
||||
// Aplicar factor de brillo al color
|
||||
int r_mod = static_cast<int>(color.r * brightness_factor);
|
||||
@@ -735,7 +778,7 @@ void Engine::initBalls(int value) {
|
||||
changeGravityDirection(GravityDirection::DOWN);
|
||||
|
||||
// Crear las bolas según el escenario
|
||||
for (int i = 0; i < test_.at(value); ++i) {
|
||||
for (int i = 0; i < BALL_COUNT_SCENARIOS[value]; ++i) {
|
||||
const int SIGN = ((rand() % 2) * 2) - 1; // Genera un signo aleatorio (+ o -)
|
||||
// Calcular spawn zone: margen a cada lado, zona central para spawn
|
||||
const int margin = static_cast<int>(current_screen_width_ * BALL_SPAWN_MARGIN);
|
||||
@@ -758,7 +801,7 @@ void Engine::setText() {
|
||||
// Suprimir textos durante modos demo
|
||||
if (demo_mode_enabled_ || demo_lite_enabled_) return;
|
||||
|
||||
int num_balls = test_.at(scenario_);
|
||||
int num_balls = BALL_COUNT_SCENARIOS[scenario_];
|
||||
if (num_balls == 1) {
|
||||
text_ = "1 PELOTA";
|
||||
} else {
|
||||
@@ -891,16 +934,16 @@ void Engine::toggleRealFullscreen() {
|
||||
// Ocultar cursor en real fullscreen
|
||||
SDL_HideCursor();
|
||||
} else {
|
||||
// Volver a resolución original
|
||||
current_screen_width_ = SCREEN_WIDTH;
|
||||
current_screen_height_ = SCREEN_HEIGHT;
|
||||
// Volver a resolución base (configurada por CLI o default)
|
||||
current_screen_width_ = base_screen_width_;
|
||||
current_screen_height_ = base_screen_height_;
|
||||
|
||||
// Restaurar ventana normal
|
||||
SDL_SetWindowFullscreen(window_, false);
|
||||
SDL_SetWindowSize(window_, SCREEN_WIDTH * WINDOW_ZOOM, SCREEN_HEIGHT * WINDOW_ZOOM);
|
||||
SDL_SetWindowSize(window_, base_screen_width_ * DEFAULT_WINDOW_ZOOM, base_screen_height_ * DEFAULT_WINDOW_ZOOM);
|
||||
|
||||
// Restaurar presentación lógica original
|
||||
SDL_SetRenderLogicalPresentation(renderer_, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
||||
// Restaurar presentación lógica base
|
||||
SDL_SetRenderLogicalPresentation(renderer_, base_screen_width_, base_screen_height_, SDL_LOGICAL_PRESENTATION_INTEGER_SCALE);
|
||||
|
||||
// Reinicar la escena con resolución original
|
||||
initBalls(scenario_);
|
||||
@@ -948,7 +991,7 @@ void Engine::toggleIntegerScaling() {
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_SetRenderLogicalPresentation(renderer_, SCREEN_WIDTH, SCREEN_HEIGHT, presentation);
|
||||
SDL_SetRenderLogicalPresentation(renderer_, current_screen_width_, current_screen_height_, presentation);
|
||||
|
||||
// Mostrar texto informativo
|
||||
text_ = "SCALING: ";
|
||||
@@ -960,11 +1003,16 @@ void Engine::toggleIntegerScaling() {
|
||||
|
||||
std::string Engine::gravityDirectionToString(GravityDirection direction) const {
|
||||
switch (direction) {
|
||||
case GravityDirection::DOWN: return "DOWN";
|
||||
case GravityDirection::UP: return "UP";
|
||||
case GravityDirection::LEFT: return "LEFT";
|
||||
case GravityDirection::RIGHT: return "RIGHT";
|
||||
default: return "UNKNOWN";
|
||||
case GravityDirection::DOWN:
|
||||
return "DOWN";
|
||||
case GravityDirection::UP:
|
||||
return "UP";
|
||||
case GravityDirection::LEFT:
|
||||
return "LEFT";
|
||||
case GravityDirection::RIGHT:
|
||||
return "RIGHT";
|
||||
default:
|
||||
return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1094,7 +1142,7 @@ int Engine::calculateMaxWindowZoom() const {
|
||||
}
|
||||
|
||||
// Calcular zoom máximo usando la fórmula de Coffee Crisis
|
||||
const int MAX_ZOOM = std::min(dm->w / SCREEN_WIDTH, (dm->h - WINDOW_DECORATION_HEIGHT) / SCREEN_HEIGHT);
|
||||
const int MAX_ZOOM = std::min(dm->w / base_screen_width_, (dm->h - WINDOW_DECORATION_HEIGHT) / base_screen_height_);
|
||||
|
||||
SDL_free(displays);
|
||||
|
||||
@@ -1114,12 +1162,12 @@ void Engine::setWindowZoom(int new_zoom) {
|
||||
// Obtener posición actual del centro de la ventana
|
||||
int current_x, current_y;
|
||||
SDL_GetWindowPosition(window_, ¤t_x, ¤t_y);
|
||||
int current_center_x = current_x + (SCREEN_WIDTH * current_window_zoom_) / 2;
|
||||
int current_center_y = current_y + (SCREEN_HEIGHT * current_window_zoom_) / 2;
|
||||
int current_center_x = current_x + (base_screen_width_ * current_window_zoom_) / 2;
|
||||
int current_center_y = current_y + (base_screen_height_ * current_window_zoom_) / 2;
|
||||
|
||||
// Calcular nuevo tamaño
|
||||
int new_width = SCREEN_WIDTH * new_zoom;
|
||||
int new_height = SCREEN_HEIGHT * new_zoom;
|
||||
int new_width = base_screen_width_ * new_zoom;
|
||||
int new_height = base_screen_height_ * new_zoom;
|
||||
|
||||
// Calcular nueva posición (centrada en el punto actual)
|
||||
int new_x = current_center_x - new_width / 2;
|
||||
@@ -1156,46 +1204,77 @@ void Engine::zoomOut() {
|
||||
void Engine::initializeThemes() {
|
||||
// SUNSET: Naranjas, rojos, amarillos, rosas (8 colores)
|
||||
themes_[0] = {
|
||||
"SUNSET", "ATARDECER", // Nombres (inglés, español)
|
||||
255, 140, 60, // Color texto: naranja cálido
|
||||
180.0f / 255.0f, 140.0f / 255.0f, 100.0f / 255.0f, // Fondo superior (naranja suave)
|
||||
40.0f / 255.0f, 20.0f / 255.0f, 60.0f / 255.0f, // Fondo inferior (púrpura oscuro)
|
||||
{{255, 140, 0}, {255, 69, 0}, {255, 215, 0}, {255, 20, 147}, {255, 99, 71}, {255, 165, 0}, {255, 192, 203}, {220, 20, 60}}
|
||||
};
|
||||
"SUNSET",
|
||||
"ATARDECER", // Nombres (inglés, español)
|
||||
255,
|
||||
140,
|
||||
60, // Color texto: naranja cálido
|
||||
180.0f / 255.0f,
|
||||
140.0f / 255.0f,
|
||||
100.0f / 255.0f, // Fondo superior (naranja suave)
|
||||
40.0f / 255.0f,
|
||||
20.0f / 255.0f,
|
||||
60.0f / 255.0f, // Fondo inferior (púrpura oscuro)
|
||||
{{255, 140, 0}, {255, 69, 0}, {255, 215, 0}, {255, 20, 147}, {255, 99, 71}, {255, 165, 0}, {255, 192, 203}, {220, 20, 60}}};
|
||||
|
||||
// OCEAN: Azules, turquesas, blancos (8 colores)
|
||||
themes_[1] = {
|
||||
"OCEAN", "OCEANO", // Nombres (inglés, español)
|
||||
80, 200, 255, // Color texto: azul océano
|
||||
100.0f / 255.0f, 150.0f / 255.0f, 200.0f / 255.0f, // Fondo superior (azul cielo)
|
||||
20.0f / 255.0f, 40.0f / 255.0f, 80.0f / 255.0f, // Fondo inferior (azul marino)
|
||||
{{0, 191, 255}, {0, 255, 255}, {32, 178, 170}, {176, 224, 230}, {70, 130, 180}, {0, 206, 209}, {240, 248, 255}, {64, 224, 208}}
|
||||
};
|
||||
"OCEAN",
|
||||
"OCEANO", // Nombres (inglés, español)
|
||||
80,
|
||||
200,
|
||||
255, // Color texto: azul océano
|
||||
100.0f / 255.0f,
|
||||
150.0f / 255.0f,
|
||||
200.0f / 255.0f, // Fondo superior (azul cielo)
|
||||
20.0f / 255.0f,
|
||||
40.0f / 255.0f,
|
||||
80.0f / 255.0f, // Fondo inferior (azul marino)
|
||||
{{0, 191, 255}, {0, 255, 255}, {32, 178, 170}, {176, 224, 230}, {70, 130, 180}, {0, 206, 209}, {240, 248, 255}, {64, 224, 208}}};
|
||||
|
||||
// NEON: Cian, magenta, verde lima, amarillo vibrante (8 colores)
|
||||
themes_[2] = {
|
||||
"NEON", "NEON", // Nombres (inglés, español)
|
||||
255, 60, 255, // Color texto: magenta brillante
|
||||
20.0f / 255.0f, 20.0f / 255.0f, 40.0f / 255.0f, // Fondo superior (negro azulado)
|
||||
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo inferior (negro)
|
||||
{{0, 255, 255}, {255, 0, 255}, {50, 205, 50}, {255, 255, 0}, {255, 20, 147}, {0, 255, 127}, {138, 43, 226}, {255, 69, 0}}
|
||||
};
|
||||
"NEON",
|
||||
"NEON", // Nombres (inglés, español)
|
||||
255,
|
||||
60,
|
||||
255, // Color texto: magenta brillante
|
||||
20.0f / 255.0f,
|
||||
20.0f / 255.0f,
|
||||
40.0f / 255.0f, // Fondo superior (negro azulado)
|
||||
0.0f / 255.0f,
|
||||
0.0f / 255.0f,
|
||||
0.0f / 255.0f, // Fondo inferior (negro)
|
||||
{{0, 255, 255}, {255, 0, 255}, {50, 205, 50}, {255, 255, 0}, {255, 20, 147}, {0, 255, 127}, {138, 43, 226}, {255, 69, 0}}};
|
||||
|
||||
// FOREST: Verdes, marrones, amarillos otoño (8 colores)
|
||||
themes_[3] = {
|
||||
"FOREST", "BOSQUE", // Nombres (inglés, español)
|
||||
100, 255, 100, // Color texto: verde natural
|
||||
144.0f / 255.0f, 238.0f / 255.0f, 144.0f / 255.0f, // Fondo superior (verde claro)
|
||||
101.0f / 255.0f, 67.0f / 255.0f, 33.0f / 255.0f, // Fondo inferior (marrón tierra)
|
||||
{{34, 139, 34}, {107, 142, 35}, {154, 205, 50}, {255, 215, 0}, {210, 180, 140}, {160, 82, 45}, {218, 165, 32}, {50, 205, 50}}
|
||||
};
|
||||
"FOREST",
|
||||
"BOSQUE", // Nombres (inglés, español)
|
||||
100,
|
||||
255,
|
||||
100, // Color texto: verde natural
|
||||
144.0f / 255.0f,
|
||||
238.0f / 255.0f,
|
||||
144.0f / 255.0f, // Fondo superior (verde claro)
|
||||
101.0f / 255.0f,
|
||||
67.0f / 255.0f,
|
||||
33.0f / 255.0f, // Fondo inferior (marrón tierra)
|
||||
{{34, 139, 34}, {107, 142, 35}, {154, 205, 50}, {255, 215, 0}, {210, 180, 140}, {160, 82, 45}, {218, 165, 32}, {50, 205, 50}}};
|
||||
|
||||
// RGB: Círculo cromático con 24 puntos (cada 15°) - Ultra precisión matemática
|
||||
themes_[4] = {
|
||||
"RGB", "RGB", // Nombres (inglés, español)
|
||||
100, 100, 100, // Color texto: gris oscuro (contraste con fondo blanco)
|
||||
1.0f, 1.0f, 1.0f, // Fondo superior (blanco puro)
|
||||
1.0f, 1.0f, 1.0f, // Fondo inferior (blanco puro) - sin degradado
|
||||
"RGB",
|
||||
"RGB", // Nombres (inglés, español)
|
||||
100,
|
||||
100,
|
||||
100, // Color texto: gris oscuro (contraste con fondo blanco)
|
||||
1.0f,
|
||||
1.0f,
|
||||
1.0f, // Fondo superior (blanco puro)
|
||||
1.0f,
|
||||
1.0f,
|
||||
1.0f, // Fondo inferior (blanco puro) - sin degradado
|
||||
{
|
||||
{255, 0, 0}, // 0° - Rojo puro
|
||||
{255, 64, 0}, // 15° - Rojo-Naranja
|
||||
@@ -1221,15 +1300,21 @@ void Engine::initializeThemes() {
|
||||
{255, 0, 191}, // 315° - Magenta-Rojo claro
|
||||
{255, 0, 128}, // 330° - Magenta-Rojo
|
||||
{255, 0, 64} // 345° - Magenta claro-Rojo
|
||||
}
|
||||
};
|
||||
}};
|
||||
|
||||
// MONOCHROME: Fondo negro degradado, sprites blancos monocromáticos (8 tonos grises)
|
||||
themes_[5] = {
|
||||
"MONOCHROME", "MONOCROMO", // Nombres (inglés, español)
|
||||
200, 200, 200, // Color texto: gris claro
|
||||
20.0f / 255.0f, 20.0f / 255.0f, 20.0f / 255.0f, // Fondo superior (gris muy oscuro)
|
||||
0.0f / 255.0f, 0.0f / 255.0f, 0.0f / 255.0f, // Fondo inferior (negro)
|
||||
"MONOCHROME",
|
||||
"MONOCROMO", // Nombres (inglés, español)
|
||||
200,
|
||||
200,
|
||||
200, // Color texto: gris claro
|
||||
20.0f / 255.0f,
|
||||
20.0f / 255.0f,
|
||||
20.0f / 255.0f, // Fondo superior (gris muy oscuro)
|
||||
0.0f / 255.0f,
|
||||
0.0f / 255.0f,
|
||||
0.0f / 255.0f, // Fondo inferior (negro)
|
||||
{
|
||||
{255, 255, 255}, // Blanco puro - todas las pelotas del mismo color
|
||||
{255, 255, 255},
|
||||
@@ -1238,9 +1323,7 @@ void Engine::initializeThemes() {
|
||||
{255, 255, 255},
|
||||
{255, 255, 255},
|
||||
{255, 255, 255},
|
||||
{255, 255, 255}
|
||||
}
|
||||
};
|
||||
{255, 255, 255}}};
|
||||
}
|
||||
|
||||
void Engine::startThemeTransition(ColorTheme new_theme) {
|
||||
@@ -1278,8 +1361,7 @@ Color Engine::getInterpolatedColor(size_t ball_index) const {
|
||||
return {
|
||||
static_cast<Uint8>(lerp(static_cast<float>(current_color.r), static_cast<float>(target_color.r), transition_progress_)),
|
||||
static_cast<Uint8>(lerp(static_cast<float>(current_color.g), static_cast<float>(target_color.g), transition_progress_)),
|
||||
static_cast<Uint8>(lerp(static_cast<float>(current_color.b), static_cast<float>(target_color.b), transition_progress_))
|
||||
};
|
||||
static_cast<Uint8>(lerp(static_cast<float>(current_color.b), static_cast<float>(target_color.b), transition_progress_))};
|
||||
}
|
||||
|
||||
// Sistema de Modo DEMO (auto-play)
|
||||
@@ -1315,9 +1397,7 @@ void Engine::performDemoAction(bool is_lite) {
|
||||
|
||||
if (is_lite) {
|
||||
// DEMO LITE: Solo física/figuras
|
||||
TOTAL_WEIGHT = DEMO_LITE_WEIGHT_GRAVITY_DIR + DEMO_LITE_WEIGHT_GRAVITY_TOGGLE
|
||||
+ DEMO_LITE_WEIGHT_SHAPE + DEMO_LITE_WEIGHT_TOGGLE_PHYSICS
|
||||
+ DEMO_LITE_WEIGHT_IMPULSE;
|
||||
TOTAL_WEIGHT = DEMO_LITE_WEIGHT_GRAVITY_DIR + DEMO_LITE_WEIGHT_GRAVITY_TOGGLE + DEMO_LITE_WEIGHT_SHAPE + DEMO_LITE_WEIGHT_TOGGLE_PHYSICS + DEMO_LITE_WEIGHT_IMPULSE;
|
||||
random_value = rand() % TOTAL_WEIGHT;
|
||||
|
||||
// Cambiar dirección gravedad (25%)
|
||||
@@ -1338,9 +1418,7 @@ void Engine::performDemoAction(bool is_lite) {
|
||||
// Activar figura 3D (25%)
|
||||
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::PNG_SHAPE};
|
||||
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::WAVE_GRID, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM, ShapeType::PNG_SHAPE};
|
||||
int shape_index = rand() % 9;
|
||||
activateShape(shapes[shape_index]);
|
||||
return;
|
||||
@@ -1362,10 +1440,7 @@ void Engine::performDemoAction(bool is_lite) {
|
||||
|
||||
} else {
|
||||
// DEMO COMPLETO: Todas las acciones
|
||||
TOTAL_WEIGHT = DEMO_WEIGHT_GRAVITY_DIR + DEMO_WEIGHT_GRAVITY_TOGGLE + DEMO_WEIGHT_SHAPE
|
||||
+ DEMO_WEIGHT_TOGGLE_PHYSICS + DEMO_WEIGHT_REGENERATE_SHAPE + DEMO_WEIGHT_THEME
|
||||
+ DEMO_WEIGHT_SCENARIO + DEMO_WEIGHT_IMPULSE + DEMO_WEIGHT_DEPTH_ZOOM
|
||||
+ DEMO_WEIGHT_SHAPE_SCALE + DEMO_WEIGHT_SPRITE;
|
||||
TOTAL_WEIGHT = DEMO_WEIGHT_GRAVITY_DIR + DEMO_WEIGHT_GRAVITY_TOGGLE + DEMO_WEIGHT_SHAPE + DEMO_WEIGHT_TOGGLE_PHYSICS + DEMO_WEIGHT_REGENERATE_SHAPE + DEMO_WEIGHT_THEME + DEMO_WEIGHT_SCENARIO + DEMO_WEIGHT_IMPULSE + DEMO_WEIGHT_DEPTH_ZOOM + DEMO_WEIGHT_SHAPE_SCALE + DEMO_WEIGHT_SPRITE;
|
||||
random_value = rand() % TOTAL_WEIGHT;
|
||||
|
||||
// Cambiar dirección gravedad (10%)
|
||||
@@ -1386,9 +1461,7 @@ void Engine::performDemoAction(bool is_lite) {
|
||||
// Activar figura 3D (20%)
|
||||
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::PNG_SHAPE};
|
||||
ShapeType shapes[] = {ShapeType::SPHERE, ShapeType::WAVE_GRID, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM, ShapeType::PNG_SHAPE};
|
||||
int shape_index = rand() % 9;
|
||||
activateShape(shapes[shape_index]);
|
||||
return;
|
||||
@@ -1483,9 +1556,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::WAVE_GRID, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
activateShape(shapes[rand() % 8]);
|
||||
}
|
||||
|
||||
@@ -1521,9 +1592,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::WAVE_GRID, ShapeType::HELIX, ShapeType::TORUS, ShapeType::CUBE, ShapeType::CYLINDER, ShapeType::ICOSAHEDRON, ShapeType::ATOM};
|
||||
activateShape(shapes[rand() % 8]);
|
||||
|
||||
// 5. Profundidad (solo si estamos en figura)
|
||||
@@ -1774,9 +1843,7 @@ void Engine::updateShape() {
|
||||
// Aplicar fuerza de atracción física hacia el punto rotado
|
||||
// Usar constantes SHAPE (mayor pegajosidad que ROTOBALL)
|
||||
float shape_size = scale_factor * 80.0f; // 80px = radio base
|
||||
balls_[i]->applyRotoBallForce(target_x, target_y, shape_size, delta_time_,
|
||||
SHAPE_SPRING_K, SHAPE_DAMPING_BASE, SHAPE_DAMPING_NEAR,
|
||||
SHAPE_NEAR_THRESHOLD, SHAPE_MAX_FORCE);
|
||||
balls_[i]->applyRotoBallForce(target_x, target_y, shape_size, delta_time_, SHAPE_SPRING_K, SHAPE_DAMPING_BASE, SHAPE_DAMPING_NEAR, SHAPE_NEAR_THRESHOLD, SHAPE_MAX_FORCE);
|
||||
|
||||
// Calcular brillo según profundidad Z para renderizado
|
||||
// Normalizar Z al rango de la figura (asumiendo simetría ±shape_size)
|
||||
|
||||
@@ -10,15 +10,15 @@
|
||||
#include <string> // for string
|
||||
#include <vector> // for vector
|
||||
|
||||
#include "defines.h" // for GravityDirection, ColorTheme, ShapeType
|
||||
#include "ball.h" // for Ball
|
||||
#include "defines.h" // for GravityDirection, ColorTheme, ShapeType
|
||||
#include "external/texture.h" // for Texture
|
||||
#include "shapes/shape.h" // for Shape (interfaz polimórfica)
|
||||
|
||||
class Engine {
|
||||
public:
|
||||
// Interfaz pública
|
||||
bool initialize(int width = 0, int height = 0, bool fullscreen = false);
|
||||
bool initialize(int width = 0, int height = 0, int zoom = 0, bool fullscreen = false);
|
||||
void run();
|
||||
void shutdown();
|
||||
|
||||
@@ -34,7 +34,6 @@ private:
|
||||
|
||||
// Estado del simulador
|
||||
std::vector<std::unique_ptr<Ball>> balls_;
|
||||
std::array<int, 8> test_ = {1, 10, 100, 500, 1000, 10000, 50000, 100000};
|
||||
GravityDirection current_gravity_ = GravityDirection::DOWN;
|
||||
int scenario_ = 0;
|
||||
bool should_exit_ = false;
|
||||
@@ -48,7 +47,7 @@ private:
|
||||
bool show_text_ = true;
|
||||
|
||||
// Sistema de zoom dinámico
|
||||
int current_window_zoom_ = WINDOW_ZOOM;
|
||||
int current_window_zoom_ = DEFAULT_WINDOW_ZOOM;
|
||||
std::string text_;
|
||||
int text_pos_ = 0;
|
||||
Uint64 text_init_time_ = 0;
|
||||
@@ -64,9 +63,13 @@ private:
|
||||
bool real_fullscreen_enabled_ = false;
|
||||
ScalingMode current_scaling_mode_ = ScalingMode::INTEGER; // Modo de escalado actual (F5)
|
||||
|
||||
// Resolución dinámica para modo real fullscreen
|
||||
int current_screen_width_ = SCREEN_WIDTH;
|
||||
int current_screen_height_ = SCREEN_HEIGHT;
|
||||
// Resolución base (configurada por CLI o default)
|
||||
int base_screen_width_ = DEFAULT_SCREEN_WIDTH;
|
||||
int base_screen_height_ = DEFAULT_SCREEN_HEIGHT;
|
||||
|
||||
// Resolución dinámica actual (cambia en fullscreen real)
|
||||
int current_screen_width_ = DEFAULT_SCREEN_WIDTH;
|
||||
int current_screen_height_ = DEFAULT_SCREEN_HEIGHT;
|
||||
|
||||
// Sistema de temas
|
||||
ColorTheme current_theme_ = ColorTheme::SUNSET;
|
||||
@@ -99,9 +102,15 @@ private:
|
||||
// Sistema de Modo DEMO (auto-play)
|
||||
bool demo_mode_enabled_ = false; // ¿Está activo el modo demo completo?
|
||||
bool demo_lite_enabled_ = false; // ¿Está activo el modo demo lite?
|
||||
bool logo_mode_enabled_ = false; // ¿Está activo el modo logo (easter egg)?
|
||||
float demo_timer_ = 0.0f; // Contador de tiempo para próxima acción
|
||||
float demo_next_action_time_ = 0.0f; // Tiempo aleatorio hasta próxima acción (segundos)
|
||||
|
||||
// Estado previo antes de entrar a Logo Mode (para restaurar al salir)
|
||||
ColorTheme logo_previous_theme_ = ColorTheme::SUNSET;
|
||||
size_t logo_previous_texture_index_ = 0;
|
||||
float logo_previous_shape_scale_ = 1.0f;
|
||||
|
||||
// Batch rendering
|
||||
std::vector<SDL_Vertex> batch_vertices_;
|
||||
std::vector<int> batch_indices_;
|
||||
@@ -134,6 +143,11 @@ private:
|
||||
void randomizeOnDemoStart(bool is_lite);
|
||||
void toggleGravityOnOff();
|
||||
|
||||
// Sistema de Modo Logo (easter egg)
|
||||
void toggleLogoMode(); // Activar/desactivar modo logo manual (tecla K)
|
||||
void enterLogoMode(bool from_demo = false); // Entrar al modo logo (manual o automático)
|
||||
void exitLogoMode(bool return_to_demo = false); // Salir del modo logo
|
||||
|
||||
// Sistema de transiciones LERP
|
||||
float lerp(float a, float b, float t) const { return a + (b - a) * t; }
|
||||
Color getInterpolatedColor(size_t ball_index) const; // Obtener color interpolado durante transición
|
||||
|
||||
@@ -6,19 +6,23 @@ void printHelp() {
|
||||
std::cout << "ViBe3 Physics - Simulador de físicas avanzadas\n";
|
||||
std::cout << "\nUso: vibe3_physics [opciones]\n\n";
|
||||
std::cout << "Opciones:\n";
|
||||
std::cout << " -w, --width <px> Ancho de resolución (default: 1280)\n";
|
||||
std::cout << " -h, --height <px> Alto de resolución (default: 720)\n";
|
||||
std::cout << " -w, --width <px> Ancho de resolución (default: 320)\n";
|
||||
std::cout << " -h, --height <px> Alto de resolución (default: 240)\n";
|
||||
std::cout << " -z, --zoom <n> Zoom de ventana (default: 3)\n";
|
||||
std::cout << " -f, --fullscreen Modo pantalla completa\n";
|
||||
std::cout << " --help Mostrar esta ayuda\n\n";
|
||||
std::cout << "Ejemplos:\n";
|
||||
std::cout << " vibe3_physics # 1280x720 ventana\n";
|
||||
std::cout << " vibe3_physics -w 1920 -h 1080 # 1920x1080 ventana\n";
|
||||
std::cout << " vibe3_physics -w 1920 -h 1080 -f # 1920x1080 fullscreen\n";
|
||||
std::cout << " vibe3_physics # 320x240 zoom 3 (ventana 960x720)\n";
|
||||
std::cout << " vibe3_physics -w 1920 -h 1080 # 1920x1080 zoom 1 (auto)\n";
|
||||
std::cout << " vibe3_physics -w 640 -h 480 -z 2 # 640x480 zoom 2 (ventana 1280x960)\n";
|
||||
std::cout << " vibe3_physics -w 1920 -h 1080 -f # 1920x1080 fullscreen\n\n";
|
||||
std::cout << "Nota: Si resolución > pantalla, se usa default. Zoom se ajusta automáticamente.\n";
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
int width = 0;
|
||||
int height = 0;
|
||||
int zoom = 0;
|
||||
bool fullscreen = false;
|
||||
|
||||
// Parsear argumentos
|
||||
@@ -48,6 +52,17 @@ int main(int argc, char* argv[]) {
|
||||
std::cerr << "Error: -h/--height requiere un valor\n";
|
||||
return -1;
|
||||
}
|
||||
} else if (strcmp(argv[i], "-z") == 0 || strcmp(argv[i], "--zoom") == 0) {
|
||||
if (i + 1 < argc) {
|
||||
zoom = atoi(argv[++i]);
|
||||
if (zoom < 1) {
|
||||
std::cerr << "Error: Zoom mínimo es 1\n";
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
std::cerr << "Error: -z/--zoom requiere un valor\n";
|
||||
return -1;
|
||||
}
|
||||
} else if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "--fullscreen") == 0) {
|
||||
fullscreen = true;
|
||||
} else {
|
||||
@@ -59,7 +74,7 @@ int main(int argc, char* argv[]) {
|
||||
|
||||
Engine engine;
|
||||
|
||||
if (!engine.initialize(width, height, fullscreen)) {
|
||||
if (!engine.initialize(width, height, zoom, fullscreen)) {
|
||||
std::cout << "¡Error al inicializar el engine!" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
PNGShape::PNGShape(const char* png_path) {
|
||||
// Cargar PNG desde path
|
||||
@@ -98,14 +99,118 @@ void PNGShape::generatePoints(int num_points, float screen_width, float screen_h
|
||||
extrusion_depth_ = screen_height * PNG_EXTRUSION_DEPTH_FACTOR;
|
||||
num_layers_ = PNG_NUM_EXTRUSION_LAYERS;
|
||||
|
||||
// Generar puntos según el enfoque
|
||||
generateExtrudedPoints();
|
||||
// Generar AMBOS conjuntos de puntos (relleno Y bordes)
|
||||
floodFill(); // Generar filled_points_
|
||||
detectEdges(); // Generar edge_points_
|
||||
|
||||
// Debug: mostrar cantidad de puntos 2D detectados
|
||||
size_t num_2d_points = PNG_USE_EDGES_ONLY ? edge_points_.size() : filled_points_.size();
|
||||
size_t total_3d_points = num_2d_points * num_layers_;
|
||||
std::cout << "[PNG_SHAPE] Detectados " << num_2d_points << " puntos 2D × "
|
||||
<< num_layers_ << " capas = " << total_3d_points << " puntos 3D totales\n";
|
||||
// Guardar copias originales (las funciones de filtrado modifican los vectores)
|
||||
std::vector<Point2D> filled_points_original = filled_points_;
|
||||
std::vector<Point2D> edge_points_original = edge_points_;
|
||||
|
||||
// Conjunto de puntos ACTIVO (será modificado por filtros)
|
||||
std::vector<Point2D> active_points_data;
|
||||
std::string mode_name = "";
|
||||
|
||||
// === SISTEMA DE DISTRIBUCIÓN ADAPTATIVA ===
|
||||
// Estrategia: Optimizar según número de pelotas disponibles
|
||||
// Objetivo: SIEMPRE intentar usar relleno primero, solo bordes si es necesario
|
||||
|
||||
size_t num_2d_points = 0;
|
||||
size_t total_3d_points = 0;
|
||||
|
||||
// NIVEL 1: Decidir punto de partida (relleno o bordes por configuración)
|
||||
if (PNG_USE_EDGES_ONLY) {
|
||||
active_points_data = edge_points_original;
|
||||
mode_name = "BORDES (config)";
|
||||
} else {
|
||||
active_points_data = filled_points_original;
|
||||
mode_name = "RELLENO";
|
||||
}
|
||||
|
||||
num_2d_points = active_points_data.size();
|
||||
total_3d_points = num_2d_points * num_layers_;
|
||||
|
||||
std::cout << "[PNG_SHAPE] Nivel 1: Modo inicial " << mode_name
|
||||
<< " (puntos 2D: " << num_2d_points << ", capas: " << num_layers_
|
||||
<< ", total 3D: " << total_3d_points << ")\n";
|
||||
std::cout << "[PNG_SHAPE] Pelotas disponibles: " << num_points << "\n";
|
||||
|
||||
// NIVEL 2: Reducir capas AGRESIVAMENTE hasta 1 (priorizar calidad 2D sobre profundidad 3D)
|
||||
// Objetivo: Llenar bien el texto en 2D antes de reducir píxeles
|
||||
while (num_layers_ > 1 && num_points < static_cast<int>(total_3d_points)) {
|
||||
num_layers_ = std::max(1, num_layers_ / 2);
|
||||
total_3d_points = num_2d_points * num_layers_;
|
||||
std::cout << "[PNG_SHAPE] Nivel 2: Reduciendo capas a " << num_layers_
|
||||
<< " (total 3D: " << total_3d_points << ")\n";
|
||||
}
|
||||
|
||||
// NIVEL 3: Filas alternas en RELLENO (solo si 1 capa no alcanza)
|
||||
// Esto permite usar relleno incluso con pocas pelotas
|
||||
int row_skip = 1;
|
||||
if (!PNG_USE_EDGES_ONLY) { // Solo si empezamos con relleno
|
||||
while (row_skip < 5 && num_points < static_cast<int>(total_3d_points)) {
|
||||
row_skip++;
|
||||
// ✅ CLAVE: Recalcular desde el ORIGINAL cada vez (no desde el filtrado previo)
|
||||
active_points_data = extractAlternateRows(filled_points_original, row_skip);
|
||||
num_2d_points = active_points_data.size();
|
||||
total_3d_points = num_2d_points * num_layers_;
|
||||
std::cout << "[PNG_SHAPE] Nivel 3: Filas alternas RELLENO (cada " << row_skip
|
||||
<< " filas, puntos 2D: " << num_2d_points << ", total 3D: " << total_3d_points << ")\n";
|
||||
mode_name = "RELLENO + FILAS/" + std::to_string(row_skip);
|
||||
}
|
||||
}
|
||||
|
||||
// NIVEL 4: Cambiar a BORDES (solo si relleno con filas alternas no alcanza)
|
||||
if (!PNG_USE_EDGES_ONLY && num_points < static_cast<int>(total_3d_points)) {
|
||||
active_points_data = edge_points_original;
|
||||
mode_name = "BORDES (auto)";
|
||||
num_2d_points = active_points_data.size();
|
||||
total_3d_points = num_2d_points * num_layers_;
|
||||
row_skip = 1; // Reset row_skip para bordes
|
||||
std::cout << "[PNG_SHAPE] Nivel 4: Cambiando a BORDES (pelotas: " << num_points
|
||||
<< ", necesarias: " << total_3d_points << ")\n";
|
||||
}
|
||||
|
||||
// NIVEL 5: Filas alternas en BORDES (si aún no alcanza)
|
||||
while (row_skip < 8 && num_points < static_cast<int>(total_3d_points)) {
|
||||
row_skip++;
|
||||
// ✅ CLAVE: Recalcular desde edge_points_original cada vez
|
||||
active_points_data = extractAlternateRows(edge_points_original, row_skip);
|
||||
num_2d_points = active_points_data.size();
|
||||
total_3d_points = num_2d_points * num_layers_;
|
||||
std::cout << "[PNG_SHAPE] Nivel 5: Filas alternas BORDES (cada " << row_skip
|
||||
<< " filas, puntos 2D: " << num_2d_points << ", total 3D: " << total_3d_points << ")\n";
|
||||
if (mode_name.find("FILAS") == std::string::npos) {
|
||||
mode_name += " + FILAS/" + std::to_string(row_skip);
|
||||
}
|
||||
}
|
||||
|
||||
// NIVEL 6: Vértices/esquinas (último recurso, muy pocas pelotas)
|
||||
if (num_points < static_cast<int>(total_3d_points) && num_points < 150) {
|
||||
// Determinar desde qué conjunto extraer vértices (el que esté activo actualmente)
|
||||
const std::vector<Point2D>& source_for_vertices = (mode_name.find("BORDES") != std::string::npos)
|
||||
? edge_points_original
|
||||
: filled_points_original;
|
||||
|
||||
std::vector<Point2D> vertices = extractCornerVertices(source_for_vertices);
|
||||
if (!vertices.empty() && vertices.size() < active_points_data.size()) {
|
||||
active_points_data = vertices;
|
||||
num_2d_points = active_points_data.size();
|
||||
total_3d_points = num_2d_points * num_layers_;
|
||||
mode_name = "VÉRTICES";
|
||||
std::cout << "[PNG_SHAPE] Nivel 6: Solo vértices (puntos 2D: " << num_2d_points << ")\n";
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ CLAVE: Guardar el conjunto de puntos optimizado final en optimized_points_ (usado por getPoint3D)
|
||||
optimized_points_ = active_points_data;
|
||||
|
||||
// Debug: mostrar configuración final
|
||||
std::cout << "[PNG_SHAPE] === CONFIGURACIÓN FINAL ===\n";
|
||||
std::cout << "[PNG_SHAPE] Modo: " << mode_name << "\n";
|
||||
std::cout << "[PNG_SHAPE] Píxeles 2D: " << num_2d_points << "\n";
|
||||
std::cout << "[PNG_SHAPE] Capas extrusión: " << num_layers_ << "\n";
|
||||
std::cout << "[PNG_SHAPE] Total puntos 3D: " << total_3d_points << "\n";
|
||||
std::cout << "[PNG_SHAPE] Pelotas disponibles: " << num_points << "\n";
|
||||
std::cout << "[PNG_SHAPE] Ratio: " << (float)num_points / (float)total_3d_points << " pelotas/punto\n";
|
||||
|
||||
@@ -118,6 +223,68 @@ void PNGShape::generatePoints(int num_points, float screen_width, float screen_h
|
||||
center_offset_y_ = image_height_ * 0.5f;
|
||||
}
|
||||
|
||||
// Extraer filas alternas de puntos (FUNCIÓN PURA: no modifica parámetros)
|
||||
// Recibe vector original y devuelve nuevo vector filtrado
|
||||
std::vector<PNGShape::Point2D> PNGShape::extractAlternateRows(const std::vector<Point2D>& source, int row_skip) {
|
||||
std::vector<Point2D> result;
|
||||
|
||||
if (row_skip <= 1 || source.empty()) {
|
||||
return source; // Sin filtrado, devolver copia del original
|
||||
}
|
||||
|
||||
// Organizar puntos por fila (Y)
|
||||
std::map<int, std::vector<Point2D>> rows;
|
||||
for (const auto& p : source) {
|
||||
int row = static_cast<int>(p.y);
|
||||
rows[row].push_back(p);
|
||||
}
|
||||
|
||||
// Tomar solo cada N filas
|
||||
int row_counter = 0;
|
||||
for (const auto& [row_y, row_points] : rows) {
|
||||
if (row_counter % row_skip == 0) {
|
||||
result.insert(result.end(), row_points.begin(), row_points.end());
|
||||
}
|
||||
row_counter++;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Extraer vértices y esquinas (FUNCIÓN PURA: devuelve nuevo vector)
|
||||
std::vector<PNGShape::Point2D> PNGShape::extractCornerVertices(const std::vector<Point2D>& source) {
|
||||
std::vector<Point2D> result;
|
||||
|
||||
if (source.empty()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Estrategia simple: tomar bordes extremos de cada fila
|
||||
// Esto da el "esqueleto" mínimo de las letras
|
||||
|
||||
std::map<int, std::pair<float, float>> row_extremes; // Y -> (min_x, max_x)
|
||||
|
||||
for (const auto& p : source) {
|
||||
int row = static_cast<int>(p.y);
|
||||
if (row_extremes.find(row) == row_extremes.end()) {
|
||||
row_extremes[row] = {p.x, p.x};
|
||||
} else {
|
||||
row_extremes[row].first = std::min(row_extremes[row].first, p.x);
|
||||
row_extremes[row].second = std::max(row_extremes[row].second, p.x);
|
||||
}
|
||||
}
|
||||
|
||||
// Generar puntos en extremos de cada fila
|
||||
for (const auto& [row_y, extremes] : row_extremes) {
|
||||
result.push_back({extremes.first, static_cast<float>(row_y)}); // Extremo izquierdo
|
||||
if (extremes.second != extremes.first) { // Solo añadir derecho si es diferente
|
||||
result.push_back({extremes.second, static_cast<float>(row_y)}); // Extremo derecho
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void PNGShape::update(float delta_time, float screen_width, float screen_height) {
|
||||
if (!is_flipping_) {
|
||||
// Estado IDLE: texto de frente
|
||||
@@ -159,8 +326,8 @@ void PNGShape::update(float delta_time, float screen_width, float screen_height)
|
||||
}
|
||||
|
||||
void PNGShape::getPoint3D(int index, float& x, float& y, float& z) const {
|
||||
// Seleccionar puntos según configuración
|
||||
const std::vector<Point2D>& points = PNG_USE_EDGES_ONLY ? edge_points_ : filled_points_;
|
||||
// Usar SIEMPRE el vector optimizado (resultado final de generatePoints)
|
||||
const std::vector<Point2D>& points = optimized_points_;
|
||||
|
||||
if (points.empty()) {
|
||||
x = y = z = 0.0f;
|
||||
|
||||
@@ -17,8 +17,9 @@ private:
|
||||
struct Point2D {
|
||||
float x, y;
|
||||
};
|
||||
std::vector<Point2D> edge_points_; // Contorno (solo bordes)
|
||||
std::vector<Point2D> filled_points_; // Relleno completo (para Enfoque B)
|
||||
std::vector<Point2D> edge_points_; // Contorno (solo bordes) - ORIGINAL sin optimizar
|
||||
std::vector<Point2D> filled_points_; // Relleno completo - ORIGINAL sin optimizar
|
||||
std::vector<Point2D> optimized_points_; // Puntos finales optimizados (usado por getPoint3D)
|
||||
|
||||
// Parámetros de extrusión
|
||||
float extrusion_depth_ = 0.0f; // Profundidad de extrusión en Z
|
||||
@@ -46,6 +47,10 @@ private:
|
||||
void floodFill(); // Rellenar interior (Enfoque B - futuro)
|
||||
void generateExtrudedPoints(); // Generar puntos con extrusión 2D
|
||||
|
||||
// Métodos de distribución adaptativa (funciones puras, no modifican parámetros)
|
||||
std::vector<Point2D> extractAlternateRows(const std::vector<Point2D>& source, int row_skip); // Extraer filas alternas
|
||||
std::vector<Point2D> extractCornerVertices(const std::vector<Point2D>& source); // Extraer vértices/esquinas
|
||||
|
||||
public:
|
||||
// Constructor: recibe path relativo al PNG
|
||||
PNGShape(const char* png_path = "data/shapes/jailgames.png");
|
||||
|
||||
Reference in New Issue
Block a user