using Engine.Graphics.Camera; using Engine.Graphics.Pipeline; using OpenTK.Mathematics; namespace Engine.Scene.Component.BuiltIn; /// /// Abstract base class for cameras that provide view and projection matrices. /// public abstract class Camera : Component, ICamera { /// public abstract Matrix4 View { get; } /// public abstract Matrix4 Projection { get; } /// public Vector2i ScreenSize { get => _screenSize; set { _screenSize = value; AspectRatio = (float)value.X / value.Y; } } /// /// The aspect ratio of the camera, calculated as width divided by height. /// public float AspectRatio { get; private set; } = 1; /// /// The near clipping plane distance. /// public float NearPlane { get; set; } /// /// The far clipping plane distance. /// public float FarPlane { get; set; } /// /// The render layer for the camera. /// public RenderLayer RenderLayer { get; set; } = RenderLayer.DEFAULT; /// /// The screen size of the camera. /// private Vector2i _screenSize = new(1, 1); /// /// Initializes a new instance of the class. /// /// The near clipping plane distance. /// The far clipping plane distance. protected Camera(float parNearPlane, float parFarPlane) { NearPlane = parNearPlane; FarPlane = parFarPlane; } /// /// Converts a screen position to a world position in 3D space. /// /// The screen position to convert. /// The corresponding world position. public abstract Vector3 ScreenToWorld(Vector2 parScreenPosition); /// /// Converts a world position to a screen position in 2D space. /// /// The world position to convert. /// The corresponding screen position. public abstract Vector2 WorldToScreen(Vector3 parWorldPosition); }