All changes made for 10th part of tutorial

voxel_engine.cpp - changed structure, added character controls, physics
almost all files are modified (including shaders)
+ new source directory - physics
This commit is contained in:
MihailRis
2021-08-04 01:45:04 +03:00
committed by GitHub
parent e1cdcf01e9
commit 1a00a11917
22 changed files with 587 additions and 149 deletions
+9 -2
View File
@@ -10,7 +10,7 @@
#include <glm/ext.hpp>
Camera::Camera(vec3 position, float fov) : position(position), fov(fov), rotation(1.0f) {
Camera::Camera(vec3 position, float fov) : position(position), fov(fov), zoom(1.0f), rotation(1.0f) {
updateVectors();
}
@@ -18,6 +18,13 @@ void Camera::updateVectors(){
front = vec3(rotation * vec4(0,0,-1,1));
right = vec3(rotation * vec4(1,0,0,1));
up = vec3(rotation * vec4(0,1,0,1));
dir = vec3(rotation * vec4(0,0,-1,1));
dir.y = 0;
float len = length(dir);
if (len > 0.0f){
dir.x /= len;
dir.z /= len;
}
}
void Camera::rotate(float x, float y, float z){
@@ -30,7 +37,7 @@ void Camera::rotate(float x, float y, float z){
mat4 Camera::getProjection(){
float aspect = (float)Window::width / (float)Window::height;
return glm::perspective(fov, aspect, 0.1f, 1500.0f);
return glm::perspective(fov*zoom, aspect, 0.05f, 1500.0f);
}
mat4 Camera::getView(){
+2
View File
@@ -17,9 +17,11 @@ public:
vec3 front;
vec3 up;
vec3 right;
vec3 dir;
vec3 position;
float fov;
float zoom;
mat4 rotation;
Camera(vec3 position, float fov);
+6
View File
@@ -30,6 +30,12 @@ int Window::initialize(int width, int height, const char* title){
}
glViewport(0,0, width, height);
glClearColor(0.0f,0.0f,0.0f,1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Window::width = width;
Window::height = height;
return 0;