/** * Copyright (c) 2021 Dominic Msters * * This software is released under the MIT License. * https://opensource.org/licenses/MIT */ #include "camera.h" void cameraLookAt(camera_t *camera, float x, float y, float z, float targetX, float targetY, float targetZ ) { ASSERT_NOT_NULL(camera); matrixIdentity(&camera->view); matrixLookAt(&camera->view, x, y, z, targetX, targetY, targetZ, 0, 1, 0); } void cameraLookAtStruct(camera_t *camera, cameralookat_t look) { ASSERT_NOT_NULL(camera); cameraLookAt(camera, look.x, look.y, look.z, look.lookX, look.lookY, look.lookZ ); } void cameraLook(camera_t *camera, float x, float y, float z, float pitch, float yaw, float roll ) { ASSERT_NOT_NULL(camera); matrixIdentity(&camera->view); matrixLook(&camera->view, x, y, z, pitch, yaw, roll, 0, 1, 0); } void cameraPerspective(camera_t *camera, float fov, float aspect, float camNear, float camFar ) { ASSERT_NOT_NULL(camera); matrixIdentity(&camera->projection); matrixPerspective(&camera->projection,mathDeg2Rad(fov),aspect,camNear,camFar); } void cameraOrtho(camera_t *camera, float left, float right, float bottom, float top, float camNear, float camFar ) { ASSERT_NOT_NULL(camera); matrixIdentity(&camera->projection); matrixOrtho(&camera->projection, left, right, bottom, top, camNear, camFar); } void cameraOrbit(camera_t *camera, float distance, float yaw, float pitch, float targetX, float targetY, float targetZ ) { float cy = cosf(pitch); float x = distance * sinf(yaw) * cy; float y = distance * sinf(pitch); float z = distance * cosf(yaw) * cy; ASSERT_NOT_NULL(camera); cameraLookAt(camera, x, y, z, targetX, targetY, targetZ); }