X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=camera.h;h=f028f825e67ef227119af309e365c2b49f494776;hb=7b1e8a237acc3121c86fab9b5946da6a8d3bf6c4;hp=596409937ceb3cf2f532c7d22f2c999533bd9fa7;hpb=f7db507815e2822d971031c30f25e02b45e9c914;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/camera.h b/camera.h index 5964099..f028f82 100644 --- a/camera.h +++ b/camera.h @@ -8,7 +8,7 @@ typedef struct camera camera; struct camera { /* Input */ - v2f angles; + v3f angles; v3f pos; float fov, nearz, farz; @@ -16,8 +16,7 @@ struct camera m4x3f transform, transform_inverse; - struct camera_mtx - { + struct camera_mtx{ m4x4f p, v, pv; @@ -25,7 +24,23 @@ struct camera mtx, mtx_prev; } -VG_STATIC main_camera; +static main_camera, gate_camera; + +VG_STATIC void camera_lerp_angles( v3f a, v3f b, float t, v3f d ) +{ + d[0] = vg_alerpf( a[0], b[0], t ); + d[1] = vg_lerpf( a[1], b[1], t ); + d[2] = vg_lerpf( a[2], b[2], t ); +} + +VG_STATIC void camera_lerp( camera *a, camera *b, float t, camera *d ) +{ + v3_lerp( a->pos, b->pos, t, d->pos ); + d->angles[0] = vg_alerpf( a->angles[0], b->angles[0], t ); + d->angles[1] = vg_lerpf( a->angles[1], b->angles[1], t ); + d->angles[2] = vg_lerpf( a->angles[2], b->angles[2], t ); + d->fov = vg_lerpf( a->fov, b->fov, t ); +} /* * 1) [angles, pos] -> transform @@ -33,7 +48,7 @@ VG_STATIC main_camera; VG_STATIC void camera_update_transform( camera *cam ) { v4f qyaw, qpitch, qcam; - q_axis_angle( qyaw, (v3f){ 0.0f, 1.0f, 0.0f }, -cam->angles[0] ); + q_axis_angle( qyaw, (v3f){ 0.0f, 1.0f, 0.0f }, -cam->angles[0] ); q_axis_angle( qpitch, (v3f){ 1.0f, 0.0f, 0.0f }, -cam->angles[1] ); q_mul( qyaw, qpitch, qcam );