Changing controls and probably some matrices
This commit is contained in:
+11
-1
@@ -1,4 +1,5 @@
|
|||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
|
#include "util_window.h"
|
||||||
|
|
||||||
Camera::Camera()
|
Camera::Camera()
|
||||||
{
|
{
|
||||||
@@ -107,6 +108,9 @@ Matrix Camera::GetModelViewMatrix() {
|
|||||||
Minv[2][i] = z[i];
|
Minv[2][i] = z[i];
|
||||||
Tr[i][3] = -center[i];
|
Tr[i][3] = -center[i];
|
||||||
}
|
}
|
||||||
|
// Minv[3][0] = (right * position);
|
||||||
|
// Minv[3][1] = (up * position);
|
||||||
|
// Minv[3][2] = (z * position);
|
||||||
return Minv * Tr;
|
return Minv * Tr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +119,13 @@ Matrix Camera::GetProjectionMatrix() {
|
|||||||
Projection[0][0] = 1 / tan(fov * DEG2RAD);
|
Projection[0][0] = 1 / tan(fov * DEG2RAD);
|
||||||
Projection[1][1] = 1 / tan(fov * DEG2RAD);
|
Projection[1][1] = 1 / tan(fov * DEG2RAD);
|
||||||
Projection[2][2] = (far_plane + near_plane) / (far_plane - near_plane);
|
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][2] = -1;
|
||||||
|
Projection[3][3] = 1;
|
||||||
return Projection;
|
return Projection;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -46,13 +46,13 @@ void HandleMouseMovement() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool HandleButtonPressed() {
|
bool HandleButtonPressed() {
|
||||||
if (GetAsyncKeyState(VK_UP) & 0x8000)
|
if (GetAsyncKeyState(0x57) & 0x8000)
|
||||||
camera.move_camera_forward();
|
camera.move_camera_forward();
|
||||||
if (GetAsyncKeyState(VK_DOWN) & 0x8000)
|
if (GetAsyncKeyState(0x53) & 0x8000)
|
||||||
camera.move_camera_backward();
|
camera.move_camera_backward();
|
||||||
if (GetAsyncKeyState(VK_RIGHT) & 0x8000)
|
if (GetAsyncKeyState(0x44) & 0x8000)
|
||||||
camera.move_camera_right();
|
camera.move_camera_right();
|
||||||
if (GetAsyncKeyState(VK_LEFT) & 0x8000)
|
if (GetAsyncKeyState(0x41) & 0x8000)
|
||||||
camera.move_camera_left();
|
camera.move_camera_left();
|
||||||
if (GetAsyncKeyState(VK_SPACE) & 0x8000)
|
if (GetAsyncKeyState(VK_SPACE) & 0x8000)
|
||||||
camera.rise();
|
camera.rise();
|
||||||
|
|||||||
@@ -8,13 +8,13 @@
|
|||||||
#define VERTICAL_CAMERA_SPEED 0.1
|
#define VERTICAL_CAMERA_SPEED 0.1
|
||||||
#define VERTICAL_CAMERA_CLAMP_UP 90
|
#define VERTICAL_CAMERA_CLAMP_UP 90
|
||||||
#define VERTICAL_CAMERA_CLAMP_DOWN -90
|
#define VERTICAL_CAMERA_CLAMP_DOWN -90
|
||||||
#define NEAR_CLIP_PLANE 0
|
#define NEAR_CLIP_PLANE 0.3f
|
||||||
#define FAR_CLIP_PLANE 10
|
#define FAR_CLIP_PLANE 10.0f
|
||||||
#define FOV 30
|
#define FOV 30
|
||||||
#define CAMERA_MOVEMENT_SPEED 0.05f
|
#define CAMERA_MOVEMENT_SPEED 0.05f
|
||||||
#define DEFAULT_CAMERA_POS Vec3f(0, 0, 5)
|
#define DEFAULT_CAMERA_POS Vec3f(0, 0, 5)
|
||||||
#define DEFAULT_CAMERA_ROT Vec3f(0, 0, 0)
|
#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 white = TGAColor(255, 255, 255, 255);
|
||||||
const TGAColor red = TGAColor(255, 0, 0, 255);
|
const TGAColor red = TGAColor(255, 0, 0, 255);
|
||||||
|
|||||||
Reference in New Issue
Block a user