X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=camera.h;h=63743935e871a51b59108af102a1470320c067c4;hb=2f44245bafbb83a2172e544a7a2965ae837186ed;hp=dbacc26afd7d89f47308781caeef7767ae0f03e4;hpb=ff8fcac9582d07bc1ccbf08421d6ffec1758a755;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/camera.h b/camera.h index dbacc26..6374393 100644 --- a/camera.h +++ b/camera.h @@ -1,12 +1,10 @@ #ifndef CAMERA_H #define CAMERA_H -#include "common.h" +#include "skaterift.h" typedef struct camera camera; - -struct camera -{ +struct camera{ /* Input */ v3f angles; v3f pos; @@ -16,19 +14,22 @@ struct camera m4x3f transform, transform_inverse; - struct camera_mtx - { + struct camera_mtx{ m4x4f p, v, pv; } mtx, mtx_prev; +}; + +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 main_camera; -VG_STATIC void camera_lerp( camera *a, camera *b, float t, camera *d ) -{ +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 ); @@ -36,13 +37,19 @@ VG_STATIC void camera_lerp( camera *a, camera *b, float t, camera *d ) d->fov = vg_lerpf( a->fov, b->fov, t ); } +VG_STATIC void camera_copy( camera *a, camera *d ){ + v3_copy( a->pos, d->pos ); + v3_copy( a->angles, d->angles ); + d->fov = a->fov; +} + /* * 1) [angles, pos] -> transform */ 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 );