Merge branch 'master' of github.com:Faerbit/swp

This commit is contained in:
Jasper 2015-03-06 13:58:46 +01:00
commit b9ffdabaa8
38 changed files with 17794 additions and 1963 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -81,6 +81,23 @@
</light>
</composition>
<!-- switchtorch -->
<composition>
<typeID>81</typeID>
<ignoreHeightmap>false</ignoreHeightmap>
<object>
<modelPath>torch.obj</modelPath>
<xOffset>0.0</xOffset>
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<scale>1.0</scale>
<mass>0.0</mass>
</object>
</composition>
<!-- Lightsource -->
<composition>
<typeID>85</typeID>
@ -454,10 +471,46 @@
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<scale>1.5</scale>
<mass>3.0</mass>
<mass>2.0</mass>
</object>
</composition>
<!-- Brazier -->
<composition>
<typeID>245</typeID>
<ignoreHeightmap>false</ignoreHeightmap>
<object>
<modelPath>brazier.obj</modelPath>
<xOffset>0.0</xOffset>
<yOffset>0.5</yOffset>
<zOffset>0.0</zOffset>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<scale>6.0</scale>
<mass>0.0</mass>
</object>
</composition>
<!-- Hint -->
<composition>
<typeID>250</typeID>
<ignoreHeightmap>false</ignoreHeightmap>
<object>
<modelPath>hint.obj</modelPath>
<xOffset>0.0</xOffset>
<yOffset>0.1</yOffset>
<zOffset>0.0</zOffset>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<scale>1.5</scale>
<mass>0.0</mass>
</object>
</composition>
@ -511,7 +564,7 @@
<objectData>
<modelPath>torch.obj</modelPath>
<texturePath>torchTexture.png</texturePath>
<texturePath>torchTexture2.png</texturePath>
<ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.3</diffuseFactor>
<specularFactor>0.7</specularFactor>
@ -580,9 +633,9 @@
</objectData>
<objectData>
<modelPath>gate.obj</modelPath>
<texturePath>gateTexture.png</texturePath>
<ambientFactor>0.1</ambientFactor>
<modelPath>gate.obj</modelPath>
<texturePath>gateTexture.png</texturePath>
<ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor>
<shininess>2.0</shininess>
@ -596,9 +649,9 @@
</objectData>
<objectData>
<modelPath>movableBlock.obj</modelPath>
<texturePath>movableBlockTexture.png</texturePath>
<ambientFactor>0.1</ambientFactor>
<modelPath>movableBlock.obj</modelPath>
<texturePath>movableBlockTexture.png</texturePath>
<ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor>
<shininess>2.0</shininess>
@ -610,3 +663,29 @@
<dampningA>0.5</dampningA>
<renderable>true</renderable>
</objectData>
<objectData>
<modelPath>brazier.obj</modelPath>
<texturePath>brazierTexture.png</texturePath>
<ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor>
<shininess>1.0</shininess>
<physicType>TriangleMesh</physicType>
<dampningL>0.555</dampningL>
<dampningA>0.5</dampningA>
<renderable>true</renderable>
</objectData>
<objectData>
<modelPath>hint.obj</modelPath>
<texturePath>hintTexture.png</texturePath>
<ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor>
<shininess>2.0</shininess>
<physicType>TriangleMesh</physicType>
<dampningL>0.555</dampningL>
<dampningA>0.5</dampningA>
<renderable>true</renderable>
</objectData>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

View File

