Finished lua script for the sunrise and added triggers to call it.

This commit is contained in:
Steffen Fündgens 2015-03-06 13:22:04 +01:00
parent db18560dbf
commit f1526fd389
4 changed files with 44 additions and 3 deletions

View File

@ -11936,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>

View File

@ -14,8 +14,8 @@ function trigger(objectToChange)
end end
timeDiff = timeDiff/maxTimeDiff timeDiff = timeDiff/maxTimeDiff
local x = 1 - 0.3 * timeDiff local x = 1 - 0.3 * timeDiff
local y = 0.7 * timeDiff local y = math.sqrt(timeDiff) * 1.0 - 0.1
local z = timeDiff^0.5 * 0.6 -0.1 local z = 0.7 * timeDiff
level:setSunAngle(x,y,z) level:setSunDirection(x,y,z)
end end
end end

View File

@ -40,6 +40,7 @@ void Level::load() {
.addFunction("moveObject", &Level::moveObject) .addFunction("moveObject", &Level::moveObject)
.addFunction("resetPlayer", &Level::resetPlayer) .addFunction("resetPlayer", &Level::resetPlayer)
.addFunction("movePlayer", &Level::movePlayer) .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);
@ -229,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;
} }

View File

@ -49,6 +49,7 @@ class Level {
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();