feat: Step 3 Flecs.NET ECS integration with animated triangle
- Add Transform component and ECS world in Engine.Core. - TriangleRenderer.RenderWorld queries entities and applies transforms. - Animate a single triangle entity in Program.cs. - Pin ppy.SDL3-CS to 2026.520.0 and add linux-x64 RID for bundled native SDL3. - Add Flecs.NET.Debug/Release 4.0.4-build.546 per configuration. - Update SDL3 API usage for the 2026.520.0 binding. - Update architecture file to Silk.NET.Vulkan and Flecs 4.0.4.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
|
||||
<DefineConstants>DEV_MODE</DefineConstants>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'ReleaseAOT'">
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using Engine.Core;
|
||||
using Engine.Core.Components;
|
||||
using Engine.Graphics;
|
||||
using Flecs.NET.Core;
|
||||
|
||||
namespace CortexEngine.App;
|
||||
|
||||
@@ -8,17 +11,21 @@ class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("Cortex Engine Step 2 — Starting up...");
|
||||
Console.WriteLine("Cortex Engine Step 3 — Starting up...");
|
||||
|
||||
try
|
||||
{
|
||||
using var window = new Sdl3Window("Cortex Engine — Step 2", 1280, 720);
|
||||
using var world = World.Create();
|
||||
using var window = new Sdl3Window("Cortex Engine — Step 3", 1280, 720);
|
||||
var timing = new Timing();
|
||||
var input = new InputMapping();
|
||||
using var vulkan = new VulkanContext(window, enableValidation: false);
|
||||
using var swapchain = new Swapchain(vulkan);
|
||||
using var renderer = new TriangleRenderer(vulkan, swapchain);
|
||||
|
||||
var triangle = world.Entity("Triangle")
|
||||
.Set(new Transform(new Vector3(0.0f, 0.0f, 0.0f)));
|
||||
|
||||
var frames = 0;
|
||||
var lastFpsTime = 0.0;
|
||||
var lastWidth = window.Width;
|
||||
@@ -39,7 +46,16 @@ class Program
|
||||
swapchain.Recreate(lastWidth, lastHeight);
|
||||
}
|
||||
|
||||
renderer.RenderFrame();
|
||||
// Animate the entity transform.
|
||||
ref var transform = ref triangle.Ensure<Transform>();
|
||||
transform.Position = new Vector3(
|
||||
MathF.Sin((float)timing.TotalTime) * 0.5f,
|
||||
0.0f,
|
||||
0.0f);
|
||||
transform.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, (float)timing.TotalTime);
|
||||
transform.Scale = Vector3.One * (1.0f + MathF.Sin((float)timing.TotalTime * 2.0f) * 0.2f);
|
||||
|
||||
renderer.RenderWorld(world);
|
||||
|
||||
frames++;
|
||||
if (timing.TotalTime - lastFpsTime >= 1.0)
|
||||
|
||||
Reference in New Issue
Block a user