changes to camera
This commit is contained in:
@@ -18,13 +18,13 @@ Camera::Camera(
|
||||
glm::vec3 world_up,
|
||||
float pitch_deg,
|
||||
float yaw_deg)
|
||||
: move_speed { move_speed }
|
||||
: pos { position }
|
||||
, move_speed { move_speed }
|
||||
, mouse_sensitivity { mouse_sensitivity }
|
||||
, pitch_min { pitch_min }
|
||||
, pitch_max { pitch_max }
|
||||
, fov_min { fov_min }
|
||||
, fov_max { fov_max }
|
||||
, pos { position }
|
||||
, front {}
|
||||
, up { up }
|
||||
, right {}
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
DOWN
|
||||
};
|
||||
|
||||
glm::vec3 pos;
|
||||
float move_speed;
|
||||
float mouse_sensitivity;
|
||||
float pitch_min;
|
||||
@@ -50,7 +51,6 @@ public:
|
||||
void process_mouse_scroll(float offset_y);
|
||||
|
||||
private:
|
||||
glm::vec3 pos;
|
||||
glm::vec3 front;
|
||||
glm::vec3 up;
|
||||
glm::vec3 right;
|
||||
|
||||
36
src/main.cpp
36
src/main.cpp
@@ -34,12 +34,26 @@ Settings settings {};
|
||||
|
||||
double delta {};
|
||||
|
||||
static const struct {
|
||||
glm::vec3 pos;
|
||||
float fov_deg;
|
||||
float fov_max;
|
||||
float move_speed;
|
||||
float mouse_sensitivity;
|
||||
} camera_defaults = {
|
||||
.pos = glm::vec3 { 0.0f, 0.0f, 3.0f },
|
||||
.fov_deg = 70.0f,
|
||||
.fov_max = 70.0f,
|
||||
.move_speed = 1.0f,
|
||||
.mouse_sensitivity = 0.1f
|
||||
};
|
||||
|
||||
Camera camera {
|
||||
glm::vec3 { 0.0f, 0.0f, 3.0f },
|
||||
70.0f,
|
||||
70.0f,
|
||||
1.0f,
|
||||
0.1f
|
||||
camera_defaults.pos,
|
||||
camera_defaults.fov_deg,
|
||||
camera_defaults.fov_max,
|
||||
camera_defaults.move_speed,
|
||||
camera_defaults.mouse_sensitivity
|
||||
};
|
||||
|
||||
// TODO: fps limiter is off by ~4 for some reason at 120-144 fps range.
|
||||
@@ -109,6 +123,10 @@ void process_keyboard_input(GLFWwindow* window) {
|
||||
} else if (glfwGetKey(window, GLFW_KEY_E) == GLFW_PRESS) {
|
||||
camera.move_to_direction(Camera::Direction::DOWN, delta);
|
||||
}
|
||||
|
||||
if (glfwGetKey(window, GLFW_KEY_R) == GLFW_PRESS) {
|
||||
camera.pos = camera_defaults.pos;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
@@ -203,14 +221,14 @@ int main() {
|
||||
plane.draw();
|
||||
|
||||
shader->set_vec4("color", { 0.0f, 0.0f, 1.0f, 1.0f });
|
||||
square.rotation.z += 45.0f * delta;
|
||||
square.pos.x = std::cos(current_time);
|
||||
square.pos.y = std::sin(current_time);
|
||||
square.rotation.z = glm::degrees(current_time) + 45.0f;
|
||||
square.draw();
|
||||
|
||||
shader->set_vec4("color", { 1.0f, 1.0f, 1.0f, 1.0f });
|
||||
cube.rotation.y += 45.0f * delta;
|
||||
cube.draw();
|
||||
// shader->set_vec4("color", { 1.0f, 1.0f, 1.0f, 1.0f });
|
||||
// cube.rotation.y += 45.0f * delta;
|
||||
// cube.draw();
|
||||
|
||||
const double time_since_last_frame { glfwGetTime() - last_frame_time };
|
||||
if (time_since_last_frame < fps_lock) {
|
||||
|
||||
Reference in New Issue
Block a user