small improvements and test code for manipulating vertices

This commit is contained in:
2026-01-03 19:35:33 +01:00
parent e91bf12a3d
commit e94d544043
3 changed files with 23 additions and 4 deletions

View File

@@ -110,6 +110,9 @@ internal class OpenGLEngine : Engine
{
_window.Close();
}
Time._secondsSinceStart = _window.Time;
Time._deltaTime = deltaTime;
TemporaryMovementProcessing((float)deltaTime);
TemporaryMouseProcessing();

View File

@@ -0,0 +1,12 @@
namespace EngineSharp.Core;
public static class Time
{
internal static double _deltaTime;
internal static double _secondsSinceStart;
public static double DeltaTime => _deltaTime;
public static float DeltaTimeF => (float)_deltaTime;
public static double SecondsSinceStart => _secondsSinceStart;
public static float SecondsSinceStartF => (float)_secondsSinceStart;
}

View File

@@ -1,9 +1,12 @@
using EngineSharp.Core;
using EngineSharp.Core.Rendering;
using Silk.NET.Maths;
namespace EngineSharp;
public class PlanetGenerator : Core.ECS.LogicComponent
{
private MeshRenderer _planetMesh = null!;
public override void Initialise()
{
var shader = Shader.GetShader("./assets/shaders/sphere.vert");
@@ -17,17 +20,18 @@ public class PlanetGenerator : Core.ECS.LogicComponent
Material = material,
};
// TODO: MeshRenderer should probably not have the mesh as a required property.
var planetMesh = new MeshRenderer
_planetMesh = new MeshRenderer
{
Mesh = sphereGenerator.CreateSphere(),
};
Entity.AddComponent(planetMesh);
Entity.AddComponent(_planetMesh);
}
public override void OnUpdate(double deltaTime)
{
// Nothing to do at the moment
// TODO: Now that vertices can be manipulated, I now need to implement the infrastructure to support compute shaders for planet generation
var time = (float)Time.SecondsSinceStart;
_planetMesh.Mesh.Vertices[0] = new Vector3D<float>(MathF.Sin(time), MathF.Cos(time), MathF.Sin(time));
}
}