prosperon/source/engine/camera.c

23 lines
747 B
C
Raw Normal View History

2021-11-30 21:29:18 -06:00
#include "camera.h"
#include "gameobject.h"
#include "input.h"
2022-02-06 10:14:57 -06:00
2021-11-30 21:29:18 -06:00
const float CAMERA_MINSPEED = 1.f;
const float CAMERA_MAXSPEED = 300.f;
const float CAMERA_ROTATESPEED = 6.f;
2023-05-12 13:22:05 -05:00
void cam_goto_object(struct mCamera *cam, struct mTransform *transform) {
2023-05-24 20:45:50 -05:00
cam->transform.pos = HMM_SubV3(transform->pos, HMM_MulV3F(trans_forward(transform), 10.0));
2021-11-30 21:29:18 -06:00
}
2023-05-12 13:22:05 -05:00
void cam_inverse_goto(struct mCamera *cam, struct mTransform *transform) {
2023-05-24 20:45:50 -05:00
transform->pos = HMM_AddV3(cam->transform.pos, HMM_MulV3F(trans_forward(&cam->transform), 10.0));
2021-11-30 21:29:18 -06:00
}
2023-05-24 20:45:50 -05:00
HMM_Mat4 getviewmatrix(const struct mCamera *const camera)
2021-11-30 21:29:18 -06:00
{
2023-05-24 20:45:50 -05:00
HMM_Vec3 lookvec = HMM_AddV3(camera->transform.pos, trans_forward(&camera->transform.rotation));
return HMM_LookAt_RH(camera->transform.pos, lookvec, vY);
2021-11-30 21:29:18 -06:00
}