fixed bug and "started" ECS
This commit is contained in:
12
src/EngineSharp.Core/EngineSharp.Core/ECS/GameObject.cs
Normal file
12
src/EngineSharp.Core/EngineSharp.Core/ECS/GameObject.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace EngineSharp.Core.ECS;
|
||||||
|
|
||||||
|
// TODO: A GameObject would have a list of Components. A GameObject is basically what will be stored in the scene graph and all components of all GameObjects will have their Update methods etc. be called
|
||||||
|
|
||||||
|
// Maybe look at this C# ECS to get an idea of how to implement one myself
|
||||||
|
// https://github.com/friflo/Friflo.Engine.ECS/tree/main
|
||||||
|
public abstract class GameObject
|
||||||
|
{
|
||||||
|
private long Id { get; set; }
|
||||||
|
|
||||||
|
public abstract void OnUpdate(double deltaTime);
|
||||||
|
}
|
@ -58,7 +58,7 @@ internal class OpenGLEngine : IEngine
|
|||||||
var viewMatrix = _camera.ViewMatrix;
|
var viewMatrix = _camera.ViewMatrix;
|
||||||
|
|
||||||
// TODO: Here render all meshes etc.
|
// TODO: Here render all meshes etc.
|
||||||
// On constructing a MeshRenderer, register it somewhere so it can be rendered here (MeshRenderer would then be a component while Mesh would be a normal C# object in the context of a ECS)
|
// On constructing a MeshRenderer, register it somewhere so it can be rendered here (MeshRenderer would then be a component while Mesh would be a normal C# object in the context of an ECS)
|
||||||
// MeshRenderer contains a mesh; Mesh contains a material; Material contains a shader and the values for all uniforms of the shader (apart from the matrices; I am not sure how to best handle the model matrix with this approach)
|
// MeshRenderer contains a mesh; Mesh contains a material; Material contains a shader and the values for all uniforms of the shader (apart from the matrices; I am not sure how to best handle the model matrix with this approach)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class PerspectiveCamera
|
|||||||
return Matrix4X4.CreateLookAt(_position, _position + _intrinsicCoordinates.Column3, _worldUp); // TODO: I hope this is Left-Handed. If not I need to update the readme
|
return Matrix4X4.CreateLookAt(_position, _position + _intrinsicCoordinates.Column3, _worldUp); // TODO: I hope this is Left-Handed. If not I need to update the readme
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Matrix4X4<float> ProjectionMatrix => Matrix4X4.CreatePerspectiveFieldOfView(Fov, _aspectRatio, NearClippingPlane, FarClippingPlane);
|
public Matrix4X4<float> ProjectionMatrix => Matrix4X4.CreatePerspectiveFieldOfView(Fov.ToRadians(), _aspectRatio, NearClippingPlane, FarClippingPlane);
|
||||||
|
|
||||||
public PerspectiveCamera(Vector3D<float> position, Vector2D<int> viewportDimensions, float yaw = -90.0f, float pitch = 0, float fov = 45.0f, float nearClippingPlane = 0.1f, float farClippingPlane = 100.0f)
|
public PerspectiveCamera(Vector3D<float> position, Vector2D<int> viewportDimensions, float yaw = -90.0f, float pitch = 0, float fov = 45.0f, float nearClippingPlane = 0.1f, float farClippingPlane = 100.0f)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user