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:
@@ -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(){
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user