/** * Copyright (c) 2026 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "entity/entitybase.h" typedef enum { ENTITY_CAMERA_PROJECTION_TYPE_PERSPECTIVE, ENTITY_CAMERA_PROJECTION_TYPE_PERSPECTIVE_FLIPPED, ENTITY_CAMERA_PROJECTION_TYPE_ORTHOGRAPHIC } entitycameraprojectiontype_t; typedef struct { union { struct { float_t fov; } perspective; struct { float_t left; float_t right; float_t top; float_t bottom; } orthographic; }; float_t nearClip; float_t farClip; entitycameraprojectiontype_t projType; } entitycamera_t; /** * Initializes an entity camera component. * * @param ent The entity ID. * @param comp The component ID. */ void entityCameraInit(const entityid_t ent, const componentid_t comp); /** * Renders out the projection matrix for the given camera. * * @param ent The entity ID. * @param comp The component ID. * @param out The output projection matrix. */ void entityCameraGetProjection( const entityid_t ent, const componentid_t comp, mat4 out ); /** * Returns the entity ID of the first active camera, or ENTITY_COUNT_MAX if * none are active. */ entityid_t entityCameraGetCurrent(void); /** * Gets the camera's horizontal forward direction (XZ plane) from its position * component. Automatically finds the position component on the entity. * * @param entityId The camera entity ID. * @param out Output vec2: {forwardX, forwardZ} normalized. */ void entityCameraGetForward(const entityid_t entityId, vec2 out); /** * Gets the camera's horizontal right direction (XZ plane) from its position * component. Automatically finds the position component on the entity. * * @param entityId The camera entity ID. * @param out Output vec2: {rightX, rightZ} normalized. */ void entityCameraGetRight(const entityid_t entityId, vec2 out);