@ -1,3 +1,148 @@
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<manualPos>false</manualPos>
<xPos>-91.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>216.500000</zPos>
<idGreen>0</idGreen>
<idBlue>142</idBlue>
<typeID>250</typeID>
<trigger>
<name>-</name>
<xPosition>0</xPosition>
<yPosition>0</yPosition>
<zPosition>0</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>1.0</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>-</luaScript>
<toChangeIdGreen>0</toChangeIdGreen>
<toChangeIdBlue>0</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<manualPos>false</manualPos>
<xPos>-6.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>54.500000</zPos>
<idGreen>0</idGreen>
<idBlue>140</idBlue>
<typeID>81</typeID>
<trigger>
<name>-</name>
<xPosition>0</xPosition>
<yPosition>0</yPosition>
<zPosition>0</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>1.0</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>-</luaScript>
<toChangeIdGreen>0</toChangeIdGreen>
<toChangeIdBlue>0</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<manualPos>false</manualPos>
<xPos>-6.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>26.500000</zPos>
<idGreen>0</idGreen>
<idBlue>139</idBlue>
<typeID>81</typeID>
<trigger>
<name>-</name>
<xPosition>0</xPosition>
<yPosition>0</yPosition>
<zPosition>0</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>1.0</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>-</luaScript>
<toChangeIdGreen>0</toChangeIdGreen>
<toChangeIdBlue>0</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<manualPos>false</manualPos>
<xPos>-53.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>54.500000</zPos>
<idGreen>0</idGreen>
<idBlue>138</idBlue>
<typeID>81</typeID>
<trigger>
<name>-</name>
<xPosition>0</xPosition>
<yPosition>0</yPosition>
<zPosition>0</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>1.0</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>-</luaScript>
<toChangeIdGreen>0</toChangeIdGreen>
<toChangeIdBlue>0</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
<yRot>0.0</yRot>
<zRot>0.0</zRot>
<manualPos>false</manualPos>
<xPos>-53.500000</xPos>
<yOffset>0.0</yOffset>
<zPos>26.500000</zPos>
<idGreen>0</idGreen>
<idBlue>137</idBlue>
<typeID>81</typeID>
<trigger>
<name>-</name>
<xPosition>0</xPosition>
<yPosition>0</yPosition>
<zPosition>0</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>1.0</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>-</luaScript>
<toChangeIdGreen>0</toChangeIdGreen>
<toChangeIdBlue>0</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
</composition>
<composition>
<scale>1.0</scale>
<xRot>0.0</xRot>
@ -721,7 +866,7 @@
<zPosition>51.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openSecondDoor1.lua</luaScript>
@ -737,7 +882,7 @@
<zPosition>51.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openSecondDoor1.lua</luaScript>
@ -774,7 +919,7 @@
<zPosition>29.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openSecondDoor3.lua</luaScript>
@ -790,7 +935,7 @@
<zPosition>29.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openSecondDoor3.lua</luaScript>
@ -2451,7 +2596,7 @@
<zPosition>51.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openSecondDoor4.lua</luaScript>
@ -2467,7 +2612,7 @@
<zPosition>51.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openSecondDoor4.lua</luaScript>
@ -2533,7 +2678,7 @@
<zPosition>29.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openSecondDoor2.lua</luaScript>
@ -2549,7 +2694,7 @@
<zPosition>29.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openSecondDoor2.lua</luaScript>
@ -3746,7 +3891,7 @@
<zPosition>67.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openThirdDoor.lua</luaScript>
@ -3762,7 +3907,7 @@
<zPosition>67.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openThirdDoor.lua</luaScript>
@ -6235,7 +6380,7 @@
<zPosition>159.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openFirstDoor.lua</luaScript>
@ -6251,7 +6396,7 @@
<zPosition>159.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<distance>0.1</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openFirstDoor.lua</luaScript>
@ -6268,7 +6413,7 @@
<zRot>0.0</zRot>
<manualPos>false</manualPos>
<xPos>17.500000</xPos>
<yOffset>0.0</yOffset>
<yOffset>5.0</yOffset>
<zPos>81.500000</zPos>
<idGreen>1</idGreen>
<idBlue>94</idBlue>
@ -8653,7 +8798,7 @@
<zRot>0.0</zRot>
<manualPos>false</manualPos>
<xPos>-81.500000</xPos>
<yOffset>0.0</yOffset>
<yOffset>5.0</yOffset>
<zPos>4.500000</zPos>
<idGreen>1</idGreen>
<idBlue>8</idBlue>
@ -10603,7 +10748,7 @@
<zRot>0.0</zRot>
<manualPos>false</manualPos>
<xPos>-172.500000</xPos>
<yOffset>0.0</yOffset>
<yOffset>5.0</yOffset>
<zPos>58.500000</zPos>
<idGreen>0</idGreen>
<idBlue>178</idBlue>
@ -11791,6 +11936,38 @@
<toChangeIdBlue>105</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
<trigger>
<name>sunStart</name>
<undo>false</undo>
<xPosition>-216</xPosition>
<yPosition>20</yPosition>
<zPosition>34</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>10</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>sunStart.lua</luaScript>
<toChangeIdGreen>0</toChangeIdGreen>
<toChangeIdBlue>105</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
<trigger>
<name>sunUpdate</name>
<undo>false</undo>
<xPosition>-216</xPosition>
<yPosition>20</yPosition>
<zPosition>34</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>10</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>sunUpdate.lua</luaScript>
<toChangeIdGreen>0</toChangeIdGreen>
<toChangeIdBlue>105</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
</composition>
<composition>
@ -11970,12 +12147,14 @@
</terrain>
<skydome>
<texture>skydome.png</texture>
<model>skydome.obj</model>
<texture>skydomeNew.png</texture>
<nightTexture>nightskydome.png</nightTexture>
</skydome>
<physics>
<friction>0.9</friction>
<strength>100.0</strength>
<strength>200.0</strength>
</physics>
<positionConstraint>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

