Implementar pivoteo sutil en PNG_SHAPE y eliminar debug output

Cambios:

1. **PNG_SHAPE pivoteo sutil** (similar a WAVE_GRID):
   - Añadidas variables tilt_x_ y tilt_y_ en png_shape.h
   - Actualización continua de tilt en update()
   - Aplicación de pivoteo en getPoint3D() con:
     * Cálculo correcto de logo_size para normalización
     * Normalización a rango [-1, 1] usando logo_size * 0.5
     * Amplitudes 0.15 y 0.1 (matching WAVE_GRID)
     * z_tilt proporcional al tamaño del logo
   - Fix crítico: usar z_base en lugar de z fijo (línea 390)

2. **Eliminación de debug output**:
   - Removidos 13 std::cout de png_shape.cpp
   - Removidos 2 std::cout de engine.cpp (Logo Mode)
   - Consola ahora limpia sin mensajes [PNG_SHAPE]

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-04 23:59:45 +02:00
parent be099c198c
commit 4f900eaa57
3 changed files with 30 additions and 31 deletions

View File

@@ -1798,8 +1798,6 @@ void Engine::enterLogoMode(bool from_demo) {
demo_timer_ = 0.0f; demo_timer_ = 0.0f;
demo_next_action_time_ = LOGO_ACTION_INTERVAL_MIN + demo_next_action_time_ = LOGO_ACTION_INTERVAL_MIN +
(rand() % 1000) / 1000.0f * (LOGO_ACTION_INTERVAL_MAX - LOGO_ACTION_INTERVAL_MIN); (rand() % 1000) / 1000.0f * (LOGO_ACTION_INTERVAL_MAX - LOGO_ACTION_INTERVAL_MIN);
std::cout << "[LOGO MODE] Activado" << (from_demo ? " (desde DEMO)" : " (manual)") << "\n";
} }
// Salir del Modo Logo (volver a estado anterior o salir de DEMO) // Salir del Modo Logo (volver a estado anterior o salir de DEMO)
@@ -1843,8 +1841,6 @@ void Engine::exitLogoMode(bool return_to_demo) {
((demo_lite_enabled_ ? DEMO_LITE_ACTION_INTERVAL_MAX : DEMO_ACTION_INTERVAL_MAX) - ((demo_lite_enabled_ ? DEMO_LITE_ACTION_INTERVAL_MAX : DEMO_ACTION_INTERVAL_MAX) -
(demo_lite_enabled_ ? DEMO_LITE_ACTION_INTERVAL_MIN : DEMO_ACTION_INTERVAL_MIN)); (demo_lite_enabled_ ? DEMO_LITE_ACTION_INTERVAL_MIN : DEMO_ACTION_INTERVAL_MIN));
} }
std::cout << "[LOGO MODE] Desactivado" << (return_to_demo ? " (volviendo a DEMO)" : " (salida manual)") << "\n";
} }
// Toggle manual del Modo Logo (tecla K) // Toggle manual del Modo Logo (tecla K)

View File

