champions-of-luneraria/Assets/Luneraria/View/LuneGround.cs
Martin Stickelbroeck 8a72cb165a U2B World Geometry
G1-Karte in Unity (Assets/Luneraria/Scenes/G1_Map.unity), reproduzierbar
gebaut aus dem Godot-Weltgenerator (gebacken), den FBX-Modellen aus U2A und der
Karte des C#-Kerns.

- tools/godot-golden/world_export.gd: backt Gelände (Raster, Farben, Lauf- und
  Standhöhen), Lanebeläge, Plattform, Brücke, Randsteine, Basen, Landmarken,
  Vegetation, Adern, Grottentreppen, Aufstellungsbereiche und Licht. Braucht
  einen echten Renderer (HEADLESS=0); prüft auf Headless-Einheitstransformationen.
- LuneWorldBuilder: Meshes (GUID-stabil), Szene, Licht, Himmel, Post-Processing,
  16 Türme, 2 Ancients und die Grotte aus LuneMap mit Teammaterialien.
- Materialsystem: Luneraria/Surface (Gelände, Kluft-Oberflächen, Fluss, Adern,
  Kristall, G2-Werte mit Teamvarianten und Vertex-AO) und Luneraria/Pad;
  LuneMaterialSet.Dress wie Godots dress.
- View-Assembly: LuneSpace (Unity = (-x, h, y)), LuneGround, LuneCameraMath,
  LuneBuildingView (Zustände intakt bis Ruine).
- Vergleichsbilder mit den Kameraeinstellungen der Godot-G2-Aufnahmen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 16:01:25 +02:00

51 lines
2 KiB
C#

using Luneraria.Core;
using UnityEngine;
namespace Luneraria.View
{
/// <summary>
/// Heights of the G1 world for placing figures and buildings (presentation only; the rules are
/// flat). Baked from the Godot reference by tools/godot-golden/world_export.gd:
/// the terrain walk height (1 m grid, lane decks instead of the river bed) and the height a
/// figure stands on including plaza, dais steps and grotto terrace (0.5 m grid).
/// </summary>
public sealed class LuneGround : ScriptableObject
{
public float WalkExtent;
public float WalkStep;
public int WalkSize;
public float[] Walk;
public float StandExtent;
public float StandStep;
public int StandSize;
public float[] Stand;
/// <summary>LuneTerrain.walk_height: lane decks, ford and platform instead of the river bed.</summary>
public float WalkHeight(Vec2 map)
{
return Bilinear(Walk, WalkSize, WalkExtent, WalkStep, map);
}
/// <summary>LuneWorld.height_at: walk height plus plaza, dais and grotto lifts.</summary>
public float StandHeight(Vec2 map)
{
return Bilinear(Stand, StandSize, StandExtent, StandStep, map);
}
// Godot LuneTerrain._bilinear, in map coordinates.
static float Bilinear(float[] field, int size, float extent, float step, Vec2 p)
{
if (field == null || field.Length == 0)
return 0f;
float fx = Mathf.Clamp((p.X + extent) / step, 0f, size - 1.001f);
float fz = Mathf.Clamp((p.Y + extent) / step, 0f, size - 1.001f);
int i = (int)fx;
int j = (int)fz;
float tx = fx - i;
float tz = fz - j;
float a = Mathf.Lerp(field[j * size + i], field[j * size + i + 1], tx);
float b = Mathf.Lerp(field[(j + 1) * size + i], field[(j + 1) * size + i + 1], tx);
return Mathf.Lerp(a, b, tz);
}
}
}