using System; namespace GlitchyEngine.Core; /// /// The type of projection used by a camera. /// [EngineClass("GlitchyEngine.World.SceneCamera.ProjectionType")] public enum ProjectionType : byte { /// /// An orthographic projection. /// Orthographic = 0, /// /// A perspective projection. /// Perspective = 1, /// /// A perspective projection where the far plane is infinitely far away from the camera. /// InfinitePerspective = 2 } /// /// A component representing a camera that is attached to the entity. /// public class Camera : Component { /// /// The projection type of the . /// public ProjectionType ProjectionType { get { ScriptGlue.Camera_GetProjectionType(_uuid, out ProjectionType projectionType); return projectionType; } set => ScriptGlue.Camera_SetProjectionType(_uuid, value); } /// /// Gets or sets the Y field of view in perspective mode. /// public float PerspectiveFovY { get { ScriptGlue.Camera_GetPerspectiveFovY(_uuid, out float fovY); return fovY; } set => ScriptGlue.Camera_SetPerspectiveFovY(_uuid, value); } /// /// Gets or sets the X field of view in perspective mode. /// public float PerspectiveFovX { get => PerspectiveFovY * AspectRatio; set => PerspectiveFovY = value / AspectRatio; } /// /// Gets or sets the near plane distance in perspective mode. /// public float PerspectiveNearPlane { get { ScriptGlue.Camera_GetPerspectiveNearPlane(_uuid, out float nearPlane); return nearPlane; } set => ScriptGlue.Camera_SetPerspectiveNearPlane(_uuid, value); } /// /// Gets or sets the far plane distance in perspective mode. /// public float PerspectiveFarPlane { get { ScriptGlue.Camera_GetPerspectiveFarPlane(_uuid, out float farPlane); return farPlane; } set => ScriptGlue.Camera_SetPerspectiveFarPlane(_uuid, value); } /// /// Gets or sets the orthographic height. /// public float OrthographicHeight { get { ScriptGlue.Camera_GetOrthographicHeight(_uuid, out float height); return height; } set => ScriptGlue.Camera_SetOrthographicHeight(_uuid, value); } /// /// Gets or sets the near plane distance in orthographic mode. /// public float OrthographicNearPlane { get { ScriptGlue.Camera_GetOrthographicNearPlane(_uuid, out float nearPlane); return nearPlane; } set => ScriptGlue.Camera_SetOrthographicNearPlane(_uuid, value); } /// /// Gets or sets the far plane distance in orthographic mode. /// public float OrthographicFarPlane { get { ScriptGlue.Camera_GetOrthographicFarPlane(_uuid, out float farPlane); return farPlane; } set => ScriptGlue.Camera_SetOrthographicFarPlane(_uuid, value); } /// /// Gets or sets the aspect ratio. /// /// The setter throws an , when is zero. public float AspectRatio { get { ScriptGlue.Camera_GetAspectRatio(_uuid, out float aspectRatio); return aspectRatio; } set { if (value == 0) throw new ArgumentException($"{AspectRatio} must not be zero."); ScriptGlue.Camera_SetAspectRatio(_uuid, value); } } /// /// Gets or sets a value indicating whether the aspect ratio is fixed. /// public bool FixedAspectRatio { get { ScriptGlue.Camera_GetFixedAspectRatio(_uuid, out bool fixedAspectRatio); return fixedAspectRatio; } set => ScriptGlue.Camera_SetFixedAspectRatio(_uuid, value); } }