@@ -130,18 +130,11 @@ void PNGShape::generatePoints(int num_points, float screen_width, float screen_h
num_2d_points = active_points_data.size(); num_2d_points = active_points_data.size();
total_3d_points = num_2d_points * num_layers_; 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) // 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 // Objetivo: Llenar bien el texto en 2D antes de reducir píxeles
while (num_layers_ > 1 && num_points < static_cast<int>(total_3d_points)) { while (num_layers_ > 1 && num_points < static_cast<int>(total_3d_points)) {
num_layers_ = std::max(1, num_layers_ / 2); num_layers_ = std::max(1, num_layers_ / 2);
total_3d_points = num_2d_points * num_layers_; 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) // NIVEL 3: Filas alternas en RELLENO (solo si 1 capa no alcanza)
@@ -154,8 +147,6 @@ void PNGShape::generatePoints(int num_points, float screen_width, float screen_h
active_points_data = extractAlternateRows(filled_points_original, row_skip); active_points_data = extractAlternateRows(filled_points_original, row_skip);
num_2d_points = active_points_data.size(); num_2d_points = active_points_data.size();
total_3d_points = num_2d_points * num_layers_; 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); mode_name = "RELLENO + FILAS/" + std::to_string(row_skip);
} }
} }
@@ -167,8 +158,6 @@ void PNGShape::generatePoints(int num_points, float screen_width, float screen_h
num_2d_points = active_points_data.size(); num_2d_points = active_points_data.size();
total_3d_points = num_2d_points * num_layers_; total_3d_points = num_2d_points * num_layers_;
row_skip = 1; // Reset row_skip para bordes 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) // NIVEL 5: Filas alternas en BORDES (si aún no alcanza)
@@ -178,8 +167,6 @@ void PNGShape::generatePoints(int num_points, float screen_width, float screen_h
active_points_data = extractAlternateRows(edge_points_original, row_skip); active_points_data = extractAlternateRows(edge_points_original, row_skip);
num_2d_points = active_points_data.size(); num_2d_points = active_points_data.size();
total_3d_points = num_2d_points * num_layers_; 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) { if (mode_name.find("FILAS") == std::string::npos) {
mode_name += " + FILAS/" + std::to_string(row_skip); mode_name += " + FILAS/" + std::to_string(row_skip);
} }
@@ -198,22 +185,12 @@ void PNGShape::generatePoints(int num_points, float screen_width, float screen_h
num_2d_points = active_points_data.size(); num_2d_points = active_points_data.size();
total_3d_points = num_2d_points * num_layers_; total_3d_points = num_2d_points * num_layers_;
mode_name = "VÉRTICES"; 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) // ✅ CLAVE: Guardar el conjunto de puntos optimizado final en optimized_points_ (usado por getPoint3D)
optimized_points_ = active_points_data; 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";
// Calcular escala para centrar la imagen en pantalla // Calcular escala para centrar la imagen en pantalla
float max_dimension = std::max(static_cast<float>(image_width_), static_cast<float>(image_height_)); float max_dimension = std::max(static_cast<float>(image_width_), static_cast<float>(image_height_));
scale_factor_ = (screen_height * PNG_SIZE_FACTOR) / max_dimension; scale_factor_ = (screen_height * PNG_SIZE_FACTOR) / max_dimension;
@@ -287,9 +264,13 @@ 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 // Estado IDLE: texto de frente con pivoteo sutil (como WAVE_GRID)
idle_timer_ += delta_time; idle_timer_ += delta_time;
// Pivoteo sutil constante (movimiento orgánico)
tilt_x_ += 0.4f * delta_time; // Velocidad sutil en X
tilt_y_ += 0.6f * delta_time; // Velocidad sutil en Y
if (idle_timer_ >= next_idle_time_) { if (idle_timer_ >= next_idle_time_) {
// Iniciar voltereta // Iniciar voltereta
is_flipping_ = true; is_flipping_ = true;
@@ -355,6 +336,24 @@ 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)
// Calcular tamaño del logo en pantalla para normalizar correctamente
float logo_width = image_width_ * scale_factor_;
float logo_height = image_height_ * scale_factor_;
float logo_size = std::max(logo_width, logo_height);
// Normalizar coordenadas a rango [-1, 1]
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
// Aplicar pivoteo proporcional al tamaño del logo
float z_tilt = (u * tilt_amount_y + v * tilt_amount_x) * logo_size;
z_base += z_tilt; // Añadir pivoteo sutil a la profundidad
// Aplicar rotación en eje Y (horizontal) // Aplicar rotación en eje Y (horizontal)
float cos_y = cosf(angle_y_); float cos_y = cosf(angle_y_);
float sin_y = sinf(angle_y_); float sin_y = sinf(angle_y_);
@@ -371,10 +370,10 @@ void PNGShape::getPoint3D(int index, float& x, float& y, float& z) const {
x = x_rot_y; x = x_rot_y;
y = y_rot; y = y_rot;
// Cuando está de frente (sin rotación), forzar Z positivo (primer plano brillante) // Cuando está de frente (sin rotación), usar Z con pivoteo sutil
if (angle_x_ == 0.0f && angle_y_ == 0.0f) { if (angle_x_ == 0.0f && angle_y_ == 0.0f) {
// De frente: todo en primer plano (Z máximo) // De frente: usar z_base que incluye el pivoteo sutil
z = extrusion_depth_ * 0.5f; // Máximo Z = más brillante z = z_base;
} else { } else {
z = z_rot; z = z_rot;
} }

View File

@@ -34,6 +34,10 @@ 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)
float tilt_x_ = 0.0f; // Oscilación sutil en eje X
float tilt_y_ = 0.0f; // Oscilación sutil en eje Y
// Dimensiones normalizadas // Dimensiones normalizadas
float scale_factor_ = 1.0f; float scale_factor_ = 1.0f;
float center_offset_x_ = 0.0f; float center_offset_x_ = 0.0f;