fixed translation
This commit is contained in:
parent
2242adc568
commit
ce747f283a
|
@ -71,7 +71,7 @@ void Transformable::Scale(const glm::vec3& factor)
|
||||||
void Transformable::CalculateTransformationMatrix()
|
void Transformable::CalculateTransformationMatrix()
|
||||||
{
|
{
|
||||||
transformation = glm::mat4(1.0f);
|
transformation = glm::mat4(1.0f);
|
||||||
transformation = glm::translate(transformation, position);
|
transformation = glm::translate(transformation, -position);
|
||||||
transformation *= glm::toMat4(orientation);
|
transformation *= glm::toMat4(orientation);
|
||||||
transformation = glm::scale(transformation, scale);
|
transformation = glm::scale(transformation, scale);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,7 @@ void Application::Init(int width, int height, const std::string& title)
|
||||||
|
|
||||||
float aspectRatio = (float)windowWidth / (float)windowHeight;
|
float aspectRatio = (float)windowWidth / (float)windowHeight;
|
||||||
camera = Camera(100.0f, aspectRatio);
|
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);
|
orthoCam = OrthogonalCamera(-3.0f * aspectRatio, 3.0f * aspectRatio, -3.0f, 3.0f);
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ Grid::Grid(const glm::vec2& size, unsigned int linesAlongWidth, unsigned int lin
|
||||||
|
|
||||||
void Grid::InitializeShader(const CameraBase& camera) const
|
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));
|
shader->SetUniform("gridColor", glm::vec4(0.5f));
|
||||||
else
|
else
|
||||||
shader->SetUniform("gridColor", glm::vec4(0.0f));
|
shader->SetUniform("gridColor", glm::vec4(0.0f));
|
||||||
|
|
|
@ -10,4 +10,7 @@ public:
|
||||||
Grid(const glm::vec2& size, unsigned int linesAlongWidth, unsigned int linesAlongHeight);
|
Grid(const glm::vec2& size, unsigned int linesAlongWidth, unsigned int linesAlongHeight);
|
||||||
|
|
||||||
void InitializeShader(const CameraBase& camera) const override;
|
void InitializeShader(const CameraBase& camera) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
glm::vec3 normal = glm::vec3(0.0f, 0.0f, 1.0f);
|
||||||
};
|
};
|
Loading…
Reference in a new issue