View File

@ -2,6 +2,10 @@ local global = require( "global" )
if(global.triggeredSCRIPTNAME == nil) then
global.triggeredSCRIPTNAME = false
end
if(global.triggeredSCRIPTNAMEUndo == nil) then
global.triggeredSCRIPTNAMEUndo = false
end
function trigger(objectToChange)
if(global.triggeredSCRIPTNAME == false) then
if(not level) then
@ -15,3 +19,17 @@ function trigger(objectToChange)
print("SCRIPTNAME")
end
end
function triggerUndo(objectToChange)
if(global.triggeredSCRIPTNAMEUndo == false) then
if(not level) then
print("No level found in Lua!")
return
end
--enter the scripts undo code here
global.triggeredSCRIPTNAMEUndo = true
print("SCRIPTNAMEUndo")
end
end

View File

@ -15,7 +15,7 @@ function trigger(objectToChange)
local strength = 100
local xPos = 17.5
local yPos = 33
local yPos = 33.0
local zPos = 81.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
@ -35,7 +35,7 @@ function triggerUndo(objectToChange)
local strength = 100
local xPos = 17.5
local yPos = 25
local yPos = 25.0
local zPos = 81.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor1 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then
local strength = 100
local xPos = -81.5
local yPos = 33
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
global.triggeredOpenSecondDoor1Undo = false
end
global.triggeredOpenSecondDoor1Undo = false
end
print("openSecondDoor1")

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor2 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then
local strength = 100
local xPos = -81.5
local yPos = 33
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
global.triggeredOpenSecondDoor2Undo = false
end
global.triggeredOpenSecondDoor2Undo = false
end
print("openSecondDoor2")

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor3 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then
local strength = 100
local xPos = -81.5
local yPos = 33
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
else
global.triggeredOpenSecondDoor3Undo = false
end
global.triggeredOpenSecondDoor3Undo = false
end
print("openSecondDoor3")

View File

@ -28,6 +28,7 @@ function trigger(objectToChange)
local yPos = 33
local zPos = 4.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
global.openedSecondDoor = true
else
global.triggeredOpenSecondDoor4Undo = false
end

View File

@ -2,6 +2,7 @@ local global = require( "global" )
if(global.triggeredResetPlayer == nil) then
global.triggeredResetPlayer = false
end
function trigger(objectToChange)
if(global.triggeredResetPlayer == false) then
if(not level) then
@ -9,9 +10,20 @@ function trigger(objectToChange)
return
end
level:resetPlayer()
if(global.triggeredOpenFirstDoor == true) then
if(global.openedSecondDoor == true) then
if(global.triggeredOpenThirdDoor == true) then
level:movePlayer(-169.5,22.5,58.5)
else
level:movePlayer(-78.5,22.5,4.5)
end
else
level:movePlayer(17.5,22.5,87.0)
end
else
level:resetPlayer()
end
--global.triggeredResetPlayer = true
print("reset player")
end
end

View File

@ -0,0 +1,19 @@
local global = require( "global" )
if(global.triggeredSunStart == nil) then
global.triggeredSunStart = false
end
function trigger(objectToChange)
if(global.triggeredSunStart == false) then
if(not level) then
print("No level found in Lua!")
return
end
local time = os.clock()
global.sunStartTime = time
global.triggeredSunStart = true
print("sunStart")
end
end

View File

@ -0,0 +1,21 @@
local global = require( "global" )
function trigger(objectToChange)
if(global.triggeredSunStart) then
if(not level) then
print("No level found in Lua!")
return
end
local maxTimeDiff = 5
local timeDiff = os.clock()- global.sunStartTime
if(timeDiff > maxTimeDiff)then
timeDiff = maxTimeDiff
end
timeDiff = timeDiff/maxTimeDiff
local x = 1 - 0.3 * timeDiff
local y = math.sqrt(timeDiff) * 1.0 - 0.1
local z = 0.7 * timeDiff
level:setSunDirection(x,y,z)
end
end

View File

@ -12,5 +12,4 @@ void main() {
float B = -2*(farPlane*nearPlane)/(farPlane - nearPlane);
float value = 0.5*(-A*length(fragPosition) + B)/length(fragPosition) + 0.5;
gl_FragDepth = value;
//gl_FragDepth = length(fragPosition)/farPlane;
}

View File

