Changing controls and probably some matrices

This commit is contained in:
2019-12-16 23:19:46 +02:00
parent 8b1546cb54
commit d156fb4044
3 changed files with 18 additions and 8 deletions
+11 -1
View File
@@ -1,4 +1,5 @@
#include "camera.h"
#include "util_window.h"
Camera::Camera()
{
@@ -107,6 +108,9 @@ Matrix Camera::GetModelViewMatrix() {
Minv[2][i] = z[i];
Tr[i][3] = -center[i];
}
// Minv[3][0] = (right * position);
// Minv[3][1] = (up * position);
// Minv[3][2] = (z * position);
return Minv * Tr;
}
@@ -115,7 +119,13 @@ Matrix Camera::GetProjectionMatrix() {
Projection[0][0] = 1 / tan(fov * DEG2RAD);
Projection[1][1] = 1 / tan(fov * DEG2RAD);
Projection[2][2] = (far_plane + near_plane) / (far_plane - near_plane);
Projection[2][3] = (-2 * far_plane * near_plane) / (far_plane - near_plane);
Projection[2][3] = (2 * far_plane * near_plane) / (far_plane - near_plane);
//Projection[2][2] = -(far_plane) / (far_plane - near_plane);
//Projection[2][3] = -1;
//Projection[3][2] = -(far_plane * near_plane) / (far_plane - near_plane);
//Projection[2][2] = -2 / (far_plane - near_plane);
//Projection[2][3] = (far_plane + near_plane) / (far_plane - near_plane);
Projection[3][2] = -1;
Projection[3][3] = 1;
return Projection;
}
+4 -4
View File
@@ -46,13 +46,13 @@ void HandleMouseMovement() {
}
bool HandleButtonPressed() {
if (GetAsyncKeyState(VK_UP) & 0x8000)
if (GetAsyncKeyState(0x57) & 0x8000)
camera.move_camera_forward();
if (GetAsyncKeyState(VK_DOWN) & 0x8000)
if (GetAsyncKeyState(0x53) & 0x8000)
camera.move_camera_backward();
if (GetAsyncKeyState(VK_RIGHT) & 0x8000)
if (GetAsyncKeyState(0x44) & 0x8000)
camera.move_camera_right();
if (GetAsyncKeyState(VK_LEFT) & 0x8000)
if (GetAsyncKeyState(0x41) & 0x8000)
camera.move_camera_left();
if (GetAsyncKeyState(VK_SPACE) & 0x8000)
camera.rise();
+3 -3
View File
@@ -8,13 +8,13 @@
#define VERTICAL_CAMERA_SPEED 0.1
#define VERTICAL_CAMERA_CLAMP_UP 90
#define VERTICAL_CAMERA_CLAMP_DOWN -90
#define NEAR_CLIP_PLANE 0
#define FAR_CLIP_PLANE 10
#define NEAR_CLIP_PLANE 0.3f
#define FAR_CLIP_PLANE 10.0f
#define FOV 30
#define CAMERA_MOVEMENT_SPEED 0.05f
#define DEFAULT_CAMERA_POS Vec3f(0, 0, 5)
#define DEFAULT_CAMERA_ROT Vec3f(0, 0, 0)
#define LIGHT_INTENSITY 2.f
#define LIGHT_INTENSITY 1.5
const TGAColor white = TGAColor(255, 255, 255, 255);
const TGAColor red = TGAColor(255, 0, 0, 255);