From d156fb404430124e60f744d7fb3cefa5a562e827 Mon Sep 17 00:00:00 2001 From: mo7sener Date: Mon, 16 Dec 2019 23:19:46 +0200 Subject: [PATCH] Changing controls and probably some matrices --- OpenWindow/camera.cpp | 12 +++++++++++- OpenWindow/main.cpp | 8 ++++---- OpenWindow/renderer.cpp | 6 +++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/OpenWindow/camera.cpp b/OpenWindow/camera.cpp index b434b70..57af509 100644 --- a/OpenWindow/camera.cpp +++ b/OpenWindow/camera.cpp @@ -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; } diff --git a/OpenWindow/main.cpp b/OpenWindow/main.cpp index 5d5e7dc..b7cdbe5 100644 --- a/OpenWindow/main.cpp +++ b/OpenWindow/main.cpp @@ -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(); diff --git a/OpenWindow/renderer.cpp b/OpenWindow/renderer.cpp index 939d11c..b144d72 100644 --- a/OpenWindow/renderer.cpp +++ b/OpenWindow/renderer.cpp @@ -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);