orthographic projection for fov=0, rework of order and defaults for 3d camera api
This commit is contained in:
@ -413,8 +413,9 @@ void render(void) {
|
||||
}
|
||||
|
||||
|
||||
void draw_camera(Vec3 position, float fov, Vec3 up, Vec3 direction) {
|
||||
if (fabsf(0.0f - fov) < 0.00001f || fov >= M_PIf)
|
||||
void draw_camera(Vec3 position, Vec3 direction, Vec3 up, float fov) {
|
||||
bool const orthographic = fabsf(0.0f - fov) < 0.00001f;
|
||||
if (!orthographic && fov >= M_PIf)
|
||||
log_warn("Invalid fov given (%f)", (double)fov);
|
||||
|
||||
Camera const camera = {
|
||||
@ -424,14 +425,24 @@ void draw_camera(Vec3 position, float fov, Vec3 up, Vec3 direction) {
|
||||
.up = up,
|
||||
};
|
||||
|
||||
camera_projection_matrix = camera_perspective(&camera);
|
||||
camera_look_at_matrix = camera_look_at(&camera);
|
||||
if (!orthographic)
|
||||
camera_projection_matrix = camera_perspective(&camera);
|
||||
else
|
||||
camera_projection_matrix = camera_orthographic(&camera);
|
||||
|
||||
camera_look_at_matrix = camera_look_at(&camera);
|
||||
}
|
||||
|
||||
|
||||
/* TODO: https://stackoverflow.com/questions/62493770/how-to-add-roll-in-camera-class */
|
||||
DrawCameraFromPrincipalAxesResult draw_camera_from_principal_axes(Vec3 position, float fov, float roll, float pitch, float yaw) {
|
||||
if (fabsf(0.0f - fov) < 0.00001f || fov >= M_PIf)
|
||||
DrawCameraFromPrincipalAxesResult draw_camera_from_principal_axes(Vec3 position,
|
||||
float roll,
|
||||
float pitch,
|
||||
float yaw,
|
||||
float fov)
|
||||
{
|
||||
bool const orthographic = fabsf(0.0f - fov) < 0.00001f;
|
||||
if (!orthographic && fov >= M_PIf)
|
||||
log_warn("Invalid fov given (%f)", (double)fov);
|
||||
|
||||
(void)roll;
|
||||
@ -451,8 +462,12 @@ DrawCameraFromPrincipalAxesResult draw_camera_from_principal_axes(Vec3 position,
|
||||
.up = (Vec3){0, 1, 0},
|
||||
};
|
||||
|
||||
camera_projection_matrix = camera_perspective(&camera);
|
||||
camera_look_at_matrix = camera_look_at(&camera);
|
||||
if (!orthographic)
|
||||
camera_projection_matrix = camera_perspective(&camera);
|
||||
else
|
||||
camera_projection_matrix = camera_orthographic(&camera);
|
||||
|
||||
camera_look_at_matrix = camera_look_at(&camera);
|
||||
|
||||
return (DrawCameraFromPrincipalAxesResult) {
|
||||
.direction = camera.target,
|
||||
|
Reference in New Issue
Block a user