Skip to content

Commit

Permalink
Just need to work on input now.
Browse files Browse the repository at this point in the history
  • Loading branch information
Software Antics committed Apr 17, 2024
1 parent b73e4d9 commit 0a9d53e
Show file tree
Hide file tree
Showing 20 changed files with 201 additions and 109 deletions.
1 change: 1 addition & 0 deletions FinalEngine.Editor.Common/FinalEngine.Editor.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

<ItemGroup>
<ProjectReference Include="..\FinalEngine.ECS\FinalEngine.ECS.csproj" />
<ProjectReference Include="..\FinalEngine.Input\FinalEngine.Input.csproj" />
<ProjectReference Include="..\FinalEngine.Rendering\FinalEngine.Rendering.csproj" />
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions FinalEngine.Editor.Common/Models/Scenes/Scene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace FinalEngine.Editor.Common.Models.Scenes;
using FinalEngine.ECS;
using FinalEngine.ECS.Components.Core;
using FinalEngine.ECS.Exceptions;
using FinalEngine.Rendering.Core;
using FinalEngine.Rendering.Components;
using Microsoft.Extensions.Logging;

public sealed class Scene : IScene
Expand Down Expand Up @@ -42,12 +42,12 @@ public void AddEntity(string tag, Guid uniqueID)

var entity = new Entity(uniqueID);

