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