Quick commit of a broken setup that doesn't work.
This commit is contained in:
parent
22c2b78fca
commit
753df69b4c
129 changed files with 16095 additions and 0 deletions
70
27-instancing/src/camera.cpp
Normal file
70
27-instancing/src/camera.cpp
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
#include "camera.hpp"
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/type_ptr.hpp>
|
||||
|
||||
glm::mat4 Camera::look_at() {
|
||||
return glm::lookAt(position, position + front, up);
|
||||
}
|
||||
|
||||
void Camera::forward() {
|
||||
dirty = true;
|
||||
position += speed * front;
|
||||
}
|
||||
|
||||
void Camera::back() {
|
||||
dirty = true;
|
||||
position -= speed * front;
|
||||
}
|
||||
|
||||
void Camera::left() {
|
||||
dirty = true;
|
||||
position -= glm::normalize(glm::cross(front, up)) * speed;
|
||||
}
|
||||
|
||||
void Camera::right() {
|
||||
dirty = true;
|
||||
position += glm::normalize(glm::cross(front, up)) * speed;
|
||||
}
|
||||
|
||||
void Camera::update(float deltaTime) {
|
||||
speed = movement_speed * deltaTime;
|
||||
}
|
||||
|
||||
void Camera::mouse_move(double xpos, double ypos) {
|
||||
dirty = true;
|
||||
|
||||
if(firstMouse) {
|
||||
lastX = xpos;
|
||||
lastY = ypos;
|
||||
firstMouse = false;
|
||||
}
|
||||
|
||||
float xoffset = xpos - lastX;
|
||||
float yoffset = lastY - ypos;
|
||||
lastX = xpos;
|
||||
lastY = ypos;
|
||||
|
||||
const float sensitivity = 0.1f;
|
||||
xoffset *= sensitivity;
|
||||
yoffset *= sensitivity;
|
||||
|
||||
yaw += xoffset;
|
||||
pitch += yoffset;
|
||||
|
||||
if(pitch > 89.0f) pitch = 89.0f;
|
||||
if(pitch < -89.0f) pitch = -89.0f;
|
||||
|
||||
direction.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch));
|
||||
direction.y = sin(glm::radians(pitch));
|
||||
direction.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch));
|
||||
|
||||
front = glm::normalize(direction);
|
||||
}
|
||||
|
||||
void Camera::mouse_scroll(double xoffset, double yoffset) {
|
||||
dirty = true;
|
||||
fov -= (float)yoffset;
|
||||
|
||||
if(fov < 1.0f) fov = 1.0f;
|
||||
if(fov > 90.0f) fov = 90.0f;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue