void Camera::RotUp(float deltaTime) { if(m_rot.x + deltaTime*rotspeed < X_LIMIT) m_rot.x += deltaTime*rotspeed; else m_rot.x = X_LIMIT; calculateViewMatrix(); }
void Camera::RotDown(float deltaTime) { if(m_rot.x - deltaTime*rotspeed > -X_LIMIT) m_rot.x += -deltaTime*rotspeed; else m_rot.x = -X_LIMIT; calculateViewMatrix(); }
void Camera::moveUp(float deltaTime) { Vector4 movelocal = Vector4(0.f, deltaTime*movespeed, 0.f, 1.f); calculateWorldMatrix(); Vector4 moveworld = movelocal * m_world; m_pos = Vector3(moveworld.x, moveworld.y, moveworld.z); calculateViewMatrix(); }
void Camera::startSync() { if (viewUpdated_) { temporaryViewMatrix_ = calculateViewMatrix(); syncView_ = true; viewUpdated_ = false; } if (projectionUpdated_) { temporaryProjMatrix_ = getProjectionMatrix(); syncProjection_ = true; projectionUpdated_ = false; } }
Camera::Camera(glm::vec3 sceneDimensions): _angX(0), _angY(0), _locked(true), _interpolate(false), _attached(nullptr), _radius(2.0f) { _model = glm::scale(glm::mat4(), glm::vec3(2 / sceneDimensions[0], 2 / sceneDimensions[1], 2 / sceneDimensions[2])); _vup = glm::vec3(0, 1, 0); _dir = glm::vec3(-1, -1, 0); // _vrp = (0, 0, 0) = (1, 1, 0) + (-1, -1, 0) _obs = glm::vec3(1, 1, 0); _aspect = 4.0f/ 3.0f; calculateViewMatrix(); calculateProjectionMatrix(); }
void Camera::RotRight(float deltaTime) { m_rot.y += -deltaTime*rotspeed; calculateViewMatrix(); }
glm::mat4 Camera::getViewMatrix(){ return calculateViewMatrix(); }