- 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>
38 lines
1.6 KiB
C++
38 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include "shape.h"
|
|
#include <vector>
|
|
|
|
// Figura: Cubo 3D rotante
|
|
// Distribución:
|
|
// - 1-8 pelotas: Solo vértices (8 puntos)
|
|
// - 9-26 pelotas: Vértices + centros de caras + centros de aristas (26 puntos)
|
|
// - 27+ pelotas: Grid volumétrico 3D uniforme
|
|
// Comportamiento: Rotación simultánea en ejes X, Y, Z (efecto Rubik)
|
|
class CubeShape : public Shape {
|
|
private:
|
|
float angle_x_ = 0.0f; // Ángulo de rotación en eje X (rad)
|
|
float angle_y_ = 0.0f; // Ángulo de rotación en eje Y (rad)
|
|
float angle_z_ = 0.0f; // Ángulo de rotación en eje Z (rad)
|
|
float size_ = 0.0f; // Mitad del lado del cubo (píxeles)
|
|
int num_points_ = 0; // Cantidad de puntos generados
|
|
|
|
// Posiciones base 3D (sin rotar) - se calculan en generatePoints()
|
|
std::vector<float> base_x_;
|
|
std::vector<float> base_y_;
|
|
std::vector<float> base_z_;
|
|
|
|
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 "CUBE"; }
|
|
float getScaleFactor(float screen_height) const override;
|
|
|
|
private:
|
|
// Métodos auxiliares para distribución de puntos
|
|
void generateVertices(); // 8 vértices
|
|
void generateVerticesAndCenters(); // 26 puntos (vértices + caras + aristas)
|
|
void generateVolumetricGrid(); // Grid 3D para muchas pelotas
|
|
};
|