Componentified Camera

This commit is contained in:
Simon Lübeß
2021-05-17 20:07:58 +02:00
parent 3e0c4b2eb7
commit 7fb1f30303
6 changed files with 234 additions and 34 deletions
+13
View File
@@ -1,4 +1,5 @@
using GlitchyEngine.Math;
using GlitchyEngine.World;
namespace GlitchyEngine.Renderer
{
@@ -36,6 +37,18 @@ namespace GlitchyEngine.Renderer
RenderCommand.Init();
}
public static void BeginScene(EcsWorld world, Entity cameraEntity)
{
var camera = world.GetComponent<CameraComponent>(cameraEntity);
var transform = world.GetComponent<TransformComponent>(cameraEntity);
var trans = transform.Transform;
var view = trans.Invert();
var proj = camera.Projection;
_sceneConstants.ViewProjection = proj * view;
}
public static void BeginScene(Camera camera)
{
_sceneConstants.ViewProjection = camera.ViewProjection;