entity.AddComponent(new Tag()
entity.AddComponent(new TagComponent()
{
Name = tag,
});

entity.AddComponent(new Transform());
entity.AddComponent(new TransformComponent());

this.world.AddEntity(entity);
this.entities.Add(entity);
Expand Down
24 changes: 23 additions & 1 deletion FinalEngine.Editor.Desktop/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ namespace FinalEngine.Editor.Desktop;
using FinalEngine.Editor.ViewModels.Services.Interactions;
using FinalEngine.Editor.ViewModels.Services.Layout;
using FinalEngine.Rendering;
using FinalEngine.Rendering.Geometry;
using FinalEngine.Rendering.Lighting;
using FinalEngine.Rendering.OpenGL;
using FinalEngine.Rendering.Renderers;
using FinalEngine.Rendering.Systems.Queues;
using FinalEngine.Resources;
using FinalEngine.Runtime;
using Microsoft.Extensions.DependencyInjection;
Expand Down Expand Up @@ -83,11 +87,29 @@ private static void ConfigureServices(HostBuilderContext context, IServiceCollec

services.AddSingleton<IResourceManager>(ResourceManager.Instance);

services.AddTransient<IEntityWorld, EntityWorld>();
services.AddTransient<IEntityWorld>(x =>
{
var world = new EntityWorld();

world.AddSystem(new RenderModelRenderQueueSystem(x.GetRequiredService<IRenderQueue<RenderModel>>()));

return world;
});

services.AddSingleton<IRenderPipeline, OpenGLRenderPipeline>();
services.AddSingleton<IRenderDevice, OpenGLRenderDevice>();

services.AddSingleton<IGeometryRenderer, GeometryRenderer>();
services.AddSingleton<ISceneRenderer, SceneRenderer>();
services.AddSingleton<ILightRenderer, LightRenderer>();
services.AddSingleton<IRenderCoordinator, RenderCoordinator>();
services.AddSingleton<IRenderingEngine, RenderingEngine>();

//// TODO: ILightRenderer and IGeometryRenderer should just implement IRenderQueue directly.
services.AddSingleton<IRenderQueue<Model>>(x => (IRenderQueue<Model>)x.GetRequiredService<IGeometryRenderer>());
services.AddSingleton<IRenderQueue<RenderModel>>(x => (IRenderQueue<RenderModel>)x.GetRequiredService<IGeometryRenderer>());
services.AddSingleton<IRenderQueue<Light>>(x => (IRenderQueue<Light>)x.GetRequiredService<ILightRenderer>());

services.AddSingleton<IEngineInitializer, EngineInitializer>();

services.AddSingleton<IFileSystem, FileSystem>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public ICommand ToggleCommand

private bool CanRemove()
{
return this.component.GetType() != typeof(Tag);
return this.component.GetType() != typeof(TagComponent);
}

private void Remove()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void IntializeComponentTypes()
{
this.categorizedComponentTypes.Clear();

var assembly = Assembly.GetAssembly(typeof(Tag)) ?? throw new TypeAccessException("Failed to initialize core engine components.");
var assembly = Assembly.GetAssembly(typeof(TagComponent)) ?? throw new TypeAccessException("Failed to initialize core engine components.");

var categoryToTypeMap = this.typeResolver.GetCategorizedTypes(assembly);

Expand Down
7 changes: 4 additions & 3 deletions FinalEngine.Examples.Sponza/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ namespace FinalEngine.Examples.Sponza;
using FinalEngine.Input.Mouses;
using FinalEngine.Maths;
using FinalEngine.Rendering;
using FinalEngine.Rendering.Core;
using FinalEngine.Rendering.Components;
using FinalEngine.Rendering.Geometry;

public sealed class Camera : ICamera
{
Expand All @@ -22,7 +23,7 @@ public Camera(int width, int height)
{
this.width = width;
this.height = height;
this.Transform = new Transform()
this.Transform = new TransformComponent()
{
Position = new Vector3(0, 50, 0),
Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitY, MathHelper.DegreesToRadians(45.0f)),
Expand All @@ -41,7 +42,7 @@ public Matrix4x4 Projection
get { return Matrix4x4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(70.0f), this.width / this.height, 0.1f, 1000.0f); }
}

public Transform Transform { get; }
public TransformComponent Transform { get; }

public Matrix4x4 View
{
Expand Down
77 changes: 0 additions & 77 deletions FinalEngine.Rendering/Core/Transform.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@
// Copyright (c) Software Antics. All rights reserved.
// </copyright>

namespace FinalEngine.Rendering.Core;
namespace FinalEngine.Rendering.Geometry;

using System.Drawing;
using System.Numerics;
using FinalEngine.Rendering.Components;

public interface ICamera
{
Rectangle Bounds { get; }

Matrix4x4 Projection { get; }

Transform Transform { get; }
TransformComponent Transform { get; }

Matrix4x4 View { get; }
}
8 changes: 4 additions & 4 deletions FinalEngine.Rendering/Geometry/RenderModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace FinalEngine.Rendering.Geometry;

using FinalEngine.Rendering.Core;
using FinalEngine.Rendering.Components;

public sealed class RenderModel
{
private IMaterial? material;

private Transform? transform;
private TransformComponent? transform;

public IMaterial Material
{
Expand All @@ -20,9 +20,9 @@ public IMaterial Material

public IMesh? Mesh { get; set; }

public Transform Transform
public TransformComponent Transform
{
get { return this.transform ??= new Transform(); }
get { return this.transform ??= new TransformComponent(); }
set { this.transform = value; }
}
}
5 changes: 4 additions & 1 deletion FinalEngine.Rendering/IRenderingEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

namespace FinalEngine.Rendering;

using FinalEngine.Rendering.Core;
using System.Drawing;
using FinalEngine.Rendering.Geometry;

public interface IRenderingEngine
{
Color ClearColor { get; }

void Render(ICamera camera);
}
4 changes: 2 additions & 2 deletions FinalEngine.Rendering/Renderers/GeometryRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace FinalEngine.Rendering.Renderers;

using System;
using System.Collections.Generic;
using FinalEngine.Rendering.Core;
using FinalEngine.Rendering.Components;
using FinalEngine.Rendering.Geometry;

public sealed class GeometryRenderer : IRenderQueue<RenderModel>, IRenderQueue<Model>, IGeometryRenderer
Expand Down Expand Up @@ -87,7 +87,7 @@ private void RenderBatchInstance(IMesh? mesh)
mesh.Draw(this.renderDevice);
}

private void UpdateUniforms(Transform transform)
private void UpdateUniforms(TransformComponent transform)
{
this.renderDevice.Pipeline.SetUniform("u_transform", transform.CreateTransformationMatrix());
}
Expand Down
2 changes: 1 addition & 1 deletion FinalEngine.Rendering/Renderers/ISceneRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinalEngine.Rendering.Renderers;

using FinalEngine.Rendering.Core;
using FinalEngine.Rendering.Geometry;

public interface ISceneRenderer
{
Expand Down
2 changes: 1 addition & 1 deletion FinalEngine.Rendering/Renderers/ISkyboxRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace FinalEngine.Rendering.Renderers;

using FinalEngine.Rendering.Core;
using FinalEngine.Rendering.Geometry;
using FinalEngine.Rendering.Textures;

public interface ISkyboxRenderer
Expand Down
2 changes: 1 addition & 1 deletion FinalEngine.Rendering/Renderers/SceneRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace FinalEngine.Rendering.Renderers;

using System;
using FinalEngine.Rendering.Core;
using FinalEngine.Rendering.Geometry;
using FinalEngine.Rendering.Pipeline;
using FinalEngine.Resources;

Expand Down
1 change: 0 additions & 1 deletion FinalEngine.Rendering/Renderers/SkyboxRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ namespace FinalEngine.Rendering.Renderers;

using System;
using System.Numerics;
using FinalEngine.Rendering.Core;
using FinalEngine.Rendering.Geometry;
using FinalEngine.Rendering.Pipeline;
using FinalEngine.Rendering.Primitives;
Expand Down
14 changes: 6 additions & 8 deletions FinalEngine.Rendering/RenderingEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace FinalEngine.Rendering;
using System;
using System.Drawing;
using System.IO.Abstractions;
using FinalEngine.Rendering.Core;
using FinalEngine.Rendering.Geometry;
using FinalEngine.Rendering.Renderers;

public sealed class RenderingEngine : IRenderingEngine
Expand All @@ -20,32 +20,32 @@ public sealed class RenderingEngine : IRenderingEngine

private readonly ISceneRenderer sceneRenderer;

private readonly ISkyboxRenderer skyboxRenderer;

public RenderingEngine(
IFileSystem fileSystem,
IRenderDevice renderDevice,
ILightRenderer lightRenderer,
ISkyboxRenderer skyboxRenderer,
ISceneRenderer sceneRenderer,
IRenderCoordinator renderCoordinator)
{
ArgumentNullException.ThrowIfNull(fileSystem, nameof(fileSystem));

this.renderDevice = renderDevice ?? throw new ArgumentNullException(nameof(renderDevice));
this.lightRenderer = lightRenderer ?? throw new ArgumentNullException(nameof(lightRenderer));
this.skyboxRenderer = skyboxRenderer ?? throw new ArgumentNullException(nameof(skyboxRenderer));
this.sceneRenderer = sceneRenderer ?? throw new ArgumentNullException(nameof(sceneRenderer));
this.renderCoordinator = renderCoordinator ?? throw new ArgumentNullException(nameof(renderCoordinator));

this.ClearColor = Color.FromArgb(255, 30, 30, 30);
}

public Color ClearColor { get; set; }

public void Render(ICamera camera)
{
ArgumentNullException.ThrowIfNull(camera, nameof(camera));

this.renderDevice.Pipeline.SetFrameBuffer(null);
this.renderDevice.Rasterizer.SetViewport(camera.Bounds);
this.renderDevice.Clear(Color.Black);
this.renderDevice.Clear(this.ClearColor);

this.renderDevice.OutputMerger.SetDepthState(new DepthStateDescription()
{
Expand Down Expand Up @@ -83,7 +83,5 @@ private void RenderScene(ICamera camera)
this.sceneRenderer.Render(camera, false);
});
}

this.skyboxRenderer.Render(camera);
}
}
Loading

0 comments on commit 0a9d53e

Please sign in to comment.