Implementar sistema polimórfico de figuras 3D (Sphere + Cube)

- Crear interfaz abstracta Shape con métodos virtuales
- Refactorizar RotoBall → SphereShape (clase polimórfica)
- Implementar CubeShape con triple rotación (X/Y/Z)
- Distribución inteligente en cubo: vértices/centros/grid 3D
- Cambiar controles: F=toggle, Q/W/E/R/T/Y/U/I=figuras, B=temas
- Actualizar SimulationMode: ROTOBALL → SHAPE
- Añadir enum ShapeType (8 figuras: Sphere/Cube/Helix/Torus/etc.)
- Incluir source/shapes/*.cpp en CMakeLists.txt
- Física compartida escalable entre todas las figuras
- Roadmap: 6 figuras pendientes (Helix/Torus/Wave/Cylinder/Icosahedron/Atom)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-03 20:20:10 +02:00
parent b196683e4a
commit a7ec764ebc
9 changed files with 484 additions and 137 deletions

View File

@@ -10,9 +10,10 @@
#include <string> // for string
#include <vector> // for vector
#include "defines.h" // for GravityDirection, ColorTheme
#include "defines.h" // for GravityDirection, ColorTheme, ShapeType
#include "ball.h" // for Ball
#include "external/texture.h" // for Texture
#include "shapes/shape.h" // for Shape (interfaz polimórfica)
class Engine {
public:
@@ -80,15 +81,11 @@ private:
// Temas de colores definidos
ThemeColors themes_[5];
// Sistema RotoBall (esfera 3D rotante)
// Sistema de Figuras 3D (polimórfico)
SimulationMode current_mode_ = SimulationMode::PHYSICS;
struct RotoBallData {
float angle_y = 0.0f; // Ángulo de rotación en eje Y
float angle_x = 0.0f; // Ángulo de rotación en eje X
float transition_progress = 0.0f; // Progreso de transición (0.0-1.0)
bool transitioning = false; // ¿Está en transición?
};
RotoBallData rotoball_;
ShapeType current_shape_type_ = ShapeType::SPHERE; // Tipo de figura actual
ShapeType last_shape_type_ = ShapeType::SPHERE; // Última figura para toggle F
std::unique_ptr<Shape> active_shape_; // Puntero polimórfico a figura activa
// Batch rendering
std::vector<SDL_Vertex> batch_vertices_;
@@ -127,8 +124,9 @@ private:
void renderGradientBackground();
void addSpriteToBatch(float x, float y, float w, float h, int r, int g, int b);
// Sistema RotoBall
void toggleRotoBallMode(bool force_gravity_on_exit = true);
void generateRotoBallSphere();
void updateRotoBall();
};
// Sistema de Figuras 3D
void toggleShapeMode(bool force_gravity_on_exit = true); // Toggle PHYSICS ↔ última figura (tecla F)
void activateShape(ShapeType type); // Activar figura específica (teclas Q/W/E/R/Y/U/I)
void updateShape(); // Actualizar figura activa
void generateShape(); // Generar puntos de figura activa
};