Neue Töne, Reiter mit Anleitung, Klingen geeicht, Sprung, Vorschaubilder aus 3D

Stand von main 262a2009.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 18:43:05 +01:00
parent cdf0707b26
commit a08764c505
27 changed files with 454 additions and 26 deletions

View File

@@ -127,12 +127,13 @@ namespace GladiatorIdle.Gfx
public Clip? Find(string name) => Clips.Find(c => c.Name == name);
/// Teamfarbe (Index in Appearance.Colors), -1 = Originalfarben.
/// Hautton dunkler (0 = unverändert, 1 = dunkle Haut): für Aussehen-Vorlagen mit dunkler Haut, solange
/// Hautton dunkler (0 = unverändert, 1 = dunkle Haut, −1 = helle, blasse Haut): für Aussehen-Vorlagen mit dunkler Haut, solange
/// sie das Modell einer anderen Vorlage nutzen. Haut erkannt an Farbton (Orange/Rosa), mittlerer
/// Sättigung und Helligkeit — Leder ist dunkler, Metall ungesättigt, Teamfarbe magenta.
public void SetSkin(float dark)
{
if (_texture == null || dark <= 0) return;
if (_texture == null || dark == 0) return;
bool pale = dark < 0; dark = MathF.Abs(dark); // negativ: hellere, blassere Haut
var data = new Color[_texture.Width * _texture.Height];
_texture.GetData(data);
for (int i = 0; i < data.Length; i++)
@@ -148,7 +149,8 @@ namespace GladiatorIdle.Gfx
float w = wh * ws * wv * dark;
if (w <= 0) continue;
// dunkle, warme Haut: Helligkeit stark senken, Sättigung leicht anheben
float nv = max * (1 - 0.58f * w), ns = MathF.Min(1, sat * (1 + 0.25f * w));
float nv = pale ? MathF.Min(1, max * (1 + 0.16f * w)) : max * (1 - 0.58f * w);
float ns = pale ? sat * (1 - 0.35f * w) : MathF.Min(1, sat * (1 + 0.25f * w));
float k = nv / max;
float nr = r * k, ng = g * k, nb = b * k;
float gray = (nr + ng + nb) / 3, boost = ns / MathF.Max(sat, 1e-3f);
@@ -390,8 +392,57 @@ namespace GladiatorIdle.Gfx
{
if (art.Contains("retiarius")) { AddTrident(); AddNet(); }
else { AddSword(); AddShield(); }
AimBlades();
}
/// Klinge zum Gegner: im Treffermoment des Schlags soll die Waffe so zum Unterarm liegen wie bei den
/// Figuren mit sauberem Skelett. Bei manchen Skeletten ist die Hand nach dem Übertragen der
/// Bewegungen anders gedreht (Klinge nach hinten oder schräg) – dann wird die Waffe für diese Figur
/// einmal so gedreht, dass sie dort liegt, und bleibt in dieser Lage fest an der Hand.
void AimBlades()
{
var clip = Find("slash") ?? (Clips.Count > 0 ? Clips[0] : null);
if (clip == null) return;
float t = ImpactTime(clip);
var keep = (float[])_pose.Clone(); bool posed = _posed;
_posed = true;
Pose(clip, t, false, 1, true, skin: false);
foreach (var p in Props)
{
if (p.Shield || p.NoAvoid) continue;
var m = p.Local * _global[p.Bone];
var dir = Vector3.Normalize(new Vector3(m.M11, m.M12, m.M13));
var (fa, fu, fs) = ArmFrame(p.Bone);
BladeLog = $"blade z {dir.Z:0.00} arm {Vector3.Dot(dir, fa):0.000} up {Vector3.Dot(dir, fu):0.000} side {Vector3.Dot(dir, fs):0.000}"; // i18n-ok
// Ziel: Lage wie bei den Figuren mit sauberem Skelett (gemessen an vier Figuren)
var target = Vector3.Normalize(fa * 0.31f + fu * 0.36f + fs * 0.88f);
float cos = MathHelper.Clamp(Vector3.Dot(dir, target), -1, 1);
if (cos < 0.97f)
{
var axis = Vector3.Cross(dir, target);
axis = axis.LengthSquared() > 1e-8f ? Vector3.Normalize(axis) : Vector3.Normalize(new Vector3(m.M21, m.M22, m.M23));
var grip = m.Translation;
var turn = Matrix.CreateTranslation(-grip) * Matrix.CreateFromAxisAngle(axis, MathF.Acos(cos)) * Matrix.CreateTranslation(grip);
p.Local = p.Local * _global[p.Bone] * turn * Matrix.Invert(_global[p.Bone]); // fest zur Hand
BladeLog += $" -> {MathHelper.ToDegrees(MathF.Acos(cos)):0} Grad gedreht"; // i18n-ok
}
}
Array.Copy(keep, _pose, keep.Length); _posed = posed; Bones();
}
/// Rahmen am Arm in der jetzigen Haltung: Unterarm-Richtung, oben (Körper), seitlich.
(Vector3 A, Vector3 U, Vector3 S) ArmFrame(int hand)
{
int fore = _parent[hand], hips = Bone("Hips"), head = Bone("Head");
var a = Vector3.Normalize(_global[hand].Translation - _global[fore].Translation);
var up = _global[head].Translation - _global[hips].Translation;
var u = Vector3.Normalize(up - a * Vector3.Dot(up, a));
return (a, u, Vector3.Cross(a, u));
}
/// Testläufe: wie die Klinge ausgerichtet wurde.
public string BladeLog = "";
/// Griff in der Faust: x vom kleinen Finger zum Zeigefinger (Waffe), y zur Handfläche, Ursprung im Griff.
Matrix Grip(string side)
{