Removing skewing of flame. Rotate looks correct now.

This commit is contained in:
Faerbit 2015-03-09 10:32:25 +01:00
parent 5599a39eff
commit 9609c50335
3 changed files with 8 additions and 16 deletions

View File

@ -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() {

View File

@ -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);
}

View File

@ -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<float>(size * glm::vec3(1.1f))
modelMatrix = glm::scale<float>(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<float>(size)
modelMatrix = glm::scale<float>(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));
}