/** * Copyright (c) 2021 Dominic Masters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #pragma once #include "../libs.h" /** * Representation for a matrix. Used as a highlevel wrapper for the math * functions that sit underneath this API. */ typedef struct { /** Internal Matrix API */ mat4 internalMatrix; } matrix_t; /** * Makes matrix identity. * @param matrix Matrix to identify. */ void matrixIdentity(matrix_t *matrix); /** * Applies a look at point vector to a matrix. * * @param matrix Matrix to apply to. * @param x Camera source X. * @param y Camera source Y. * @param z Camera source Z. * @param tx Camera target X. * @param ty Camera target Y. * @param tz Camera target Z. * @param ux Camera up vector X. * @param uy Camera up vector Y. * @param uz Camera up vector Z. */ void matrixLookAt(matrix_t *matrix, float x,float y,float z, float tx,float ty, float tz, float ux, float uy, float uz ); /** * Applies a look vector to a matrix. * * @param matrix Matrix to apply to. * @param x Camera source X. * @param y Camera source Y. * @param z Camera source Z. * @param pitch Camera pitch * @param yaw Camera yaw. * @param roll Camera roll. * @param ux Camera up vector X. * @param uy Camera up vector Y. * @param uz Camera up vector Z. */ void matrixLook(matrix_t *matrix, float x, float y, float z, float pitch, float yaw, float roll, float ux, float uy, float uz ); /** * Applies a perspective projection to a matrix. * * @param matrix Matrix to apply to. * @param fov Field of View (in radians) to use. * @param aspect Aspect ratio (w/h) of the viewport. * @param camNear Near vector, > 0. * @param camFar Far view vector. */ void matrixPerspective(matrix_t *matrix, float fov,float aspect, float camNear, float camFar ); /** * Applies an orthogonal projection to a matrix. * * @param matrix Matrix to apply to. * @param left Left view position. * @param right Right view position. * @param bottom Bottom view position. * @param top Top view position. * @param camNear Near vector, > 0. * @param camFar Far view vector. */ void matrixOrtho(matrix_t *matrix, float left, float right, float bottom, float top, float camNear, float camFar ); /** * Performs a matrix translation. * * @param matrix Matrix to translate. * @param x X coordinate to translate on. * @param y Y coordinate to translate on. * @param z Z coordinate to translate on. */ void matrixTranslate(matrix_t *matrix, float x, float y, float z); /** * Applies a rotation vector to a matrix. * * @param matrix Matrix to rotate. * @param angle Angle (in radians) to rotate. * @param x X vector to rotate on. * @param y Y vector to rotate on. * @param z Z vector to rotate on. */ void matrixRotate(matrix_t *matrix, float angle, float x, float y, float z); /** * Scales a matrix. * * @param matrix Matrix to scale * @param x X vector to scale. * @param y Y vector to scale. * @param z Z vector to scale. */ void matrixScale(matrix_t *matrix, float x, float y, float z);