small improvements and test code for manipulating vertices
This commit is contained in:
@@ -110,6 +110,9 @@ internal class OpenGLEngine : Engine
|
||||
{
|
||||
_window.Close();
|
||||
}
|
||||
|
||||
Time._secondsSinceStart = _window.Time;
|
||||
Time._deltaTime = deltaTime;
|
||||
|
||||
TemporaryMovementProcessing((float)deltaTime);
|
||||
TemporaryMouseProcessing();
|
||||
|
||||
12
src/EngineSharp.Core/EngineSharp.Core/Time.cs
Normal file
12
src/EngineSharp.Core/EngineSharp.Core/Time.cs
Normal 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;
|
||||
}
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user