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> </light>
</composition> </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 --> <!-- Lightsource -->
<composition> <composition>
<typeID>85</typeID> <typeID>85</typeID>
@ -454,10 +471,46 @@
<yRot>0.0</yRot> <yRot>0.0</yRot>
<zRot>0.0</zRot> <zRot>0.0</zRot>
<scale>1.5</scale> <scale>1.5</scale>
<mass>3.0</mass> <mass>2.0</mass>
</object> </object>
</composition> </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> <objectData>
<modelPath>torch.obj</modelPath> <modelPath>torch.obj</modelPath>
<texturePath>torchTexture.png</texturePath> <texturePath>torchTexture2.png</texturePath>
<ambientFactor>0.1</ambientFactor> <ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.3</diffuseFactor> <diffuseFactor>0.3</diffuseFactor>
<specularFactor>0.7</specularFactor> <specularFactor>0.7</specularFactor>
@ -580,9 +633,9 @@
</objectData> </objectData>
<objectData> <objectData>
<modelPath>gate.obj</modelPath> <modelPath>gate.obj</modelPath>
<texturePath>gateTexture.png</texturePath> <texturePath>gateTexture.png</texturePath>
<ambientFactor>0.1</ambientFactor> <ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.6</diffuseFactor> <diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor> <specularFactor>0.4</specularFactor>
<shininess>2.0</shininess> <shininess>2.0</shininess>
@ -596,9 +649,9 @@
</objectData> </objectData>
<objectData> <objectData>
<modelPath>movableBlock.obj</modelPath> <modelPath>movableBlock.obj</modelPath>
<texturePath>movableBlockTexture.png</texturePath> <texturePath>movableBlockTexture.png</texturePath>
<ambientFactor>0.1</ambientFactor> <ambientFactor>0.1</ambientFactor>
<diffuseFactor>0.6</diffuseFactor> <diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor> <specularFactor>0.4</specularFactor>
<shininess>2.0</shininess> <shininess>2.0</shininess>
@ -610,3 +663,29 @@
<dampningA>0.5</dampningA> <dampningA>0.5</dampningA>
<renderable>true</renderable> <renderable>true</renderable>
</objectData> </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> <composition>
<scale>1.0</scale> <scale>1.0</scale>
<xRot>0.0</xRot> <xRot>0.0</xRot>
@ -721,7 +866,7 @@
<zPosition>51.5</zPosition> <zPosition>51.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>true</isBiggerThan> <isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openSecondDoor1.lua</luaScript> <luaScript>openSecondDoor1.lua</luaScript>
@ -737,7 +882,7 @@
<zPosition>51.5</zPosition> <zPosition>51.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>false</isBiggerThan> <isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openSecondDoor1.lua</luaScript> <luaScript>openSecondDoor1.lua</luaScript>
@ -774,7 +919,7 @@
<zPosition>29.5</zPosition> <zPosition>29.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>true</isBiggerThan> <isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openSecondDoor3.lua</luaScript> <luaScript>openSecondDoor3.lua</luaScript>
@ -790,7 +935,7 @@
<zPosition>29.5</zPosition> <zPosition>29.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>false</isBiggerThan> <isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openSecondDoor3.lua</luaScript> <luaScript>openSecondDoor3.lua</luaScript>
@ -2451,7 +2596,7 @@
<zPosition>51.5</zPosition> <zPosition>51.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>true</isBiggerThan> <isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openSecondDoor4.lua</luaScript> <luaScript>openSecondDoor4.lua</luaScript>
@ -2467,7 +2612,7 @@
<zPosition>51.5</zPosition> <zPosition>51.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>false</isBiggerThan> <isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openSecondDoor4.lua</luaScript> <luaScript>openSecondDoor4.lua</luaScript>
@ -2533,7 +2678,7 @@
<zPosition>29.5</zPosition> <zPosition>29.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>true</isBiggerThan> <isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openSecondDoor2.lua</luaScript> <luaScript>openSecondDoor2.lua</luaScript>
@ -2549,7 +2694,7 @@
<zPosition>29.5</zPosition> <zPosition>29.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>false</isBiggerThan> <isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openSecondDoor2.lua</luaScript> <luaScript>openSecondDoor2.lua</luaScript>
@ -3746,7 +3891,7 @@
<zPosition>67.5</zPosition> <zPosition>67.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>true</isBiggerThan> <isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openThirdDoor.lua</luaScript> <luaScript>openThirdDoor.lua</luaScript>
@ -3762,7 +3907,7 @@
<zPosition>67.5</zPosition> <zPosition>67.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>false</isBiggerThan> <isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openThirdDoor.lua</luaScript> <luaScript>openThirdDoor.lua</luaScript>
@ -6235,7 +6380,7 @@
<zPosition>159.5</zPosition> <zPosition>159.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>true</isBiggerThan> <isBiggerThan>true</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openFirstDoor.lua</luaScript> <luaScript>openFirstDoor.lua</luaScript>
@ -6251,7 +6396,7 @@
<zPosition>159.5</zPosition> <zPosition>159.5</zPosition>
<targetIdGreen>-</targetIdGreen> <targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue> <targetIdBlue>-</targetIdBlue>
<distance>0.2</distance> <distance>0.1</distance>
<isBiggerThan>false</isBiggerThan> <isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum> <objectNum>0</objectNum>
<luaScript>openFirstDoor.lua</luaScript> <luaScript>openFirstDoor.lua</luaScript>
@ -6268,7 +6413,7 @@
<zRot>0.0</zRot> <zRot>0.0</zRot>
<manualPos>false</manualPos> <manualPos>false</manualPos>
<xPos>17.500000</xPos> <xPos>17.500000</xPos>
<yOffset>0.0</yOffset> <yOffset>5.0</yOffset>
<zPos>81.500000</zPos> <zPos>81.500000</zPos>
<idGreen>1</idGreen> <idGreen>1</idGreen>
<idBlue>94</idBlue> <idBlue>94</idBlue>
@ -8653,7 +8798,7 @@
<zRot>0.0</zRot> <zRot>0.0</zRot>
<manualPos>false</manualPos> <manualPos>false</manualPos>
<xPos>-81.500000</xPos> <xPos>-81.500000</xPos>
<yOffset>0.0</yOffset> <yOffset>5.0</yOffset>
<zPos>4.500000</zPos> <zPos>4.500000</zPos>
<idGreen>1</idGreen> <idGreen>1</idGreen>
<idBlue>8</idBlue> <idBlue>8</idBlue>
@ -10603,7 +10748,7 @@
<zRot>0.0</zRot> <zRot>0.0</zRot>
<manualPos>false</manualPos> <manualPos>false</manualPos>
<xPos>-172.500000</xPos> <xPos>-172.500000</xPos>
<yOffset>0.0</yOffset> <yOffset>5.0</yOffset>
<zPos>58.500000</zPos> <zPos>58.500000</zPos>
<idGreen>0</idGreen> <idGreen>0</idGreen>
<idBlue>178</idBlue> <idBlue>178</idBlue>
@ -11791,6 +11936,38 @@
<toChangeIdBlue>105</toChangeIdBlue> <toChangeIdBlue>105</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum> <toChangeObjNum>0</toChangeObjNum>
</trigger> </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>
<composition> <composition>
@ -11970,12 +12147,14 @@
</terrain> </terrain>
<skydome> <skydome>
<texture>skydome.png</texture> <model>skydome.obj</model>
<texture>skydomeNew.png</texture>
<nightTexture>nightskydome.png</nightTexture>
</skydome> </skydome>
<physics> <physics>
<friction>0.9</friction> <friction>0.9</friction>
<strength>100.0</strength> <strength>200.0</strength>
</physics> </physics>
<positionConstraint> <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 if(global.triggeredSCRIPTNAME == nil) then
global.triggeredSCRIPTNAME = false global.triggeredSCRIPTNAME = false
end end
if(global.triggeredSCRIPTNAMEUndo == nil) then
global.triggeredSCRIPTNAMEUndo = false
end
function trigger(objectToChange) function trigger(objectToChange)
if(global.triggeredSCRIPTNAME == false) then if(global.triggeredSCRIPTNAME == false) then
if(not level) then if(not level) then
@ -15,3 +19,17 @@ function trigger(objectToChange)
print("SCRIPTNAME") print("SCRIPTNAME")
end end
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 strength = 100
local xPos = 17.5 local xPos = 17.5
local yPos = 33 local yPos = 33.0
local zPos = 81.5 local zPos = 81.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos) level:moveObject(objectToChange, strength, xPos, yPos, zPos)
@ -35,7 +35,7 @@ function triggerUndo(objectToChange)
local strength = 100 local strength = 100
local xPos = 17.5 local xPos = 17.5
local yPos = 25 local yPos = 25.0
local zPos = 81.5 local zPos = 81.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos) level:moveObject(objectToChange, strength, xPos, yPos, zPos)

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor1 = true global.triggeredOpenSecondDoor1 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then global.triggeredOpenSecondDoor1Undo = false
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
end end
print("openSecondDoor1") print("openSecondDoor1")

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor2 = true global.triggeredOpenSecondDoor2 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then global.triggeredOpenSecondDoor2Undo = false
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
end end
print("openSecondDoor2") print("openSecondDoor2")

