diff --git a/backend/src/Transformable.cpp b/backend/src/Transformable.cpp index 5f80def..ae1a4d4 100644 --- a/backend/src/Transformable.cpp +++ b/backend/src/Transformable.cpp @@ -71,7 +71,7 @@ void Transformable::Scale(const glm::vec3& factor) void Transformable::CalculateTransformationMatrix() { transformation = glm::mat4(1.0f); - transformation = glm::translate(transformation, position); + transformation = glm::translate(transformation, -position); transformation *= glm::toMat4(orientation); transformation = glm::scale(transformation, scale); } diff --git a/src/Application.cpp b/src/Application.cpp index 1095f12..e4a63ec 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -123,7 +123,7 @@ void Application::Init(int width, int height, const std::string& title) float aspectRatio = (float)windowWidth / (float)windowHeight; camera = Camera(100.0f, aspectRatio); - camera.Move(glm::vec3(0.0f, 0.0f, -4.0f)); + camera.Move(glm::vec3(0.0f, 0.0f, 4.0f)); orthoCam = OrthogonalCamera(-3.0f * aspectRatio, 3.0f * aspectRatio, -3.0f, 3.0f); diff --git a/src/Grid.cpp b/src/Grid.cpp index 0631bd6..4018f2a 100644 --- a/src/Grid.cpp +++ b/src/Grid.cpp @@ -91,7 +91,7 @@ Grid::Grid(const glm::vec2& size, unsigned int linesAlongWidth, unsigned int lin void Grid::InitializeShader(const CameraBase& camera) const { - if(glm::dot(glm::rotate(camera.GetQuaternion(), glm::vec3(0.0f, 0.0f, 1.0f)), glm::rotate(GetQuaternion(), glm::vec3(0.0f, 0.0f, 1.0f))) > 0) + if(glm::dot(GetPosition() - camera.GetPosition(), glm::rotate(glm::inverse(GetQuaternion()), normal)) < 0.0f) shader->SetUniform("gridColor", glm::vec4(0.5f)); else shader->SetUniform("gridColor", glm::vec4(0.0f)); diff --git a/src/Grid.hpp b/src/Grid.hpp index 6276704..f0fc37e 100644 --- a/src/Grid.hpp +++ b/src/Grid.hpp @@ -10,4 +10,7 @@ public: Grid(const glm::vec2& size, unsigned int linesAlongWidth, unsigned int linesAlongHeight); void InitializeShader(const CameraBase& camera) const override; + +private: + glm::vec3 normal = glm::vec3(0.0f, 0.0f, 1.0f); }; \ No newline at end of file