void sig::Camera2D::ApplyTransformation(Window *w) { if (w == nullptr) { return; } m_origin = Vector2(w->GetWidth() / 2.0f, w->GetHeight() / 2.0f); m_scale = Vector2(m_zoom); m_size = Vector2(1); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, w->GetWidth(), w->GetHeight(), 0, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glMultMatrixf(&GetCameraMatrix()(0, 0)); }
// Movement void FPSDebugCamera::Move(float _delta, const glm::vec3& _move) { // Check if we are not moving at all if (_move.x == 0 && _move.y == 0 && _move.z == 0) return; // Get the current matrix GetCameraMatrix(); // Get the facing vectors from the matrix glm::vec3 x(transform[0].x, transform[1].x, transform[2].x); glm::vec3 y(transform[0].y, transform[1].y, transform[2].y); glm::vec3 z(transform[0].z, transform[1].z, transform[2].z); // Get the translation to apply glm::vec3 translation; translation += x * _move.x; translation.y += _move.y; // Always go up or down globally translation += z * _move.z; // Apply it position += glm::normalize(translation) * speed * _delta; }
void Pipeline::BuildViewProjection() { this->mVP = GetProjectionMatrix() * GetCameraMatrix(); }
void Pipeline::BuildViewOrthographic() { this->mVO = GetOrthographicMatrix() * GetCameraMatrix(); }
Matrix44 GetCameraMatrix() const { Matrix44 dest; GetCameraMatrix(dest); return dest; }