View File

@ -22,15 +22,7 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor3 = true global.triggeredOpenSecondDoor3 = true
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
if(global.openSecondDoorCounter == 4) then global.triggeredOpenSecondDoor3Undo = false
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
end end
print("openSecondDoor3") print("openSecondDoor3")

View File

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

View File

@ -2,6 +2,7 @@ local global = require( "global" )
if(global.triggeredResetPlayer == nil) then if(global.triggeredResetPlayer == nil) then
global.triggeredResetPlayer = false global.triggeredResetPlayer = false
end end
function trigger(objectToChange) function trigger(objectToChange)
if(global.triggeredResetPlayer == false) then if(global.triggeredResetPlayer == false) then
if(not level) then if(not level) then
@ -9,9 +10,20 @@ function trigger(objectToChange)
return return
end 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") print("reset player")
end end
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 B = -2*(farPlane*nearPlane)/(farPlane - nearPlane);
float value = 0.5*(-A*length(fragPosition) + B)/length(fragPosition) + 0.5; float value = 0.5*(-A*length(fragPosition) + B)/length(fragPosition) + 0.5;
gl_FragDepth = value; gl_FragDepth = value;
//gl_FragDepth = length(fragPosition)/farPlane;
} }

View File

@ -9,7 +9,7 @@ uniform bool withColor;
void main() { void main() {
if (withColor) { if (withColor) {
oColor = vec4(fColor, 0.6); oColor = vec4(fColor, 1.0);
} }
else { else {
oColor = vec4(0.0, 0.0, 0.0, 0.0); 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 ); glClearColor( 0.0, 0.0, 0.0, 1.0 );
glEnable( GL_DEPTH_TEST ); glEnable( GL_DEPTH_TEST );
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
glEnable(GL_MULTISAMPLE); //glEnable(GL_MULTISAMPLE);
fullscreen_quad_ab = SharedArrayBuffer(new ArrayBuffer()); fullscreen_quad_ab = SharedArrayBuffer(new ArrayBuffer());
fullscreen_quad_ab->defineAttribute("aPosition", GL_FLOAT, 2); fullscreen_quad_ab->defineAttribute("aPosition", GL_FLOAT, 2);
@ -70,6 +71,9 @@ void Graphics::init(Level* level) {
lightingShader = ShaderProgramCreator("phong").attributeLocations( lightingShader = ShaderProgramCreator("phong").attributeLocations(
vao->getAttributeLocations()).create(); vao->getAttributeLocations()).create();
skydomeShader = ShaderProgramCreator("skydome").attributeLocations(
vao->getAttributeLocations()).create();
depthShader = ShaderProgramCreator("depth") depthShader = ShaderProgramCreator("depth")
.attributeLocations(vao->getAttributeLocations()).create(); .attributeLocations(vao->getAttributeLocations()).create();
@ -86,14 +90,20 @@ void Graphics::init(Level* level) {
flameShader = ShaderProgramCreator("flame") flameShader = ShaderProgramCreator("flame")
.attributeLocations(flame_positions->getAttributeLocations()).create(); .attributeLocations(flame_positions->getAttributeLocations()).create();
flameColorShader = ShaderProgramCreator("flame_color")
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
flamePostShader = ShaderProgramCreator("flame_post") flamePostShader = ShaderProgramCreator("flame_post")
.attributeLocations(fullscreen_quad->getAttributeLocations()).create(); .attributeLocations(fullscreen_quad->getAttributeLocations()).create();
mergeShader = ShaderProgramCreator("merge")
.attributeLocations(fullscreen_quad->getAttributeLocations()).create();
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &number_of_texture_units); glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &number_of_texture_units);
printf("Your graphics card supports %d texture units.\n", number_of_texture_units); printf("Your graphics card supports %d texture units.\n", number_of_texture_units);
// Exit if we need more texture units // Exit if we need more texture units
if (number_of_texture_units < 15) { if (number_of_texture_units < 19) {
printf("You need at least 15 texture units to run this application. Exiting\n"); printf("You need at least 19 texture units to run this application. Exiting\n");
exit(-1); exit(-1);
} }
@ -159,10 +169,31 @@ void Graphics::init(Level* level) {
framebuffer_light->validate(); framebuffer_light->validate();
flamePostShader->use(); 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("windowSizeX", int(windowSize.x));
flamePostShader->setUniform("windowSizeY", int(windowSize.y)); 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(); 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 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)}; 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(); framebuffer_cube->bind();
for (unsigned int i_pointlight = 0; i_pointlight<closestLights.size() && i_pointlight < maxShadowRenderCount; i_pointlight++) { for (unsigned int i_pointlight = 0; i_pointlight<closestLights.size() && i_pointlight < maxShadowRenderCount; i_pointlight++) {
// render each side of the cube // render each side of the cube
@ -200,6 +232,7 @@ void Graphics::render(double time)
} }
} }
} }
// render depth textures for sun // render depth textures for sun
depthShader->use(); depthShader->use();
glViewport(0, 0, windowSize.x, windowSize.y); glViewport(0, 0, windowSize.x, windowSize.y);
@ -234,6 +267,20 @@ void Graphics::render(double time)
framebuffer_light->bind(); framebuffer_light->bind();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 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(); lightingShader->use();
//set lighting parameters //set lighting parameters
@ -271,19 +318,17 @@ void Graphics::render(double time)
lightingShader->setUniform("ambientColor", level->getAmbientLight()); lightingShader->setUniform("ambientColor", level->getAmbientLight());
lightingShader->setUniform("camera", level->getPhysics()->getCameraPosition()); 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 // render the level
level->render(lightingShader, true, &lightingViewProjectionMatrix, &depthBiasVPs); level->render(lightingShader, true, &lightingViewProjectionMatrix, &depthBiasVPs);
// draw flames on top // draw flames on top
flameShader->use(); flameShader->use();
framebuffer_flame->bind();
glClear(GL_COLOR_BUFFER_BIT);
// cull faces to get consistent color while using alpha // cull faces to get consistent color while using alpha
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
glCullFace(GL_BACK); glCullFace(GL_BACK);
// draw with colors // draw with colors
flameShader->setUniform("viewProjectionMatrix", lightingViewProjectionMatrix); flameShader->setUniform("viewProjectionMatrix", lightingViewProjectionMatrix);
flameShader->setUniform("modelViewProjectionMatrix", lightingViewProjectionMatrix); flameShader->setUniform("modelViewProjectionMatrix", lightingViewProjectionMatrix);
@ -299,10 +344,21 @@ void Graphics::render(double time)
flame_positions->render(); flame_positions->render();
flameShader->setUniform("left", false); flameShader->setUniform("left", false);
flame_positions->render(); flame_positions->render();
glDisable(GL_CULL_FACE);
glDepthMask(GL_FALSE); 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 // draw slightly larger only for stencil buffer to blur edges
flameShader->use();
glEnable(GL_STENCIL_TEST); glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 0xFF); //Set any stencil to 1 glStencilFunc(GL_ALWAYS, 1, 0xFF); //Set any stencil to 1
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); 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 glStencilFunc(GL_EQUAL, 1, 0xFF); //Pass test if stencil value is 1
glStencilMask(0x00);// don't write to stencil buffer glStencilMask(0x00);// don't write to stencil buffer
glDepthMask(GL_TRUE);
glDisable(GL_CULL_FACE);
flamePostShader->use(); flamePostShader->use();
fullscreen_quad->render(); fullscreen_quad->render();
glDepthMask(GL_TRUE);
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,8 @@ class Object : public Entity {
Object(); Object();
~Object(); ~Object();
void render(ACGL::OpenGL::SharedShaderProgram shader, bool lightingPass, 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: private:
Model model; Model model;
Material material; 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(){ void Trigger::triggerUpdate(){
if (isBigger && (glm::distance(object->getPosition(), position) > distance)) { if (isBigger && (glm::distance(object->getPosition(), position) > distance)) {
luaL_dofile(luaState, luaScript.c_str()); int error = luaL_dofile(luaState, luaScript.c_str());
if (undo){ if (error != 0) {
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange); std::cout << "Couldn't load file: " << this->luaScript << std::endl;
}else{ exit(-1);
luabridge::getGlobal(luaState, "trigger")(objectToChange);
}
} }
else if (!isBigger && (glm::distance(object->getPosition(), position) < distance)) { if (undo){
luaL_dofile(luaState, luaScript.c_str()); luabridge::getGlobal(luaState, "triggerUndo")(objectToChange);
if (undo){ }else{
luabridge::getGlobal(luaState, "triggerUndo")(objectToChange); luabridge::getGlobal(luaState, "trigger")(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){ bool Trigger::deleteNotification(int deletedObjectIndex){