fix(title-3d): naus rotades cap al VP, alçada mínima, eix X de càmera corregit

This commit is contained in:
2026-05-22 09:11:26 +02:00
parent b654fd0428
commit e533387ce5
2 changed files with 13 additions and 6 deletions
+6 -4
View File
@@ -49,10 +49,12 @@ namespace Graphics {
void Camera3D::recomputeBasis() {
// Forward = del position cap al target.
forward_ = (target_ - position_).normalized();
// Right = forward × up_world. Cau a (1,0,0) si forward ≈ up_world.
right_ = forward_.cross(up_world_).normalized();
// Up real ortogonal = right × forward.
up_ = right_.cross(forward_).normalized();
// Right = up_world × forward (convenció right-handed amb Y up,
// mirant cap a +Z → right cau a +X). L'invers (forward × up_world)
// donava la base mirall i invertia l'eix X de la projecció.
right_ = up_world_.cross(forward_).normalized();
// Up ortogonal real = forward × right (manté la mà dreta).
up_ = forward_.cross(right_).normalized();
}
void Camera3D::recomputeFocal() {
+7 -2
View File
@@ -15,7 +15,12 @@ namespace Title {
namespace {
// Profunditat d'extrusió de la silueta 2D de la nau (en unitats mundials).
constexpr float SHIP_EXTRUSION_DEPTH = 8.0F;
// Mantenir-la xicoteta: l'usuari vol naus "casi 2D" amb alçada mínima.
constexpr float SHIP_EXTRUSION_DEPTH = 1.5F;
// Rotació pitch que aplica el draw() per orientar la silueta cap al punt
// de fuga: el Y2D negatiu del shape (la punta) passa a +Z mundial.
constexpr float SHIP_PITCH_RAD = -1.5707963F; // -π/2
// Posicions en l'espai 3D (càmera a (0,0,0) mirant cap a +Z, Y cap amunt).
constexpr float SHIP_FLOAT_X = 20.0F; // Separació horitzontal
@@ -102,7 +107,7 @@ namespace Title {
}
const Graphics::Transform3D TRANSFORM{
.position = ship.current_position,
.rotation_euler = Vec3{},
.rotation_euler = Vec3{.x = SHIP_PITCH_RAD, .y = 0.0F, .z = 0.0F},
.scale = ship.current_scale,
};
Graphics::drawWireframe(renderer_, *camera_, ship.mesh, TRANSFORM, 1.0F);