Finished lua script for the sunrise and added triggers to call it.
This commit is contained in:
parent
2c191c75a5
commit
a843d00f1c
@ -11936,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>
|
||||
|
@ -14,8 +14,8 @@ function trigger(objectToChange)
|
||||
end
|
||||
timeDiff = timeDiff/maxTimeDiff
|
||||
local x = 1 - 0.3 * timeDiff
|
||||
local y = 0.7 * timeDiff
|
||||
local z = timeDiff^0.5 * 0.6 -0.1
|
||||
level:setSunAngle(x,y,z)
|
||||
local y = math.sqrt(timeDiff) * 1.0 - 0.1
|
||||
local z = 0.7 * timeDiff
|
||||
level:setSunDirection(x,y,z)
|
||||
end
|
||||
end
|
||||
|
8
level.cc
8
level.cc
@ -40,6 +40,7 @@ void Level::load() {
|
||||
.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);
|
||||
@ -229,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;
|
||||
}
|
||||
|
1
level.hh
1
level.hh
@ -49,6 +49,7 @@ class Level {
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user