Render Zyphos height field from fractal DSL
This commit is contained in:
parent
d02533fe22
commit
ad254bae30
8 changed files with 56 additions and 18 deletions
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Aquarium.Engine.Contracts\Aquarium.Engine.Contracts.csproj" />
|
||||
<ProjectReference Include="..\Aquarium.Engine.Fractal\Aquarium.Engine.Fractal.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
26
src/Aquarium.Zyphos/ZyphosFractalTerrain.cs
Normal file
26
src/Aquarium.Zyphos/ZyphosFractalTerrain.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using Aquarium.Engine.Fractal.Brushes;
|
||||
using Aquarium.Engine.Fractal.Grammar;
|
||||
using Aquarium.Engine.Render;
|
||||
|
||||
namespace Aquarium.Zyphos;
|
||||
|
||||
public static class ZyphosFractalTerrain
|
||||
{
|
||||
public const string Grammar = """
|
||||
# Zyphos first Aquarium fractal terrain DSL proof.
|
||||
tile PositiveZ 0 0 0 zyphos/first-fractal-terrain
|
||||
height basin 0 0 30 30 0 3 1 -0.12 7 basin
|
||||
ifs crater 3 2 -5 3 6 2.5 0.48 2.6 0.42 4 0.85 -0.10 19 crater
|
||||
ifs ridge 2 3 6 -4 5 1.35 0.45 3.2 -0.27 3.6 0.72 0.075 31 ridge
|
||||
""";
|
||||
|
||||
private static readonly Lazy<FractalOwnershipTree> Tree = new(() => FractalDslCompiler.Compile(Grammar));
|
||||
private static readonly Lazy<AquariumHeightFieldBrush[]> Brushes = new(() => FractalHeightBrushCompiler.CompileMany(Tree.Value.Claims));
|
||||
|
||||
public static FractalOwnershipTree OwnershipTree => Tree.Value;
|
||||
|
||||
public static AquariumHeightFieldBrush[] HeightBrushes => Brushes.Value;
|
||||
|
||||
public static string Summary =>
|
||||
$"{OwnershipTree.Claims.Count} DSL claims / {OwnershipTree.Nodes.Count} node / {HeightBrushes.Length} shaped brushes";
|
||||
}
|
||||
|
|
@ -47,9 +47,10 @@ public sealed class ZyphosRuntime : IAquariumRuntime
|
|||
panel.Slider("Orbit Distance", () => orbitDistance, value => orbitDistance = value, 9.0f, 24.0f, "0.0");
|
||||
panel.Readout("Runtime", () => $"{timeSeconds:0.0}s");
|
||||
panel.Readout("Camera", () => $"{orbitDistance:0.0} wu / yaw {orbitYaw:0.00}");
|
||||
panel.Readout("Objects", () => "spherical terrain, atmosphere, moon");
|
||||
panel.Readout("Terrain DSL", () => ZyphosFractalTerrain.Summary);
|
||||
panel.Readout("Objects", () => "fractal height DSL, atmosphere, moon");
|
||||
})
|
||||
.Command("zyphos", _ => "Zyphos: planetary-scale client demo loaded.", "Report Zyphos demo status.");
|
||||
.Command("zyphos", _ => $"Zyphos: {ZyphosFractalTerrain.Summary}", "Report Zyphos demo status.");
|
||||
}
|
||||
|
||||
public AquariumFrame ComposeFrame(AquariumFrame frame, AquariumFrameInput input)
|
||||
|
|
|
|||
|
|
@ -22,18 +22,7 @@ public static class ZyphosSceneBuilder
|
|||
|
||||
private static AquariumHeightFieldBrush[] BuildHeightFieldBrushes()
|
||||
{
|
||||
return
|
||||
[
|
||||
new AquariumHeightFieldBrush(
|
||||
Vector2.Zero,
|
||||
30.0f,
|
||||
2.6f,
|
||||
-0.18f,
|
||||
0.03f,
|
||||
1.9f,
|
||||
0.22f,
|
||||
1.1f)
|
||||
];
|
||||
return ZyphosFractalTerrain.HeightBrushes;
|
||||
}
|
||||
|
||||
private static AquariumSdfObject[] BuildSdfObjects(float timeSeconds, float previousTimeSeconds)
|
||||
|
|
|
|||
Loading…
Reference in a new issue