3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll

Stand von main 20cd8ba2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 13:24:20 +01:00
parent a08764c505
commit e29db47b20
44 changed files with 2089 additions and 991 deletions

View File

@@ -169,12 +169,58 @@ namespace GladiatorIdle.Arena
* Matrix.CreateTranslation(X + _off * Facing * 0.35f * Stage.Scale, Stage.FloorY - _lift, 0);
}
/// Perspektive der Duell-Kulisse (sonst wie bisher orthografisch über die 2D-Ansicht).
Matrix? _view3, _proj3;
public void UseCamera3D(Matrix view3, Matrix proj3) { _view3 = view3; _proj3 = proj3; }
/// Licht der Arena übernehmen (Sonne, Umgebung, kühles Gegenlicht für die Kontur).
public void SetLighting(ArenaLook look)
{
if (_mfx == null) return;
_mfx.AmbientLightColor = look.Ambient * 0.95f + new Vector3(0.04f);
_mfx.DirectionalLight0.Direction = Vector3.Normalize(look.SunDir);
_mfx.DirectionalLight0.DiffuseColor = look.Sun;
_mfx.DirectionalLight1.Direction = Vector3.Normalize(new Vector3(-look.SunDir.X, 0.1f, 0.8f));
_mfx.DirectionalLight1.DiffuseColor = Vector3.Lerp(new Vector3(0.22f, 0.27f, 0.36f), look.Fog * 0.4f, 0.4f);
_mfx.FogEnabled = false;
}
// Schatten: Stencil, damit sich überlappende Teile nicht doppelt abdunkeln
static readonly DepthStencilState ShadowStencil = new()
{
DepthBufferEnable = true, DepthBufferWriteEnable = false,
StencilEnable = true, StencilFunction = CompareFunction.Equal, ReferenceStencil = 0,
StencilPass = StencilOperation.Increment, StencilFail = StencilOperation.Keep, StencilDepthBufferFail = StencilOperation.Keep,
};
/// Figur flach auf den Sand geworfen (Richtung der Sonne), halbdurchsichtig dunkel.
public void DrawCastShadow(GraphicsDevice gd, Vector3 sunDir, float strength)
{
if (_model == null || _mfx == null || _view3 == null) return;
var fx = _mfx;
fx.View = _view3.Value; fx.Projection = _proj3!.Value;
// Licht fällt flach: Schatten nicht endlos lang
var dir = Vector3.Normalize(new Vector3(sunDir.X, MathF.Max(0.45f, sunDir.Y), sunDir.Z));
var shadow = Matrix.CreateShadow(-dir, new Plane(new Vector3(0, -1, 0), Stage.FloorY - 1));
fx.World = ModelWorld(0) * shadow;
fx.LightingEnabled = false;
fx.DiffuseColor = Vector3.Zero;
fx.EmissiveColor = Vector3.Zero;
fx.Alpha = strength;
_model.Draw(gd, fx, depth: ShadowStencil, blend: BlendState.AlphaBlend);
fx.Alpha = 1;
fx.LightingEnabled = true;
fx.DiffuseColor = Vector3.One;
gd.DepthStencilState = DepthStencilState.None;
gd.BlendState = BlendState.AlphaBlend;
}
void DrawModel(GraphicsDevice gd, BasicEffect scene, Color aura, float grow)
{
var fx = _mfx!;
var vp = gd.Viewport;
fx.View = scene.View;
fx.Projection = Matrix.CreateOrthographicOffCenter(0, vp.Width, vp.Height, 0, -100000, 100000);
fx.View = _view3 ?? scene.View;
fx.Projection = _proj3 ?? Matrix.CreateOrthographicOffCenter(0, vp.Width, vp.Height, 0, -100000, 100000);
fx.World = ModelWorld(grow);
if (aura.A > 0)
{