Files
orni-attack/source/core/rendering/shape_renderer.hpp
T
JailDesigner 6d7060ceb5 Fase 8a+b: paleta semantica de color por entidad
Cada entity declara su color de linea via parametro opcional. Cuando
alpha==0 el pipeline cae al color global del oscilador (compatibilidad
con el comportamiento anterior).

Defaults::Palette (defaults.hpp):
- SHIP        = blanco neutro
- BULLET      = verde laser
- PENTAGON    = azul "esquivador"
- QUADRAT     = rojo "tank"
- MOLINILLO   = magenta agresivo

Pipeline:
- linea(): parametro SDL_Color color (default {0,0,0,0}). En .cpp,
  fuente del color = color.a>0 ? color : g_current_line_color.
- render_shape(): parametro SDL_Color color que propaga a cada linea
  del shape.
- Debris: campo color en la struct; explode() recibe SDL_Color color
  y lo guarda en cada fragment; draw() lo pasa a linea().

Aplicacion:
- Ship::draw -> Palette::SHIP.
- Bullet::draw -> Palette::BULLET.
- Enemy::draw -> Palette::{PENTAGON,QUADRAT,MOLINILLO} segun type_.
- CollisionSystem detectBulletEnemy: debris hereda color del enemy.
- GameScene::tocado: debris hereda Palette::SHIP.

Smoke test xvfb OK.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-20 08:04:56 +02:00

56 lines
1.7 KiB
C++

// shape_renderer.hpp - Renderizado de formes vectorials
// © 2025 Port a C++20 con SDL3
#pragma once
#include "core/rendering/render_context.hpp"
#include <SDL3/SDL.h>
#include <memory>
#include "core/graphics/shape.hpp"
#include "core/types.hpp"
namespace Rendering {
// Estructura per rotacions 3D (pitch, yaw, roll)
struct Rotation3D {
float pitch; // Rotación eix X (cabeceo arriba/baix)
float yaw; // Rotación eix Y (guiñada izquierda/derecha)
float roll; // Rotación eix Z (alabeo lateral)
Rotation3D()
: pitch(0.0F),
yaw(0.0F),
roll(0.0F) {}
Rotation3D(float p, float y, float r)
: pitch(p),
yaw(y),
roll(r) {}
[[nodiscard]] bool has_rotation() const {
return pitch != 0.0F || yaw != 0.0F || roll != 0.0F;
}
};
// Renderizar shape con transformacions
// - renderer: SDL renderer
// - shape: shape vectorial a draw
// - position: posición del centro en coordenades mundials
// - angle: rotación en radians (0 = amunt, sentit horari)
// - scale: factor de scale (1.0 = mida original)
// - progress: progrés de l'animación (0.0-1.0, default 1.0 = tot visible)
// - brightness: factor de brightness (0.0-1.0, default 1.0 = màxima brightness)
void render_shape(Rendering::Renderer* renderer,
const std::shared_ptr<Graphics::Shape>& shape,
const Vec2& position,
float angle,
float scale = 1.0F,
float progress = 1.0F,
float brightness = 1.0F,
const Rotation3D* rotation_3d = nullptr,
SDL_Color color = {0, 0, 0, 0}); // alpha==0 → usa global oscilador
} // namespace Rendering