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>
51 lines
2.2 KiB
C#
51 lines
2.2 KiB
C#
using UnityEngine;
|
|
|
|
namespace Luneraria.View
|
|
{
|
|
/// <summary>
|
|
/// The game camera of the reference (scripts/luneraria/view/lune_camera.gd): a perspective
|
|
/// three-quarter view whose angle steepens as it zooms out. `zoom` is the visible ground height
|
|
/// at the focus; yaw 0 shows Blau's base bottom-left and Rot's top-right, as in Godot.
|
|
/// Positions are computed in Godot's frame and converted, so the picture matches Godot's.
|
|
/// </summary>
|
|
public static class LuneCameraMath
|
|
{
|
|
public const float FieldOfView = 34f;
|
|
public const float MinZoom = 11f;
|
|
public const float MaxZoom = 100f;
|
|
public const float DefaultZoom = 34f;
|
|
public const float OverviewZoom = 92f;
|
|
public const float PitchNear = -48f;
|
|
public const float PitchFar = -70f;
|
|
public const float FocusLimit = 42f;
|
|
|
|
public static float PitchFor(float zoom)
|
|
{
|
|
return Mathf.Lerp(PitchNear, PitchFar, SmoothStep(14f, MaxZoom, zoom)) * Mathf.Deg2Rad;
|
|
}
|
|
|
|
public static float DistanceFor(float zoom)
|
|
{
|
|
return zoom / (2f * Mathf.Tan(FieldOfView * .5f * Mathf.Deg2Rad));
|
|
}
|
|
|
|
/// <summary>Camera position and rotation for a Unity focus point, zoom and Godot yaw (radians).</summary>
|
|
public static void Pose(Vector3 focus, float zoom, float yaw, out Vector3 position, out Quaternion rotation)
|
|
{
|
|
float pitch = PitchFor(zoom);
|
|
// Godot: Vector3(0, 0, 1).rotated(RIGHT, pitch).rotated(UP, yaw).
|
|
var back = new Vector3(0f, -Mathf.Sin(pitch), Mathf.Cos(pitch));
|
|
back = new Vector3(back.x * Mathf.Cos(yaw) + back.z * Mathf.Sin(yaw), back.y, -back.x * Mathf.Sin(yaw) + back.z * Mathf.Cos(yaw));
|
|
Vector3 godotFocus = LuneSpace.FromGodot(focus);
|
|
Vector3 godotPosition = godotFocus + back * DistanceFor(zoom);
|
|
position = LuneSpace.FromGodot(godotPosition);
|
|
rotation = Quaternion.LookRotation(focus - position, Vector3.up);
|
|
}
|
|
|
|
static float SmoothStep(float from, float to, float value)
|
|
{
|
|
float t = Mathf.Clamp01((value - from) / (to - from));
|
|
return t * t * (3f - 2f * t);
|
|
}
|
|
}
|
|
}
|