using System.Numerics; using System.Text.Json; using Microsoft.UI.Xaml.Hosting; using XFEEDToolBox.Controls; using XFEEDToolBox.Core.Rendering; using XFEEDToolBox.Rendering; namespace XFEEDToolBox; public partial class App { private static async Task RunLoadingHologramProbeAsync(string reportPath,string gameExecutable) { var directory=Path.GetDirectoryName(Path.GetFullPath(reportPath))!;Directory.CreateDirectory(directory); var results=new List();string? failure=null; try { if(!Environment.GetCommandLineArgs().Contains("--offline-preview"))throw new InvalidOperationException("Hologram probe requires isolated offline preview."); var compositor=ElementCompositionPreview.GetElementVisual(MainWindow.Content).Compositor; var source=new EliteLocalModels(gameExecutable); foreach(var item in EliteLocalModels.Reference.Models) { File.AppendAllText(reportPath+".progress",item.ShipType+Environment.NewLine); var mesh=await Task.Run(()=>source.Read(item.ShipType)??throw new InvalidDataException("Missing original model.")); using var graphics=new ShipGraphics(mesh,new(mesh,false,false),680,440,compositor,new(1,.502f,0,1)); graphics.Draw(12,false);var pixels=graphics.ReadPixels(); var frame=new ShipModelView.RenderedFrame(680,440,pixels,graphics.AngleDegrees); await SaveModelFrameAsync(frame,Path.Combine(directory,item.ShipType+".png")); var transparent=pixels.Where((_,i)=>i%4==3).Count(a=>a==0); var present=680*440-transparent; if(present<50||transparent<680*440*.2)throw new InvalidOperationException("Empty or opaque model target: "+item.ShipType); results.Add(new{item.ShipType,mesh.Sha256,mesh.Triangles,graphics.Adapter,frame=MeasureHologramFrame(frame)}); if(item.ShipType is "anaconda" or "cobramkiii" or "cobramkiv") { foreach(var seconds in new[]{0d,24,48}) { graphics.Resize(1400,900);graphics.Draw(seconds,false); await SaveModelFrameAsync(new(1400,900,graphics.ReadPixels(),graphics.AngleDegrees),Path.Combine(directory,$"{item.ShipType}-pose-{seconds:0}.png")); } graphics.Resize(190,140);graphics.Draw(12,false); await SaveModelFrameAsync(new(190,140,graphics.ReadPixels(),graphics.AngleDegrees),Path.Combine(directory,item.ShipType+"-small.png")); } } } catch(Exception error){failure=error.ToString();} await File.WriteAllTextAsync(reportPath,JsonSerializer.Serialize(new{models=results,failure,material=LoadingHologramProfile.Default, gameActionsInvoked=false,desktopCapture=false,isolatedOffline=true},new JsonSerializerOptions{WriteIndented=true})); MainWindow.Close(); } }