diff --git a/data/levels/Compositions.xml b/data/levels/Compositions.xml
index fd1365f..744df8e 100644
--- a/data/levels/Compositions.xml
+++ b/data/levels/Compositions.xml
@@ -452,7 +452,7 @@
0.0
0.0
1.5
- 1.0
+ 3.0
diff --git a/data/levels/Level1.xml b/data/levels/Level1.xml
index 80e3368..76335e2 100644
--- a/data/levels/Level1.xml
+++ b/data/levels/Level1.xml
@@ -715,6 +715,7 @@
openSecondDoor1
+ false
-6.5
22.0
51.5
@@ -728,6 +729,22 @@
8
0
+
+ openSecondDoor1Undo
+ true
+ -6.5
+ 22.0
+ 51.5
+ -
+ -
+ 0.2
+ false
+ 0
+ openSecondDoor1.lua
+ 1
+ 8
+ 0
+
@@ -751,6 +768,7 @@
openSecondDoor3
+ false
-6.5
22.0
29.5
@@ -764,6 +782,22 @@
8
0
+
+ openSecondDoor3Undo
+ true
+ -6.5
+ 22.0
+ 29.5
+ -
+ -
+ 0.2
+ false
+ 0
+ openSecondDoor3.lua
+ 1
+ 8
+ 0
+
@@ -2411,6 +2445,7 @@
openSecondDoor4
+ false
-53.5
22.0
51.5
@@ -2424,6 +2459,22 @@
8
0
+
+ openSecondDoor4Undo
+ true
+ -53.5
+ 22.0
+ 51.5
+ -
+ -
+ 0.2
+ false
+ 0
+ openSecondDoor4.lua
+ 1
+ 8
+ 0
+
@@ -2476,6 +2527,7 @@
openSecondDoor2
+ false
-53.5
22.0
29.5
@@ -2489,6 +2541,22 @@
8
0
+
+ openSecondDoor2Undo
+ true
+ -53.5
+ 22.0
+ 29.5
+ -
+ -
+ 0.2
+ false
+ 0
+ openSecondDoor2.lua
+ 1
+ 8
+ 0
+
@@ -3672,6 +3740,7 @@
openThirdDoor
+ false
-161.5
21.7
67.5
@@ -3687,6 +3756,7 @@
openThirdDoorUndo
+ true
-161.5
21.7
67.5
@@ -3695,7 +3765,7 @@
0.2
false
0
- openThirdDoorUndo.lua
+ openThirdDoor.lua
0
178
0
@@ -6159,6 +6229,7 @@
openFirstDoor
+ false
17.5
21.8
159.5
@@ -6174,6 +6245,7 @@
openFirstDoorUndo
+ true
17.5
21.8
159.5
@@ -6182,7 +6254,7 @@
0.2
false
0
- openFirstDoorUndo.lua
+ openFirstDoor.lua
1
94
0
diff --git a/data/levels/scripts/openFirstDoor.lua b/data/levels/scripts/openFirstDoor.lua
index 0dceaa4..001f8d6 100644
--- a/data/levels/scripts/openFirstDoor.lua
+++ b/data/levels/scripts/openFirstDoor.lua
@@ -2,6 +2,10 @@ local global = require( "global" )
if(global.triggeredOpenFirstDoor == nil) then
global.triggeredOpenFirstDoor = false
end
+if(global.triggeredOpenFirstDoorUndo == nil) then
+ global.triggeredOpenFirstDoorUndo = true
+end
+
function trigger(objectToChange)
if(global.triggeredOpenFirstDoor == false) then
if(not level) then
@@ -21,3 +25,23 @@ function trigger(objectToChange)
print("openFirstDoor")
end
end
+
+function triggerUndo(objectToChange)
+ if(global.triggeredOpenFirstDoorUndo == false) then
+ if(not level) then
+ print("No level found in Lua!")
+ return
+ end
+
+ local strength = 100
+ local xPos = 17.5
+ local yPos = 25
+ local zPos = 81.5
+ level:moveObject(objectToChange, strength, xPos, yPos, zPos)
+
+ global.triggeredOpenFirstDoor = false
+
+ global.triggeredOpenFirstDoorUndo = true
+ print("openFirstDoorUndo")
+ end
+end
diff --git a/data/levels/scripts/openFirstDoorUndo.lua b/data/levels/scripts/openFirstDoorUndo.lua
deleted file mode 100644
index e7538da..0000000
--- a/data/levels/scripts/openFirstDoorUndo.lua
+++ /dev/null
@@ -1,23 +0,0 @@
-local global = require( "global" )
-if(global.triggeredOpenFirstDoorUndo == nil) then
- global.triggeredOpenFirstDoorUndo = true
-end
-function trigger(objectToChange)
- if(global.triggeredOpenFirstDoorUndo == false) then
- if(not level) then
- print("No level found in Lua!")
- return
- end
-
- local strength = 100
- local xPos = 17.5
- local yPos = 25
- local zPos = 81.5
- level:moveObject(objectToChange, strength, xPos, yPos, zPos)
-
- global.triggeredOpenFirstDoor = false
-
- global.triggeredOpenFirstDoorUndo = true
- print("openFirstDoorUndo")
- end
-end
diff --git a/data/levels/scripts/openSecondDoor1.lua b/data/levels/scripts/openSecondDoor1.lua
index 3a38643..7baccc5 100644
--- a/data/levels/scripts/openSecondDoor1.lua
+++ b/data/levels/scripts/openSecondDoor1.lua
@@ -2,6 +2,10 @@ local global = require( "global" )
if(global.triggeredOpenSecondDoor1 == nil) then
global.triggeredOpenSecondDoor1 = false
end
+if(global.triggeredOpenSecondDoor1Undo == nil) then
+ global.triggeredOpenSecondDoor1Undo = true
+end
+
function trigger(objectToChange)
if(global.triggeredOpenSecondDoor1 == false) then
if(not level) then
@@ -25,14 +29,28 @@ function trigger(objectToChange)
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
- global.openSecondDoorCounter = 0
- global.triggeredOpenSecondDoor1 = false
- global.triggeredOpenSecondDoor2 = false
- global.triggeredOpenSecondDoor3 = false
- global.triggeredOpenSecondDoor4 = false
+ global.triggeredOpenSecondDoor1Undo = false
end
end
print("openSecondDoor1")
end
end
+
+function triggerUndo(objectToChange)
+ if(global.triggeredOpenSecondDoor1Undo == false) then
+ if(not level) then
+ print("No level found in Lua!")
+ return
+ end
+
+ global.openSecondDoorCounter = 0
+ global.triggeredOpenSecondDoor1 = false
+ global.triggeredOpenSecondDoor2 = false
+ global.triggeredOpenSecondDoor3 = false
+ global.triggeredOpenSecondDoor4 = false
+
+ global.triggeredOpenSecondDoor1Undo = true
+ print("openSecondDoor1Undo")
+ end
+end
diff --git a/data/levels/scripts/openSecondDoor2.lua b/data/levels/scripts/openSecondDoor2.lua
index b2bbdb5..f1de38e 100644
--- a/data/levels/scripts/openSecondDoor2.lua
+++ b/data/levels/scripts/openSecondDoor2.lua
@@ -2,6 +2,10 @@ local global = require( "global" )
if(global.triggeredOpenSecondDoor2 == nil) then
global.triggeredOpenSecondDoor2 = false
end
+if(global.triggeredOpenSecondDoor2Undo == nil) then
+ global.triggeredOpenSecondDoor2Undo = true
+end
+
function trigger(objectToChange)
if(global.triggeredOpenSecondDoor2 == false) then
if(not level) then
@@ -25,14 +29,28 @@ function trigger(objectToChange)
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
- global.openSecondDoorCounter = 0
- global.triggeredOpenSecondDoor1 = false
- global.triggeredOpenSecondDoor2 = false
- global.triggeredOpenSecondDoor3 = false
- global.triggeredOpenSecondDoor4 = false
+ global.triggeredOpenSecondDoor2Undo = false
end
end
print("openSecondDoor2")
end
end
+
+function triggerUndo(objectToChange)
+ if(global.triggeredOpenSecondDoor2Undo == false) then
+ if(not level) then
+ print("No level found in Lua!")
+ return
+ end
+
+ global.openSecondDoorCounter = 0
+ global.triggeredOpenSecondDoor1 = false
+ global.triggeredOpenSecondDoor2 = false
+ global.triggeredOpenSecondDoor3 = false
+ global.triggeredOpenSecondDoor4 = false
+
+ global.triggeredOpenSecondDoor2Undo = true
+ print("openSecondDoor2Undo")
+ end
+end
diff --git a/data/levels/scripts/openSecondDoor3.lua b/data/levels/scripts/openSecondDoor3.lua
index 985b72d..0da7adf 100644
--- a/data/levels/scripts/openSecondDoor3.lua
+++ b/data/levels/scripts/openSecondDoor3.lua
@@ -2,6 +2,10 @@ local global = require( "global" )
if(global.triggeredOpenSecondDoor3 == nil) then
global.triggeredOpenSecondDoor3 = false
end
+if(global.triggeredOpenSecondDoor3Undo == nil) then
+ global.triggeredOpenSecondDoor3Undo = true
+end
+
function trigger(objectToChange)
if(global.triggeredOpenSecondDoor3 == false) then
if(not level) then
@@ -25,14 +29,28 @@ function trigger(objectToChange)
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
- global.openSecondDoorCounter = 0
- global.triggeredOpenSecondDoor1 = false
- global.triggeredOpenSecondDoor2 = false
- global.triggeredOpenSecondDoor3 = false
- global.triggeredOpenSecondDoor4 = false
+ global.triggeredOpenSecondDoor3Undo = false
end
end
print("openSecondDoor3")
end
end
+
+function triggerUndo(objectToChange)
+ if(global.triggeredOpenSecondDoor3Undo == false) then
+ if(not level) then
+ print("No level found in Lua!")
+ return
+ end
+
+ global.openSecondDoorCounter = 0
+ global.triggeredOpenSecondDoor1 = false
+ global.triggeredOpenSecondDoor2 = false
+ global.triggeredOpenSecondDoor3 = false
+ global.triggeredOpenSecondDoor4 = false
+
+ global.triggeredOpenSecondDoor3Undo = true
+ print("openSecondDoor3Undo")
+ end
+end
diff --git a/data/levels/scripts/openSecondDoor4.lua b/data/levels/scripts/openSecondDoor4.lua
index f3fdfbb..9c2c98b 100644
--- a/data/levels/scripts/openSecondDoor4.lua
+++ b/data/levels/scripts/openSecondDoor4.lua
@@ -2,6 +2,10 @@ local global = require( "global" )
if(global.triggeredOpenSecondDoor4 == nil) then
global.triggeredOpenSecondDoor4 = false
end
+if(global.triggeredOpenSecondDoor4Undo == nil) then
+ global.triggeredOpenSecondDoor4Undo = true
+end
+
function trigger(objectToChange)
if(global.triggeredOpenSecondDoor4 == false) then
if(not level) then
@@ -13,7 +17,7 @@ function trigger(objectToChange)
global.openSecondDoorCounter = 0
end
if(global.openSecondDoorCounter == 3) then
- global.openSecondDoorCounter = global.openSecondDoorCounter + 1
+ global.openSecondDoorCounter = global.openSecondDoorCounter + 1
end
global.triggeredOpenSecondDoor4 = true
@@ -25,14 +29,28 @@ function trigger(objectToChange)
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
- global.openSecondDoorCounter = 0
- global.triggeredOpenSecondDoor1 = false
- global.triggeredOpenSecondDoor2 = false
- global.triggeredOpenSecondDoor3 = false
- global.triggeredOpenSecondDoor4 = false
+ global.triggeredOpenSecondDoor4Undo = false
end
end
print("openSecondDoor4")
end
end
+
+function triggerUndo(objectToChange)
+ if(global.triggeredOpenSecondDoor4Undo == false) then
+ if(not level) then
+ print("No level found in Lua!")
+ return
+ end
+
+ global.openSecondDoorCounter = 0
+ global.triggeredOpenSecondDoor1 = false
+ global.triggeredOpenSecondDoor2 = false
+ global.triggeredOpenSecondDoor3 = false
+ global.triggeredOpenSecondDoor4 = false
+
+ global.triggeredOpenSecondDoor4Undo = true
+ print("openSecondDoor4Undo")
+ end
+end
diff --git a/data/levels/scripts/openThirdDoor.lua b/data/levels/scripts/openThirdDoor.lua
index e1776de..69f3120 100644
--- a/data/levels/scripts/openThirdDoor.lua
+++ b/data/levels/scripts/openThirdDoor.lua
@@ -2,6 +2,10 @@ local global = require( "global" )
if(global.triggeredOpenThirdDoor == nil) then
global.triggeredOpenThirdDoor = false
end
+if(global.triggeredOpenThirdDoorUndo == nil) then
+ global.triggeredOpenThirdDoorUndo = true
+end
+
function trigger(objectToChange)
if(global.triggeredOpenThirdDoor == false) then
if(not level) then
@@ -21,3 +25,23 @@ function trigger(objectToChange)
print("openThirdDoor")
end
end
+
+function triggerUndo(objectToChange)
+ if(global.triggeredOpenThirdDoorUndo == false) then
+ if(not level) then
+ print("No level found in Lua!")
+ return
+ end
+
+ local strength = 100
+ local xPos = -172.5
+ local yPos = 25
+ local zPos = 58.5
+ level:moveObject(objectToChange, strength, xPos, yPos, zPos)
+
+ global.triggeredOpenThirdDoor = false
+
+ global.triggeredOpenThirdDoorUndo = true
+ print("openThirdDoorUndo")
+ end
+end
diff --git a/data/levels/scripts/openThirdDoorUndo.lua b/data/levels/scripts/openThirdDoorUndo.lua
deleted file mode 100644
index f183e34..0000000
--- a/data/levels/scripts/openThirdDoorUndo.lua
+++ /dev/null
@@ -1,23 +0,0 @@
-local global = require( "global" )
-if(global.triggeredOpenThirdDoorUndo == nil) then
- global.triggeredOpenThirdDoorUndo = true
-end
-function trigger(objectToChange)
- if(global.triggeredOpenThirdDoorUndo == false) then
- if(not level) then
- print("No level found in Lua!")
- return
- end
-
- local strength = 100
- local xPos = -172.5
- local yPos = 25
- local zPos = 58.5
- level:moveObject(objectToChange, strength, xPos, yPos, zPos)
-
- global.triggeredOpenThirdDoor = false
-
- global.triggeredOpenThirdDoorUndo = true
- print("openThirdDoorUndo")
- end
-end
diff --git a/data/shader/flame.fsh b/data/shader/flame.fsh
index 0bf4756..7a4127d 100644
--- a/data/shader/flame.fsh
+++ b/data/shader/flame.fsh
@@ -4,7 +4,14 @@ in vec3 fColor;
out vec4 oColor;
+uniform bool withColor;
+
void main() {
- oColor = vec4(fColor, 1.0);
+ if (withColor) {
+ oColor = vec4(fColor, 0.6);
+ }
+ else {
+ oColor = vec4(0.0, 0.0, 0.0, 0.0);
+ }
}
diff --git a/data/shader/flame.gsh b/data/shader/flame.gsh
index 6fa8e4d..0fda82a 100644
--- a/data/shader/flame.gsh
+++ b/data/shader/flame.gsh
@@ -1,6 +1,6 @@
#version 150
-uniform mat4 viewProjectionMatrix;
+uniform mat4 modelViewProjectionMatrix;
uniform float time;
uniform bool bottom;
uniform bool left;
@@ -62,19 +62,19 @@ void main() {
float rightAngle = PI * 2.0 / resolution * (j+1);
vec4 offset = vec4(cos(rightAngle) * downRadius, i, -sin(rightAngle) * downRadius, 0.0);
- gl_Position = gl_in[0].gl_Position + viewProjectionMatrix * offset;
+ gl_Position = gl_in[0].gl_Position + modelViewProjectionMatrix * offset;
EmitVertex();
offset = vec4(cos(rightAngle) * upRadius, i + step, -sin(rightAngle) * upRadius, 0.0);
- gl_Position = gl_in[0].gl_Position + viewProjectionMatrix * offset;
+ gl_Position = gl_in[0].gl_Position + modelViewProjectionMatrix * offset;
EmitVertex();
offset = vec4(cos(leftAngle) * downRadius, i, -sin(leftAngle) * downRadius, 0.0);
- gl_Position = gl_in[0].gl_Position + viewProjectionMatrix * offset;
+ gl_Position = gl_in[0].gl_Position + modelViewProjectionMatrix * offset;
EmitVertex();
offset = vec4(cos(leftAngle) * upRadius, i + step, -sin(leftAngle) * upRadius, 0.0);
- gl_Position = gl_in[0].gl_Position + viewProjectionMatrix * offset;
+ gl_Position = gl_in[0].gl_Position + modelViewProjectionMatrix * offset;
EmitVertex();
EndPrimitive();
diff --git a/data/shader/flame_post.fsh b/data/shader/flame_post.fsh
index 6518b0d..ea0bc2a 100644
--- a/data/shader/flame_post.fsh
+++ b/data/shader/flame_post.fsh
@@ -2,7 +2,6 @@
in vec2 vTexCoord;
-uniform sampler2D flame_fbo;
uniform sampler2D light_fbo;
uniform int windowSizeX;
uniform int windowSizeY;
@@ -12,24 +11,11 @@ out vec4 oColor;
const float lookup_offset = 4.0;
void main() {
- vec4 color = texture(flame_fbo, vTexCoord).rgba;
- if (color == vec4(0.0, 0.0, 0.0, 1.0)) {
- oColor = texture(light_fbo, vTexCoord).rgba;
- }
- else {
- vec4 sum = vec4(0.0);
- for(float i = -lookup_offset; i<=lookup_offset; i+=1.0) {
- for(float j = -lookup_offset; j<=lookup_offset; j+=1.0) {
- vec4 flame_pixel = texture(flame_fbo, vec2(vTexCoord.x + i * 1.0/(windowSizeX/2.0), vTexCoord.y + j * 1.0/(windowSizeY/2.0)))/pow(lookup_offset*2+1, 2.0);
- vec4 light_pixel = texture(light_fbo, vec2(vTexCoord.x + i * 1.0/(windowSizeX/2.0), vTexCoord.y + j * 1.0/(windowSizeY/2.0)))/pow(lookup_offset*2+1, 2.0);
- if (flame_pixel == vec4(0.0, 0.0, 0.0, 1.0)) {
- sum += light_pixel;
- }
- else {
- sum += mix(flame_pixel, light_pixel, 0.7);
- }
- }
+ vec4 sum = vec4(0.0);
+ for(float i = -lookup_offset; i<=lookup_offset; i+=1.0) {
+ for(float j = -lookup_offset; j<=lookup_offset; j+=1.0) {
+ sum += texture(light_fbo, vec2(vTexCoord.x + i * 1.0/(windowSizeX/2.0), vTexCoord.y + j * 1.0/(windowSizeY/2.0)))/pow(lookup_offset*2+1, 2.0);
}
- oColor = sum;
}
+ oColor = sum;
}
diff --git a/graphics.cc b/graphics.cc
index 7b4bc43..f2dcc7e 100644
--- a/graphics.cc
+++ b/graphics.cc
@@ -92,8 +92,8 @@ void Graphics::init(Level* level) {
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &number_of_texture_units);
printf("Your graphics card supports %d texture units.\n", number_of_texture_units);
// Exit if we need more texture units
- if (number_of_texture_units < 16) {
- printf("You need at least 16 texture units to run this application. Exiting\n");
+ if (number_of_texture_units < 15) {
+ printf("You need at least 15 texture units to run this application. Exiting\n");
exit(-1);
}
@@ -142,28 +142,12 @@ void Graphics::init(Level* level) {
}
}
- flame_fbo_color_texture = SharedTexture2D(new Texture2D(windowSize, GL_RGBA8));
- flame_fbo_color_texture->setMinFilter(GL_NEAREST);
- flame_fbo_color_texture->setMagFilter(GL_NEAREST);
- flame_fbo_color_texture->setWrapS(GL_CLAMP_TO_BORDER);
- flame_fbo_color_texture->setWrapT(GL_CLAMP_TO_BORDER);
- flame_fbo_depth_texture = SharedTexture2D(new Texture2D(windowSize, GL_DEPTH_COMPONENT24));
- flame_fbo_depth_texture->setMinFilter(GL_NEAREST);
- flame_fbo_depth_texture->setMagFilter(GL_NEAREST);
- flame_fbo_depth_texture->setWrapS(GL_CLAMP_TO_BORDER);
- flame_fbo_depth_texture->setWrapT(GL_CLAMP_TO_BORDER);
- framebuffer_flames = SharedFrameBufferObject(new FrameBufferObject());
- framebuffer_flames->attachColorTexture("oColor", flame_fbo_color_texture);
- framebuffer_flames->setDepthTexture(flame_fbo_depth_texture);
- framebuffer_flames->setClearColor(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f));
- framebuffer_flames->validate();
-
light_fbo_color_texture = SharedTexture2D(new Texture2D(windowSize, GL_RGBA8));
light_fbo_color_texture->setMinFilter(GL_NEAREST);
light_fbo_color_texture->setMagFilter(GL_NEAREST);
light_fbo_color_texture->setWrapS(GL_CLAMP_TO_BORDER);
light_fbo_color_texture->setWrapT(GL_CLAMP_TO_BORDER);
- light_fbo_depth_texture = SharedTexture2D(new Texture2D(windowSize, GL_DEPTH_COMPONENT24));
+ light_fbo_depth_texture = SharedTexture2D(new Texture2D(windowSize, GL_DEPTH24_STENCIL8));
light_fbo_depth_texture->setMinFilter(GL_NEAREST);
light_fbo_depth_texture->setMagFilter(GL_NEAREST);
light_fbo_depth_texture->setWrapS(GL_CLAMP_TO_BORDER);
@@ -175,8 +159,7 @@ void Graphics::init(Level* level) {
framebuffer_light->validate();
flamePostShader->use();
- flamePostShader->setTexture("flame_fbo", flame_fbo_color_texture, 15);
- flamePostShader->setTexture("light_fbo", light_fbo_color_texture, 16);
+ flamePostShader->setTexture("light_fbo", light_fbo_color_texture, 15);
flamePostShader->setUniform("windowSizeX", int(windowSize.x));
flamePostShader->setUniform("windowSizeY", int(windowSize.y));
@@ -294,17 +277,17 @@ void Graphics::render(double time)
// render the level
level->render(lightingShader, true, &lightingViewProjectionMatrix, &depthBiasVPs);
+ // draw flames on top
+ flameShader->use();
// cull faces to get consistent color while using alpha
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
- // draw flames on top
- framebuffer_flames->bind();
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
- flameShader->use();
+ // draw with colors
flameShader->setUniform("viewProjectionMatrix", lightingViewProjectionMatrix);
+ flameShader->setUniform("modelViewProjectionMatrix", lightingViewProjectionMatrix);
+ flameShader->setUniform("withColor", true);
flameShader->setUniform("time", (float) time);
flameShader->setUniform("bottom", true);
flameShader->setUniform("left", true);
@@ -317,13 +300,48 @@ void Graphics::render(double time)
flameShader->setUniform("left", false);
flame_positions->render();
- glDisable(GL_CULL_FACE);
+ glDepthMask(GL_FALSE);
- glBindFramebuffer(GL_FRAMEBUFFER, 0);
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ // draw slightly larger only for stencil buffer to blur edges
+ glEnable(GL_STENCIL_TEST);
+ glStencilFunc(GL_ALWAYS, 1, 0xFF); //Set any stencil to 1
+ glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+ glStencilMask(0xFF);//write to stencil buffer
+ glClear(GL_STENCIL_BUFFER_BIT);//clear stencil buffer
+
+ glm::mat4 modelMatrix = glm::scale(glm::vec3(1.1f));
+ flameShader->setUniform("viewProjectionMatrix", lightingViewProjectionMatrix);
+ flameShader->setUniform("modelViewProjectionMatrix", lightingViewProjectionMatrix * modelMatrix);
+ flameShader->setUniform("withColor", false);
+ flameShader->setUniform("time", (float) time);
+ flameShader->setUniform("bottom", true);
+ flameShader->setUniform("left", true);
+ flame_positions->render();
+ flameShader->setUniform("left", false);
+ flame_positions->render();
+ flameShader->setUniform("bottom", false);
+ flameShader->setUniform("left", true);
+ flame_positions->render();
+ flameShader->setUniform("left", false);
+ flame_positions->render();
+
+ glStencilFunc(GL_EQUAL, 1, 0xFF); //Pass test if stencil value is 1
+ glStencilMask(0x00);// don't write to stencil buffer
+
+ glDepthMask(GL_TRUE);
+ glDisable(GL_CULL_FACE);
flamePostShader->use();
fullscreen_quad->render();
+
+ glDisable(GL_STENCIL_TEST);
+
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, framebuffer_light->getObjectName());
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
+ glBlitFramebuffer(0, 0, windowSize.x, windowSize.y, 0, 0, windowSize.x, windowSize.y,
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);
}
bool Graphics::compareLightDistances(Light a, Light b) {
@@ -406,8 +424,8 @@ void Graphics::resize(glm::uvec2 windowSize) {
for (unsigned int i = 0; iresize(glm::vec2(windowSize.x, windowSize.y));
}
- flame_fbo_color_texture->resize(windowSize);
- flame_fbo_depth_texture->resize(windowSize);
+ light_fbo_color_texture->resize(windowSize);
+ light_fbo_depth_texture->resize(windowSize);
flamePostShader->setUniform("windowSizeX", int(windowSize.x));
flamePostShader->setUniform("windowSizeY", int(windowSize.y));
}
diff --git a/graphics.hh b/graphics.hh
index 4b5140a..0c48ac4 100644
--- a/graphics.hh
+++ b/graphics.hh
@@ -39,9 +39,6 @@ class Graphics {
std::vector framebuffer_directional;
std::vector depth_cubeMaps;
SharedFrameBufferObject framebuffer_cube;
- SharedFrameBufferObject framebuffer_flames;
- SharedTexture2D flame_fbo_color_texture;
- SharedTexture2D flame_fbo_depth_texture;
SharedFrameBufferObject framebuffer_light;
SharedTexture2D light_fbo_color_texture;
SharedTexture2D light_fbo_depth_texture;
diff --git a/loader.cc b/loader.cc
index 3c1e386..5c93b29 100644
--- a/loader.cc
+++ b/loader.cc
@@ -325,6 +325,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
float xPos = queryFloat(xmlTrigger, "xPosition");
float yPos = queryFloat(xmlTrigger, "yPosition");
float zPos = queryFloat(xmlTrigger, "zPosition");
+ bool undo = queryBool(xmlTrigger, "undo");
glm::vec3 position = glm::vec3(xPos, yPos, zPos);
std::string stringTarget = queryString(xmlTrigger, "targetIdGreen");
if (stringTarget.compare("-") != 0){
@@ -381,7 +382,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
printf("No Identifier found for an object that was to be changed by a trigger.\n");
}
if (object != 0) {
- Trigger trigger = Trigger(position, distance, isBigger, object, luaScript, level->getLuaState(), objectToChange, scriptPath);
+ Trigger trigger = Trigger(position, distance, isBigger, object, luaScript, level->getLuaState(), objectToChange, scriptPath, undo);
level->addTrigger(trigger);
}
else {
diff --git a/trigger.cc b/trigger.cc
index dbea382..ee66fbe 100644
--- a/trigger.cc
+++ b/trigger.cc
@@ -1,7 +1,7 @@
#include "trigger.hh"
#include
-Trigger::Trigger(glm::vec3 position, float distance, bool isBigger, Object* object, std::string luaScript, lua_State* luaState, int objectToChange, std::string scriptPath) {
+Trigger::Trigger(glm::vec3 position, float distance, bool isBigger, Object* object, std::string luaScript, lua_State* luaState, int objectToChange, std::string scriptPath, bool undo) {
this->position=position;
this->distance=distance;
this->isBigger=isBigger;
@@ -17,6 +17,7 @@ Trigger::Trigger(glm::vec3 position, float distance, bool isBigger, Object* obje
printf("The Lua state is NULL in trigger!\n");
}
this->objectToChange = objectToChange;
+ this->undo = undo;
}
Trigger::Trigger(){
@@ -28,11 +29,19 @@ Trigger::~Trigger(){
void Trigger::triggerUpdate(){
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
luaL_dofile(luaState, luaScript.c_str());
- luabridge::getGlobal(luaState, "trigger")(objectToChange);
+ if (undo){
+ luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
+ }else{
+ luabridge::getGlobal(luaState, "trigger")(objectToChange);
+ }
}
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
luaL_dofile(luaState, luaScript.c_str());
- luabridge::getGlobal(luaState, "trigger")(objectToChange);
+ if (undo){
+ luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
+ }else{
+ luabridge::getGlobal(luaState, "trigger")(objectToChange);
+ }
}
}
diff --git a/trigger.hh b/trigger.hh
index 7afa73d..3c30ca9 100644
--- a/trigger.hh
+++ b/trigger.hh
@@ -14,7 +14,7 @@ class Level;
class Trigger {
public:
- Trigger(glm::vec3 position, float distance, bool isBigger, Object* object, std::string luaScript, lua_State* L, int objectToChange, std::string scriptPath);
+ Trigger(glm::vec3 position, float distance, bool isBigger, Object* object, std::string luaScript, lua_State* L, int objectToChange, std::string scriptPath, bool undo);
Trigger();
~Trigger();
void triggerUpdate();
@@ -27,6 +27,7 @@ class Trigger {
std::string luaScript;
lua_State* luaState;
int objectToChange;
+ bool undo;
};
#endif