@ -9,7 +9,7 @@ uniform bool withColor;
void main() {
if (withColor) {
oColor = vec4(fColor, 0.6);
oColor = vec4(fColor, 1.0);
}
else {
oColor = vec4(0.0, 0.0, 0.0, 0.0);

View File

@ -0,0 +1,11 @@
#version 150
in vec2 vTexCoord;
uniform sampler2D flame_fbo;
out vec4 oColor;
void main() {
oColor = texture(flame_fbo, vTexCoord);
}

View File

@ -0,0 +1,11 @@
#version 150
in vec2 aPosition;
in vec2 aTexCoord;
out vec2 vTexCoord;
void main() {
vTexCoord = aTexCoord;
gl_Position = vec4(aPosition, 0.0, 1.0);
}

18
data/shader/merge.fsh Normal file
View File

@ -0,0 +1,18 @@
#version 150
in vec2 vTexCoord;
uniform sampler2D flame_fbo;
uniform sampler2D light_fbo;
out vec4 oColor;
void main() {
vec4 flameColor = texture(flame_fbo, vTexCoord);
if (flameColor == vec4(0.0, 0.0, 0.0, 1.0)) {
oColor = texture(light_fbo, vTexCoord);
}
else {
oColor = mix(flameColor, texture(light_fbo, vTexCoord), 0.4);
}
}

11
data/shader/merge.vsh Normal file
View File

@ -0,0 +1,11 @@
#version 150
in vec2 aPosition;
in vec2 aTexCoord;
out vec2 vTexCoord;
void main() {
vTexCoord = aTexCoord;
gl_Position = vec4(aPosition, 0.0, 1.0);
}

42
data/shader/skydome.fsh Normal file
View File

@ -0,0 +1,42 @@
#version 150
in vec2 vTexCoord;
in vec4 fragPosition;
in vec4 sunPosition;
out vec4 oColor;
uniform sampler2D uTexture;
uniform sampler2D nightTexture;
uniform float farPlane;
uniform vec4 fogColor;
uniform vec3 cameraCenter;
uniform vec3 sunColor;
uniform vec3 directionalVector;
const float sunSize = 40.0;
void main() {
vec4 textureColor = vec4(0.0, 0.0, 0.0, 1.0);
float sunAngle = -dot(normalize(directionalVector), vec3(0.0, 1.0, 0.0));
vec4 dayColor = texture(uTexture, vTexCoord);
if (sunAngle >= 0.0) {
textureColor = mix(dayColor, texture(nightTexture, vTexCoord), sunAngle);
textureColor = mix(vec4(0.0, 0.0, 0.0, 1.0), textureColor, 1.0 - sunAngle);
}
else {
textureColor = dayColor;
}
float distanceToSun = length(sunPosition - fragPosition);
float distanceCameraCenter = distance(cameraCenter, vec3(fragPosition));
float fogFactor = clamp((1.0 - ((farPlane - 35.0) -distanceCameraCenter)/30.0), 0.0, 1.0);
fogFactor *= clamp((1.0-((fragPosition.y-40.0)/30.0)), 0.0, 1.0);
if (distanceToSun < sunSize) {
float sunIntensity = clamp(0.3*exp(1/(distanceToSun/sunSize))-exp(1.0)*0.3, 0.0, 1.0);
vec4 color = mix(textureColor, vec4(sunColor, sunIntensity), sunIntensity);
oColor = mix(color, fogColor, fogFactor);
}
else {
oColor = mix(textureColor, fogColor, fogFactor);
}
}

22
data/shader/skydome.vsh Normal file
View File

@ -0,0 +1,22 @@
#version 150
in vec3 aPosition;
in vec3 aNormal;
in vec2 aTexCoord;
uniform mat4 modelMatrix;
uniform mat4 modelViewProjectionMatrix;
uniform float skydomeSize;
uniform vec3 directionalVector;
uniform vec3 cameraCenter;
out vec2 vTexCoord;
out vec4 fragPosition;
out vec4 sunPosition;
void main() {
fragPosition = modelMatrix * vec4(aPosition, 1.0);
vTexCoord = aTexCoord;
sunPosition = (normalize(vec4(directionalVector, 0.0)) * skydomeSize) + vec4(cameraCenter, 1.0);
gl_Position = modelViewProjectionMatrix * vec4(aPosition, 1.0);
}

View File

@ -32,9 +32,10 @@ void Graphics::init(Level* level) {
glClearColor( 0.0, 0.0, 0.0, 1.0 );
glEnable( GL_DEPTH_TEST );
glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
glEnable(GL_MULTISAMPLE);
//glEnable(GL_MULTISAMPLE);
fullscreen_quad_ab = SharedArrayBuffer(new ArrayBuffer());
fullscreen_quad_ab->defineAttribute("aPosition", GL_FLOAT, 2);
@ -69,6 +70,9 @@ void Graphics::init(Level* level) {
// look up all shader files starting with 'phong' and build a ShaderProgram from it:
lightingShader = ShaderProgramCreator("phong").attributeLocations(
vao->getAttributeLocations()).create();
skydomeShader = ShaderProgramCreator("skydome").attributeLocations(
vao->getAttributeLocations()).create();
depthShader = ShaderProgramCreator("depth")
.attributeLocations(vao->getAttributeLocations()).create();
@ -86,14 +90,20 @@ void Graphics::init(Level* level) {
flameShader = ShaderProgramCreator("flame")
.attributeLocations(flame_positions->getAttributeLocations()).create();
flameColorShader = ShaderProgramCreator("flame_color")
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
flamePostShader = ShaderProgramCreator("flame_post")
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
mergeShader = ShaderProgramCreator("merge")
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
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 < 15) {
printf("You need at least 15 texture units to run this application. Exiting\n");
if (number_of_texture_units < 19) {
printf("You need at least 19 texture units to run this application. Exiting\n");
exit(-1);
}
@ -159,10 +169,31 @@ void Graphics::init(Level* level) {
framebuffer_light->validate();
flamePostShader->use();
flamePostShader->setTexture("light_fbo", light_fbo_color_texture, 15);
flamePostShader->setTexture("light_fbo", light_fbo_color_texture, 14);
flamePostShader->setUniform("windowSizeX", int(windowSize.x));
flamePostShader->setUniform("windowSizeY", int(windowSize.y));
skydomeShader->use();
skydomeShader->setTexture("nightTexture", level->getSkydome()->getNightTexture()->getReference(), 15);
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);
framebuffer_flame = SharedFrameBufferObject(new FrameBufferObject());
framebuffer_flame->attachColorTexture("oColor", flame_fbo_color_texture);
framebuffer_flame->setDepthTexture(light_fbo_depth_texture);
framebuffer_flame->setClearColor(glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
framebuffer_flame->validate();
mergeShader->use();
mergeShader->setTexture("flame_fbo", flame_fbo_color_texture, 16);
mergeShader->setTexture("light_fbo", light_fbo_color_texture, 17);
flameColorShader->use();
flameColorShader->setTexture("flame_fbo", flame_fbo_color_texture, 18);
updateClosestLights();
}
@ -183,6 +214,7 @@ void Graphics::render(double time)
glm::vec3 upvectors[6] = {glm::vec3(0.0f, -1.0f, 0.0f),glm::vec3(0.0f, -1.0f, 0.0f),glm::vec3(0.0f, 0.0f, -1.0f),
glm::vec3(0.0f, 0.0f, -1.0f),glm::vec3(0.0f, -1.0f, 0.0f),glm::vec3(0.0f, -1.0f, 0.0f)};
framebuffer_cube->bind();
for (unsigned int i_pointlight = 0; i_pointlight<closestLights.size() && i_pointlight < maxShadowRenderCount; i_pointlight++) {
// render each side of the cube
@ -200,6 +232,7 @@ void Graphics::render(double time)
}
}
}
// render depth textures for sun
depthShader->use();
glViewport(0, 0, windowSize.x, windowSize.y);
@ -233,6 +266,20 @@ void Graphics::render(double time)
// lighting render pass
framebuffer_light->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//set view and projection matrix
glm::mat4 lightingViewProjectionMatrix = glm::perspective(1.571f, (float)windowSize.x/(float)windowSize.y, 0.1f, farPlane) * buildViewMatrix(level);
//render skydome
skydomeShader->use();
// set fog Parameters
skydomeShader->setUniform("farPlane", farPlane);
skydomeShader->setUniform("skydomeSize", level->getSkydomeSize());
skydomeShader->setUniform("fogColor", level->getFogColour());
skydomeShader->setUniform("cameraCenter", level->getCameraCenter()->getPosition());
skydomeShader->setUniform("directionalVector", level->getDirectionalLight()->getPosition());
skydomeShader->setUniform("sunColor", level->getDirectionalLight()->getColour());
level->getSkydome()->render(skydomeShader, false, true, &lightingViewProjectionMatrix);
lightingShader->use();
@ -271,19 +318,17 @@ void Graphics::render(double time)
lightingShader->setUniform("ambientColor", level->getAmbientLight());
lightingShader->setUniform("camera", level->getPhysics()->getCameraPosition());
//set view and projection matrix
glm::mat4 lightingViewProjectionMatrix = glm::perspective(1.571f, (float)windowSize.x/(float)windowSize.y, 0.1f, farPlane) * buildViewMatrix(level);
// render the level
level->render(lightingShader, true, &lightingViewProjectionMatrix, &depthBiasVPs);
// draw flames on top
flameShader->use();
framebuffer_flame->bind();
glClear(GL_COLOR_BUFFER_BIT);
// cull faces to get consistent color while using alpha
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
// draw with colors
flameShader->setUniform("viewProjectionMatrix", lightingViewProjectionMatrix);
flameShader->setUniform("modelViewProjectionMatrix", lightingViewProjectionMatrix);
@ -299,10 +344,21 @@ void Graphics::render(double time)
flame_positions->render();
flameShader->setUniform("left", false);
flame_positions->render();
glDisable(GL_CULL_FACE);
glDepthMask(GL_FALSE);
flameColorShader->use();
fullscreen_quad->render();
framebuffer_light->bind();
mergeShader->use();
glDisable(GL_DEPTH_TEST);
fullscreen_quad->render();
glEnable(GL_DEPTH_TEST);
// draw slightly larger only for stencil buffer to blur edges
flameShader->use();
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 0xFF); //Set any stencil to 1
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
@ -328,11 +384,9 @@ void Graphics::render(double time)
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();
glDepthMask(GL_TRUE);
glDisable(GL_STENCIL_TEST);

View File

@ -31,15 +31,20 @@ class Graphics {
float farPlane;
std::vector<Light> closestLights;
SharedShaderProgram lightingShader;
SharedShaderProgram skydomeShader;
SharedShaderProgram depthCubeShader;
SharedShaderProgram depthShader;
SharedShaderProgram flameShader;
SharedShaderProgram flameColorShader;
SharedShaderProgram flamePostShader;
SharedShaderProgram mergeShader;
std::vector<SharedTexture2D> depth_directionalMaps;
std::vector<SharedFrameBufferObject> framebuffer_directional;
std::vector<SharedTextureCubeMap> depth_cubeMaps;
SharedFrameBufferObject framebuffer_cube;
SharedFrameBufferObject framebuffer_light;
SharedFrameBufferObject framebuffer_flame;
SharedTexture2D flame_fbo_color_texture;
SharedTexture2D light_fbo_color_texture;
SharedTexture2D light_fbo_depth_texture;
SharedVertexArrayObject flame_positions;

View File

@ -39,6 +39,8 @@ void Level::load() {
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
.addFunction("moveObject", &Level::moveObject)
.addFunction("resetPlayer", &Level::resetPlayer)
.addFunction("movePlayer", &Level::movePlayer)
.addFunction("setSunDirection", &Level::setSunDirection)
.endClass();
//Push the level to Lua as a global variable
luabridge::push(luaState, this);
@ -50,9 +52,11 @@ void Level::load() {
void Level::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* shadowVPs) {
for(unsigned int i = 0; i<objects.size(); i++) {
// do not project shadow of skydome
if(lightingPass || (objects.at(i) != skydome)) {
objects.at(i)->render(shader, lightingPass, viewProjectionMatrix, shadowVPs);
if (lightingPass) {
objects.at(i)->render(shader, lightingPass, true, viewProjectionMatrix, shadowVPs);
}
else {
objects.at(i)->render(shader, lightingPass, false, viewProjectionMatrix, shadowVPs);
}
}
}
@ -112,7 +116,7 @@ void Level::update(float runTimeSinceLastUpdate, float runTime, glm::vec2 mouseD
physicsObjects[i]->setRotation(physics.getRotation(i));
}
skydome->setPosition(glm::vec3(cameraCenter->getPosition().x,
skydome.setPosition(glm::vec3(cameraCenter->getPosition().x,
0.0f, cameraCenter->getPosition().z));
if (runTime > 2.0f) {
@ -186,8 +190,12 @@ void Level::deleteObject(int objectIndex){
void Level::resetPlayer(){
Loader loader = Loader();
glm::vec3 newPosition = loader.reloadPlayerPosition(xmlFilePath, this);
physics.forceMove(newPosition, playerIndex);
physics.forceMoveCamera(newPosition + glm::vec3(1,0,0));
physics.forcePlayer(newPosition);
}
void Level::movePlayer(float xPosition, float yPosition, float zPosition){
glm::vec3 newPosition = glm::vec3(xPosition, yPosition, zPosition);
physics.forcePlayer(newPosition);
}
void Level::setPlayerIndex(int index){
@ -198,7 +206,7 @@ void Level::setStrength(float strength) {
this->strength = strength;
}
void Level::setSkydomeObject(Object* object){
void Level::setSkydomeObject(Skydome object){
this->skydome = object;
}
@ -222,6 +230,13 @@ void Level::setDirectionalLight(Light light) {
this->directionalLight = light;
}
void Level::setSunDirection(float x, float y, float z){
glm::vec3 lightPosition = glm::vec3(x,y,z);
glm::vec3 lightColour = this->directionalLight.getColour();
float lightIntensity = this->directionalLight.getIntensity();
this->directionalLight = Light(lightPosition, lightColour, lightIntensity);
}
Physics* Level::getPhysics() {
return &physics;
}
@ -253,3 +268,7 @@ lua_State* Level::getLuaState() {
Terrain* Level::getTerrain() {
return &terrain;
}
Skydome* Level::getSkydome() {
return &skydome;
}

View File

@ -10,6 +10,7 @@
#include "camera.hh"
#include "physics.hh"
#include "trigger.hh"
#include "skydome.hh"
extern "C" {
#include "extern/lua/src/lua.h"
@ -36,17 +37,19 @@ class Level {
glm::vec4 getFogColour();
void setSkydomeSize(float size);
float getSkydomeSize();
Skydome* getSkydome();
std::vector<Object*>* getObjects();
std::vector<Object*>* getPhysicsObjects();
void deleteObject(int objectIndex);
void moveObject(int objectIndex, float strength, float xPos, float yPos, float zPos);
void setStrength(float strength);
void setSkydomeObject(Object* object);
void setSkydomeObject(Skydome object);
void addObject(Object* object);
void addPhysicsObject(Object* object);
void setAmbientLight(glm::vec3 colour);
void setFogColour(glm::vec4 colour);
void setDirectionalLight(Light light);
void setSunDirection(float x, float y, float z);
Physics* getPhysics();
unsigned int getObjectsVectorSize();
unsigned int getPhysicsObjectsVectorSize();
@ -56,6 +59,7 @@ class Level {
lua_State* getLuaState();
Terrain* getTerrain();
void resetPlayer();
void movePlayer(float xPosition, float yPosition, float zPosition);
void setPlayerIndex(int index);
private:
lua_State* luaState=nullptr;
@ -68,7 +72,7 @@ class Level {
Light directionalLight;
Object* cameraCenter;
int playerIndex;
Object* skydome;
Skydome skydome;
Physics physics;
Camera camera;
Terrain terrain;

View File

@ -70,22 +70,28 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
//load the skydome
XMLElement* skydomeElement = doc->FirstChildElement("skydome");
std::string skydomeTexture = queryString(skydomeElement, "texture");
std::string skydomePath = "../" + globalGeometryPath + "skydome.obj";
std::string skydomeModelFileName = queryString(skydomeElement, "model");
std::string skydomePath = "../" + globalGeometryPath + skydomeModelFileName;
if(stat(skydomePath.c_str(), &buf) != 0){
std::cout << "The object file " << skydomePath << " does not exist." << std::endl;
exit(-1);
}
Model skydomeModel = Model("skydome.obj", level->getSkydomeSize());
Model skydomeModel = Model(skydomeModelFileName, level->getSkydomeSize());
std::string skydomeTexture = queryString(skydomeElement, "texture");
std::string skydomeTexturePath = "../" + globalTexturePath + skydomeTexture;
if(stat(skydomeTexturePath.c_str(), &buf) != 0){
std::cout << "The texture file " << skydomeTexturePath << " does not exist." << std::endl;
exit(-1);
}
Material skydomeMaterial = Material(skydomeTexture, 0.7f, 0.0f, 0.0f, 0.0f);
Object* skydomeObject = new Object(skydomeModel, skydomeMaterial, glm::vec3(0.0f, 0.0f, 0.0f),
glm::vec3(0.0f, 0.0f, 0.0f), true);
level->addObject(skydomeObject);
Material skydomeMaterial = Material(skydomeTexture, 1.0f, 0.0f, 0.0f, 0.0f);
std::string nightTexture = queryString(skydomeElement, "nightTexture");
std::string nightTexturePath = "../" + globalTexturePath + nightTexture;
if(stat(nightTexturePath.c_str(), &buf) != 0){
std::cout << "The texture file " << nightTexturePath << " does not exist." << std::endl;
exit(-1);
}
Material nightMaterial = Material(nightTexture, 1.0f, 0.0f, 0.0f, 0.0f);
Skydome skydomeObject = Skydome(skydomeModel, skydomeMaterial, nightMaterial);
level->setSkydomeObject(skydomeObject);
//load lighting parameters
@ -128,10 +134,12 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
int thisType = queryInt(thisComposition, "typeID");
//iterate over all compositions in Compositions.xml to find the one corresponding to the current composition
XMLElement* composition = compositions->FirstChildElement("composition");
bool typeExists = false;
for(; composition; composition=composition->NextSiblingElement("composition")){
int compositionType = queryInt(composition, "typeID");
//corect composition found
if(thisType == compositionType){
typeExists = true;
//iterate over all objects of the composition
XMLElement* xmlObject = composition->FirstChildElement("object");
int objectNum = 0;
@ -312,6 +320,9 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
}//iterating over all lights of the composition
}//corect composition found
}//iterating over all compositions in Compositions.xml
if (!typeExists){
std::cout << "The typeID " << thisType << " exists in the level xml but is not a Compositions." << std::endl;
}
}//iterating over all compositions in Level.xml
//load triggers

View File

@ -81,7 +81,7 @@ bool createWindow()
setGLFWHintsForOpenGLVersion( ACGL_OPENGL_VERSION );
// activate multisampling (second parameter is the number of samples):
glfwWindowHint( GLFW_SAMPLES, 4);
//glfwWindowHint( GLFW_SAMPLES, 4);
// request an OpenGL debug context:
glfwWindowHint( GLFW_OPENGL_DEBUG_CONTEXT, true );

View File

@ -14,18 +14,22 @@ Object::~Object() {
}
void Object::render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glm::mat4* viewProjectionMatrix, std::vector<glm::mat4>* additionalMatrices) {
bool texturePass, glm::mat4* viewProjectionMatrix,
std::vector<glm::mat4>* additionalMatrices) {
if (!renderable) {
return;
}
glm::mat4 modelMatrix = glm::translate(getPosition()) * getRotation() * glm::scale<float>(glm::vec3(model.getScale()));
if(texturePass) {
shader->setTexture("uTexture", material.getReference(), 0);
shader->setUniform("modelMatrix", modelMatrix);
}
if (lightingPass) {
// set lightning parameters for this object
shader->setUniform("ambientFactor", material.getAmbientFactor());
shader->setUniform("diffuseFactor", material.getDiffuseFactor());
shader->setUniform("specularFactor", material.getSpecularFactor());
shader->setUniform("shininess", material.getShininess());
shader->setTexture("uTexture", material.getReference(), 0);
// set model matrix
shader->setUniform("modelMatrix", modelMatrix);
// set shadowMVPs

View File

@ -16,7 +16,8 @@ class Object : public Entity {
Object();
~Object();
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass,
glm::mat4* viewProjcetionMatrix, std::vector<glm::mat4>* additionalMatrices);
bool texturePass, glm::mat4* viewProjcetionMatrix,
std::vector<glm::mat4>* additionalMatrices=0);
private:
Model model;
Material material;

13
skydome.cc Normal file
View File

@ -0,0 +1,13 @@
#include "skydome.hh"
Skydome::Skydome(Model model, Material material, Material nightTexture) :
Object(model, material, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 0.0f, 0.0f), true){
this->nightTexture = nightTexture;
}
Skydome::Skydome() {
}
Material* Skydome::getNightTexture() {
return &nightTexture;
}

11
skydome.hh Normal file
View File

@ -0,0 +1,11 @@
#pragma once
#include "object.hh"
class Skydome : public Object {
public:
Skydome(Model model, Material material, Material nightTexture);
Skydome();
Material* getNightTexture();
private:
Material nightTexture;
};

View File

@ -27,22 +27,30 @@ Trigger::~Trigger(){
}
void Trigger::triggerUpdate(){
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
luaL_dofile(luaState, luaScript.c_str());
if (undo){
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
}else{
luabridge::getGlobal(luaState, "trigger")(objectToChange);
}
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
int error = luaL_dofile(luaState, luaScript.c_str());
if (error != 0) {
std::cout << "Couldn't load file: " << this->luaScript << std::endl;
exit(-1);
}
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) {
luaL_dofile(luaState, luaScript.c_str());
if (undo){
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
}else{
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)) {
int error = luaL_dofile(luaState, luaScript.c_str());
if (error != 0) {
std::cout << "Couldn't load file: " << this->luaScript << std::endl;
exit(-1);
}
if (undo){
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
}else{
luabridge::getGlobal(luaState, "trigger")(objectToChange);
}
}
}
bool Trigger::deleteNotification(int deletedObjectIndex){