From 808f4deb62968d30a7ede2fca51adfbc33bad351 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Mon, 9 Mar 2015 10:32:25 +0100 Subject: [PATCH] Removing skewing of flame. Rotate looks correct now. --- data/shader/flame.gsh | 4 ++-- data/shader/flame.vsh | 5 ++++- flame.cc | 15 ++------------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/data/shader/flame.gsh b/data/shader/flame.gsh index 11723c1..eddb9f6 100644 --- a/data/shader/flame.gsh +++ b/data/shader/flame.gsh @@ -17,7 +17,7 @@ const float cos_p1_1 = 0.35; const float cos_p2_1 = 2.0; const float ex_p1_1 = -0.193; const float ex_p2_1 = 2.9426; -const float begin_1 = -0.785398; +const float begin_1 = -0.8; const float end_1 = 1.5; const float transition_point_2 = 0.600598; @@ -25,7 +25,7 @@ const float cos_p1_2 = 0.3; const float cos_p2_2 = 1.7; const float ex_p1_2 = -0.19; const float ex_p2_2 = 2.762; -const float begin_2 = -0.923998; +const float begin_2 = -0.8; const float end_2 = 2; float flickerFunction() { diff --git a/data/shader/flame.vsh b/data/shader/flame.vsh index 6d645f2..ec98860 100644 --- a/data/shader/flame.vsh +++ b/data/shader/flame.vsh @@ -8,7 +8,10 @@ in vec3 aColor; out vec3 Color; +const float end = 0.8; + void main () { Color = aColor; - gl_Position = viewProjectionMatrix * vec4(aPosition, 1.0); + vec3 position = aPosition + vec3(-sin(skew.y)*end, 0.0, sin(skew.x)*end); + gl_Position = viewProjectionMatrix * vec4(position, 1.0); } diff --git a/flame.cc b/flame.cc index 33183ac..4c8b6ac 100644 --- a/flame.cc +++ b/flame.cc @@ -26,24 +26,13 @@ Flame::Flame() { void Flame::render(SharedShaderProgram shader, glm::mat4 viewProjectionMatrix, float time, bool withColor, glm::vec2 skewing) { glm::mat4 modelMatrix; - // matrix is column major - glm::mat4 skewMatrixX = - glm::mat4(1.0f, tan(skewing.x), 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f); - glm::mat4 skewMatrixZ = - glm::mat4(1.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 1.0f, 0.0f, 0.0f, - 0.0f, tan(skewing.y), 1.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f); if (!withColor) { - modelMatrix = skewMatrixX * skewMatrixZ * glm::scale(size * glm::vec3(1.1f)) + modelMatrix = glm::scale(size * glm::vec3(1.1f)) * glm::rotate(skewing.x, glm::vec3(1.0f, 0.0f, 0.0f)) * glm::rotate(skewing.y, glm::vec3(0.0f, 0.0f, 1.0f)); } else { - modelMatrix = skewMatrixX * skewMatrixZ * glm::scale(size) + modelMatrix = glm::scale(size) * glm::rotate(skewing.x, glm::vec3(1.0f, 0.0f, 0.0f)) * glm::rotate(skewing.y, glm::vec3(0.0f, 0.0f, 1.0f)); }