Bestenliste, Expeditionen, Ereignisse, Dreizack und Netz, aufrechte Schilde, dunkle Haut
Stand von main 82292b5c. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -54,7 +54,7 @@ namespace GladiatorIdle.Gfx
|
||||
public readonly List<Clip> Clips = new();
|
||||
public readonly VertexPNCT[] Vertices;
|
||||
public BoundingBox Bounds { get; }
|
||||
readonly Texture2D? _texture;
|
||||
Texture2D? _texture;
|
||||
Texture2D? _painted;
|
||||
/// Maßstab: Modell-Einheiten je Zentimeter (Mixamo-Figuren gibt es in cm und in m).
|
||||
public readonly float Unit;
|
||||
@@ -127,6 +127,44 @@ 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
|
||||
/// 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;
|
||||
var data = new Color[_texture.Width * _texture.Height];
|
||||
_texture.GetData(data);
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
var c = data[i];
|
||||
float r = c.R / 255f, g = c.G / 255f, b = c.B / 255f;
|
||||
float max = MathF.Max(r, MathF.Max(g, b)), min = MathF.Min(r, MathF.Min(g, b)), d = max - min;
|
||||
if (max < 0.38f || d < 0.04f) continue;
|
||||
float sat = d / max;
|
||||
float h = max == r ? 60 * (((g - b) / d) % 6) : max == g ? 60 * ((b - r) / d + 2) : 60 * ((r - g) / d + 4);
|
||||
if (h < 0) h += 360;
|
||||
float wh = Band(h, 2, 10, 34, 46), ws = Band(sat, 0.12f, 0.2f, 0.62f, 0.75f), wv = Band(max, 0.38f, 0.48f, 1.1f, 1.2f);
|
||||
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 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);
|
||||
nr = gray + (nr - gray) * boost; ng = gray + (ng - gray) * boost; nb = gray + (nb - gray) * boost;
|
||||
data[i] = new Color(Math.Clamp(nr, 0, 1), Math.Clamp(ng, 0, 1), Math.Clamp(nb, 0, 1), c.A / 255f);
|
||||
}
|
||||
var t = new Texture2D(_texture.GraphicsDevice, _texture.Width, _texture.Height);
|
||||
t.SetData(data);
|
||||
_texture = t;
|
||||
_color = -2; // Teamfarbe neu auf die geänderte Textur
|
||||
}
|
||||
|
||||
/// 0 unterhalb a, 1 zwischen b und c, 0 oberhalb d, linear dazwischen.
|
||||
static float Band(float x, float a, float b, float c, float d) =>
|
||||
x <= a || x >= d ? 0 : x < b ? (x - a) / (b - a) : x > c ? (d - x) / (d - c) : 1;
|
||||
|
||||
public void SetColor(int index)
|
||||
{
|
||||
if (index == _color) return;
|
||||
@@ -279,7 +317,7 @@ namespace GladiatorIdle.Gfx
|
||||
var world = fx.World;
|
||||
foreach (var p in Props)
|
||||
{
|
||||
fx.World = p.Local * _global[p.Bone] * p.Correction * world;
|
||||
fx.World = p.World * p.Correction * world;
|
||||
foreach (var pass in fx.CurrentTechnique.Passes)
|
||||
{
|
||||
pass.Apply();
|
||||
@@ -297,6 +335,9 @@ namespace GladiatorIdle.Gfx
|
||||
public bool Shield; public float Height, Width, Bend, Length; // Maße in cm (Schild: Höhe x, Breite y; Klinge: Länge entlang x)
|
||||
public Matrix Correction = Matrix.Identity; // Ausweichen vor dem eigenen Körper (Modell-Raum)
|
||||
public float Push, Angle; public Vector3 Axis = Vector3.Up;
|
||||
public bool NoAvoid; // weicht nicht aus (Netz)
|
||||
public bool Upright; // Schild aufrecht vor der Hand statt an der Handdrehung
|
||||
public Matrix World = Matrix.Identity; // Lage im Modell-Raum (vor dem Ausweichen)
|
||||
public VertexPNC[] V = Array.Empty<VertexPNC>(); public int[] I = Array.Empty<int>(); public Color[] Base = Array.Empty<Color>();
|
||||
}
|
||||
public readonly List<Prop> Props = new();
|
||||
@@ -344,8 +385,15 @@ namespace GladiatorIdle.Gfx
|
||||
return frame * _offset[bone]; // Rahmen · (Knochen in Ruhe)⁻¹
|
||||
}
|
||||
|
||||
/// Gladius in der Faust (Knochen-Präfix "Right"/"Left"). Klinge zeigt vom kleinen Finger zum Zeigefinger.
|
||||
public void AddSword(string side = "Right")
|
||||
/// Ausrüstung nach Figur: Retiarius Dreizack und Netz, sonst Gladius und Scutum.
|
||||
public void Arm(string art)
|
||||
{
|
||||
if (art.Contains("retiarius")) { AddTrident(); AddNet(); }
|
||||
else { AddSword(); AddShield(); }
|
||||
}
|
||||
|
||||
/// Griff in der Faust: x vom kleinen Finger zum Zeigefinger (Waffe), y zur Handfläche, Ursprung im Griff.
|
||||
Matrix Grip(string side)
|
||||
{
|
||||
var h = BindPos(side + "Hand"); var m = BindPos(side + "HandMiddle1");
|
||||
var ix = BindPos(side + "HandIndex1"); var pk = BindPos(side + "HandPinky1"); var th = BindPos(side + "HandThumb1");
|
||||
@@ -354,6 +402,64 @@ namespace GladiatorIdle.Gfx
|
||||
var palm = Vector3.Normalize(Vector3.Cross(finger, blade));
|
||||
if (Vector3.Dot(palm, th - h) < 0) palm = -palm;
|
||||
var grip = h + (m - h) * 0.75f + palm * 2.5f * Unit;
|
||||
return Matrix.CreateScale(Unit) * Attach(Bone(side + "Hand"), blade, palm, grip);
|
||||
}
|
||||
|
||||
/// Dreizack des Retiarius, in der Mitte gefasst: Schaft nach hinten, drei Zinken nach vorn.
|
||||
public void AddTrident(string side = "Right")
|
||||
{
|
||||
var b = new MeshBuilder();
|
||||
var wood = new Color(110, 74, 42); var bronze = new Color(184, 140, 70); var steel = new Color(200, 204, 210);
|
||||
b.Box(new Vector3(15, 0, 0), new Vector3(150, 2.6f, 2.6f), wood); // Schaft (-60 … +90)
|
||||
b.Box(new Vector3(-61, 0, 0), new Vector3(3, 3.6f, 3.6f), bronze); // Endkappe
|
||||
b.Box(new Vector3(91, 0, 0), new Vector3(4, 4, 4), bronze); // Tülle
|
||||
b.Box(new Vector3(95, 0, 0), new Vector3(3, 2, 22), bronze); // Querstück
|
||||
foreach (float z in new[] { -10f, 0f, 10f })
|
||||
{
|
||||
float len = z == 0 ? 32 : 26;
|
||||
b.Box(new Vector3(96 + len / 2, 0, z), new Vector3(len, 1.4f, 1.6f), steel); // Zinke
|
||||
b.Box(new Vector3(96 + len - 2, 0, z + (z >= 0 ? 1.4f : -1.4f)), new Vector3(4, 1.2f, 1.6f), steel); // Widerhaken
|
||||
}
|
||||
var p = b.Build(Bone(side + "Hand"), Grip(side));
|
||||
p.Length = 128;
|
||||
Props.Add(p);
|
||||
}
|
||||
|
||||
/// Wurfnetz des Retiarius: gerafft in der Faust, hängt als Maschenwerk mit Bleigewichten herab.
|
||||
public void AddNet(string side = "Left")
|
||||
{
|
||||
var b = new MeshBuilder();
|
||||
var rope = new Color(176, 152, 104); var lead = new Color(90, 92, 98);
|
||||
const int COLS = 6, ROWS = 8;
|
||||
const float W = 36, H = 58, CORD = 0.9f;
|
||||
Vector3 P(float u, float v)
|
||||
{
|
||||
// vom Griff nach unten (Richtung kleiner Finger = -x), unten breiter, leicht gewellt
|
||||
float spread = 0.35f + 0.65f * v;
|
||||
return new Vector3(-4 - v * H, MathF.Sin(u * 9 + v * 5) * 2.5f * v, (u - 0.5f) * W * spread);
|
||||
}
|
||||
for (int c = 0; c <= COLS; c++) // senkrechte Schnüre
|
||||
for (int r = 0; r < ROWS; r++)
|
||||
{
|
||||
var a = P(c / (float)COLS, r / (float)ROWS); var e = P(c / (float)COLS, (r + 1) / (float)ROWS);
|
||||
b.Box((a + e) / 2, new Vector3(MathF.Abs(e.X - a.X) + CORD, CORD, CORD + MathF.Abs(e.Z - a.Z)), rope);
|
||||
}
|
||||
for (int r = 1; r <= ROWS; r++) // waagerechte Schnüre
|
||||
for (int c = 0; c < COLS; c++)
|
||||
{
|
||||
var a = P(c / (float)COLS, r / (float)ROWS); var e = P((c + 1) / (float)COLS, r / (float)ROWS);
|
||||
b.Box((a + e) / 2, new Vector3(CORD, CORD, MathF.Abs(e.Z - a.Z) + CORD), rope);
|
||||
}
|
||||
for (int c = 0; c <= COLS; c++) b.Box(P(c / (float)COLS, 1) + new Vector3(-1.5f, 0, 0), new Vector3(3, 2.2f, 2.2f), lead); // Bleigewichte
|
||||
b.Box(new Vector3(-2, 0, 0), new Vector3(6, 5, 9), rope); // geraffter Teil in der Faust
|
||||
var p = b.Build(Bone(side + "Hand"), Grip(side));
|
||||
p.NoAvoid = true;
|
||||
Props.Add(p);
|
||||
}
|
||||
|
||||
/// Gladius in der Faust (Knochen-Präfix "Right"/"Left"). Klinge zeigt vom kleinen Finger zum Zeigefinger.
|
||||
public void AddSword(string side = "Right")
|
||||
{
|
||||
var b = new MeshBuilder();
|
||||
var steel = new Color(196, 200, 206); var brass = new Color(176, 136, 62); var wood = new Color(92, 58, 34);
|
||||
b.Box(new Vector3(-9, 0, 0), new Vector3(1.5f, 3.6f, 3.6f), brass); // Knauf
|
||||
@@ -361,7 +467,7 @@ namespace GladiatorIdle.Gfx
|
||||
b.Box(new Vector3(2.2f, 0, 0), new Vector3(1.6f, 4, 11), brass); // Parierstange
|
||||
b.Box(new Vector3(30, 0, 0), new Vector3(54, 0.8f, 5.2f), steel); // Klinge
|
||||
b.Box(new Vector3(60, 0, 0), new Vector3(6, 0.7f, 2.6f), steel); // Spitze
|
||||
var sword = b.Build(Bone(side + "Hand"), Matrix.CreateScale(Unit) * Attach(Bone(side + "Hand"), blade, palm, grip));
|
||||
var sword = b.Build(Bone(side + "Hand"), Grip(side));
|
||||
sword.Length = 63;
|
||||
Props.Add(sword);
|
||||
}
|
||||
@@ -390,6 +496,8 @@ namespace GladiatorIdle.Gfx
|
||||
// y (Breite) = Knöchel × Griff, z (außen) = x × y = Knöchelrichtung
|
||||
var shield = b.Build(Bone(side + "Hand"), Matrix.CreateScale(Unit) * Attach(Bone(side + "Hand"), across, Vector3.Cross(knuckles, across), centre));
|
||||
shield.Shield = true; shield.Height = H; shield.Width = W; shield.Bend = BEND;
|
||||
// Skelett ohne Finger: die Handdrehung passt nach der Übertragung der Bewegungen nicht zuverlässig
|
||||
shield.Upright = Bone(side + "HandMiddle1") < 0;
|
||||
Props.Add(shield);
|
||||
}
|
||||
|
||||
@@ -429,11 +537,12 @@ namespace GladiatorIdle.Gfx
|
||||
{
|
||||
if (Props.Count == 0) return;
|
||||
BuildBody(out float cm);
|
||||
foreach (var p in Props) p.World = p.Upright ? UprightShield(p, cm) : p.Local * _global[p.Bone];
|
||||
if (_body.Count == 0) return;
|
||||
Prop? shield = null;
|
||||
foreach (var p in Props) if (p.Shield) shield = p;
|
||||
if (shield != null) AvoidShield(shield, cm);
|
||||
foreach (var p in Props) if (!p.Shield) AvoidBlade(p, shield, cm);
|
||||
foreach (var p in Props) if (!p.Shield && !p.NoAvoid) AvoidBlade(p, shield, cm);
|
||||
}
|
||||
|
||||
static Vector3 Axis(Matrix m, int row) => row switch
|
||||
@@ -441,10 +550,28 @@ namespace GladiatorIdle.Gfx
|
||||
0 => new Vector3(m.M11, m.M12, m.M13), 1 => new Vector3(m.M21, m.M22, m.M23), _ => new Vector3(m.M31, m.M32, m.M33)
|
||||
};
|
||||
|
||||
/// Schild aufrecht vor der Hand: Hochachse entlang des Oberkörpers, Vorderseite vom Körper zur Hand hin.
|
||||
Matrix UprightShield(Prop s, float cm)
|
||||
{
|
||||
int hand = s.Bone, hips = Bone("Hips"), neck = Bone("Neck"), head = Bone("Head");
|
||||
if (hips < 0 || neck < 0) return s.Local * _global[s.Bone];
|
||||
var h = _global[hand].Translation;
|
||||
var a = _global[hips].Translation; var n = _global[neck].Translation;
|
||||
var up = Vector3.Normalize((head >= 0 ? _global[head].Translation : n) - a);
|
||||
var outV = h - Closest(a, n, h);
|
||||
outV -= up * Vector3.Dot(outV, up);
|
||||
if (outV.LengthSquared() < 1e-6f) outV = Vector3.Cross(up, Vector3.UnitX);
|
||||
outV.Normalize();
|
||||
var y = Vector3.Cross(outV, up); // x (Höhe) = up, z (außen) = outV, z = x × y
|
||||
var c = h + outV * 6 * cm;
|
||||
var frame = new Matrix(up.X, up.Y, up.Z, 0, y.X, y.Y, y.Z, 0, outV.X, outV.Y, outV.Z, 0, c.X, c.Y, c.Z, 1);
|
||||
return Matrix.CreateScale(cm) * frame;
|
||||
}
|
||||
|
||||
/// Schild entlang seiner Außenseite verschieben, bis kein Körperteil von innen hineinragt.
|
||||
void AvoidShield(Prop s, float cm)
|
||||
{
|
||||
var m = s.Local * _global[s.Bone];
|
||||
var m = s.World;
|
||||
var c = m.Translation;
|
||||
float sc = Axis(m, 0).Length(); // Modell-Einheiten je Schild-cm
|
||||
var ax = Vector3.Normalize(Axis(m, 0)); var ay = Vector3.Normalize(Axis(m, 1)); var az = Vector3.Normalize(Axis(m, 2));
|
||||
@@ -469,12 +596,12 @@ namespace GladiatorIdle.Gfx
|
||||
/// Klinge um den Griff wegdrehen, wenn sie Körper oder eigenen Schild schneidet.
|
||||
void AvoidBlade(Prop p, Prop? shield, float cm)
|
||||
{
|
||||
var m = p.Local * _global[p.Bone];
|
||||
var m = p.World;
|
||||
var grip = m.Translation;
|
||||
float sc = Axis(m, 0).Length();
|
||||
var dir = Vector3.Normalize(Axis(m, 0));
|
||||
float len = p.Length * sc, half = 2.5f * cm;
|
||||
var sm = shield != null ? shield.Local * _global[shield.Bone] * shield.Correction : Matrix.Identity;
|
||||
var sm = shield != null ? shield.World * shield.Correction : Matrix.Identity;
|
||||
float ss = Axis(sm, 0).Length();
|
||||
var sx = Vector3.Normalize(Axis(sm, 0)); var sy = Vector3.Normalize(Axis(sm, 1)); var sz = Vector3.Normalize(Axis(sm, 2));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user