aboutsummaryrefslogtreecommitdiff
path: root/src/cameras.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cameras.c')
-rw-r--r--src/cameras.c30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/cameras.c b/src/cameras.c
index dc1afd0..ca03b51 100644
--- a/src/cameras.c
+++ b/src/cameras.c
@@ -1,6 +1,7 @@
#include "cameras.h"
#include "game.h"
#include "world.h"
+#include "entitiesInclude.h"
// First person camera indeed.
void initFirstPersonCamera(Game * game, Camera3D * camera) {
@@ -30,12 +31,37 @@ void initThirdPersonCamera(Game * game, Camera3D * camera) {
void updateThirdPersonCamera(Game * game, Camera3D * camera) {
Entity * player = getEntityFromWorld(game->world, 0);
Vector3 direction = Vector3RotateByQuaternion(THIRD_PERSON_CAMERA_DISTANCE, player->rotation);
-
camera->position = Vector3Add(player->position, direction);
+
camera->target = player->position;
camera->up = Vector3RotateByQuaternion((Vector3){0.0, 1.0, 0.0}, player->rotation);
}
+// Zoom camera indeed hehehehehehe.
+void initZoomCamera(Game * game, Camera3D * camera) {
+ *camera = (Camera3D){
+ .fovy = 12.0,
+ .projection = CAMERA_PERSPECTIVE
+ };
+}
+
+void updateZoomCamera(Game * game, Camera3D * camera) {
+ Entity * player = getEntityFromWorld(game->world, 0);
+ AntifaShip * data = (AntifaShip*)player->data;
+
+ Vector3 direction;
+
+ // Get direction. Aim with ship or target on target entity.
+ if (data->doAutoTarget)
+ direction = data->gunTarget;
+ else
+ direction = Vector3RotateByQuaternion((Vector3){0.0, 0.0, 1.0}, player->rotation);
+
+ camera->position = Vector3Add(player->position, Vector3Scale(direction, FIRST_PERSON_CAMERA_DISTANCE));
+ camera->target = Vector3Add(camera->position, direction);
+ camera->up = Vector3RotateByQuaternion((Vector3){0.0, 1.0, 0.0}, player->rotation);
+}
+
// KILL THE BUGS!!!
void initDebugCamera(Game * game, Camera3D * camera) {
*camera = (Camera3D){
@@ -55,12 +81,14 @@ void updateDebugCamera(Game * game, Camera3D * camera) {
const CameraInitCb cameraInitCallbacks[CAMERA_COUNT] = {
initFirstPersonCamera,
initThirdPersonCamera,
+ initZoomCamera,
initDebugCamera
};
const CameraCb cameraCallbacks[CAMERA_COUNT] = {
updateFirstPersonCamera,
updateThirdPersonCamera,
+ updateZoomCamera,
updateDebugCamera
};