diff --git a/flame.cc b/flame.cc index 1fafe2d..2512f74 100644 --- a/flame.cc +++ b/flame.cc @@ -24,13 +24,24 @@ Flame::Flame() { } void Flame::render(SharedShaderProgram shader, glm::mat4 viewProjectionMatrix, float time, - bool withColor) { + 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 = glm::scale(size * glm::vec3(1.1f)); + modelMatrix = skewMatrixX * skewMatrixZ * glm::scale(size * glm::vec3(1.1f)); } else { - modelMatrix = glm::scale(size); + modelMatrix = skewMatrixX * skewMatrixZ * glm::scale(size); } glm::mat4 modelViewProjectionMatrix = viewProjectionMatrix * modelMatrix; shader->setUniform("modelViewProjectionMatrix", modelViewProjectionMatrix); diff --git a/flame.hh b/flame.hh index b9372a3..5649774 100644 --- a/flame.hh +++ b/flame.hh @@ -9,7 +9,7 @@ class Flame : public Entity { Flame(glm::vec3 position, glm::vec3 color, glm::vec3 size); Flame(); void render(SharedShaderProgram shader, glm::mat4 viewProjectionMatrix, - float time, bool withColor); + float time, bool withColor, glm::vec2 skewing); private: glm::vec3 color; glm::vec3 size; diff --git a/graphics.cc b/graphics.cc index e21ea4b..3ffd1a7 100644 --- a/graphics.cc +++ b/graphics.cc @@ -282,6 +282,9 @@ void Graphics::render(double time) framebuffer_light->bind(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + //wind + glm::vec2 wind = glm::vec2(-0.4f, 0.3f); + //set view and projection matrix glm::mat4 lightingViewProjectionMatrix = glm::perspective(1.571f, (float)windowSize.x/(float)windowSize.y, 0.1f, farPlane) * buildViewMatrix(level); @@ -332,7 +335,7 @@ void Graphics::render(double time) // set Material Parameters lightingShader->setUniform("ambientColor", level->getAmbientLight()); lightingShader->setUniform("camera", level->getPhysics()->getCameraPosition()); - lightingShader->setUniform("movement", glm::vec2(-0.3f, -0.4f)); + lightingShader->setUniform("movement", wind); lightingShader->setUniform("time", (float) time); // render the level @@ -346,7 +349,7 @@ void Graphics::render(double time) // draw with colors for(unsigned int i = 0; irender(flameShader, lightingViewProjectionMatrix, float(time), true); + closestFlames.at(i)->render(flameShader, lightingViewProjectionMatrix, float(time), true, wind); } glDisable(GL_CULL_FACE); @@ -358,7 +361,7 @@ void Graphics::render(double time) glClear(GL_STENCIL_BUFFER_BIT);//clear stencil buffer for(unsigned int i = 0; irender(flameShader, lightingViewProjectionMatrix, float(time), false); + closestFlames.at(i)->render(flameShader, lightingViewProjectionMatrix, float(time), false, wind); } glStencilFunc(GL_EQUAL, 1, 0xFF); //Pass test if stencil value is 1