Added lights that get created and deleted from lua. Scripts dont crash but i cant test it further until monday.

This commit is contained in:
SteffenFuendgens 2015-03-07 13:41:35 +01:00
parent 736aa50ac6
commit 0f8f261d30
6 changed files with 48 additions and 0 deletions

View File

@ -25,6 +25,11 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor1Undo = false global.triggeredOpenSecondDoor1Undo = false
end end
local xPos = -6.5
local yPos = 25.0
local zPos = 54.5
level:preloadLightPosition(xPos, yPos, zPos)
level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -1.5, 3.0, 0.8)
print("openSecondDoor1") print("openSecondDoor1")
end end
end end
@ -41,6 +46,7 @@ function triggerUndo(objectToChange)
global.triggeredOpenSecondDoor2 = false global.triggeredOpenSecondDoor2 = false
global.triggeredOpenSecondDoor3 = false global.triggeredOpenSecondDoor3 = false
global.triggeredOpenSecondDoor4 = false global.triggeredOpenSecondDoor4 = false
level:deleteFourLights()
global.triggeredOpenSecondDoor1Undo = true global.triggeredOpenSecondDoor1Undo = true
print("openSecondDoor1Undo") print("openSecondDoor1Undo")

View File

@ -25,6 +25,11 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor2Undo = false global.triggeredOpenSecondDoor2Undo = false
end end
local xPos = -53.5
local yPos = 25.0
local zPos = 26.5
level:preloadLightPosition(xPos, yPos, zPos)
level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -1.5, 3.0, 0.8)
print("openSecondDoor2") print("openSecondDoor2")
end end
end end
@ -41,6 +46,7 @@ function triggerUndo(objectToChange)
global.triggeredOpenSecondDoor2 = false global.triggeredOpenSecondDoor2 = false
global.triggeredOpenSecondDoor3 = false global.triggeredOpenSecondDoor3 = false
global.triggeredOpenSecondDoor4 = false global.triggeredOpenSecondDoor4 = false
level:deleteFourLights()
global.triggeredOpenSecondDoor2Undo = true global.triggeredOpenSecondDoor2Undo = true
print("openSecondDoor2Undo") print("openSecondDoor2Undo")

View File

@ -25,6 +25,11 @@ function trigger(objectToChange)
global.triggeredOpenSecondDoor3Undo = false global.triggeredOpenSecondDoor3Undo = false
end end
local xPos = -6.5
local yPos = 25.0
local zPos = 26.5
level:preloadLightPosition(xPos, yPos, zPos)
level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -1.5, 3.0, 0.8)
print("openSecondDoor3") print("openSecondDoor3")
end end
end end
@ -41,6 +46,7 @@ function triggerUndo(objectToChange)
global.triggeredOpenSecondDoor2 = false global.triggeredOpenSecondDoor2 = false
global.triggeredOpenSecondDoor3 = false global.triggeredOpenSecondDoor3 = false
global.triggeredOpenSecondDoor4 = false global.triggeredOpenSecondDoor4 = false
level:deleteFourLights()
global.triggeredOpenSecondDoor3Undo = true global.triggeredOpenSecondDoor3Undo = true
print("openSecondDoor3Undo") print("openSecondDoor3Undo")

View File

@ -34,6 +34,11 @@ function trigger(objectToChange)
end end
end end
local xPos = -53.5
local yPos = 25.0
local zPos = 54.5
level:preloadLightPosition(xPos, yPos, zPos)
level:addLightByParameters(0.2, 0.9, 0.0, 4.0, -1.5, 3.0, 0.8)
print("openSecondDoor4") print("openSecondDoor4")
end end
end end
@ -50,6 +55,7 @@ function triggerUndo(objectToChange)
global.triggeredOpenSecondDoor2 = false global.triggeredOpenSecondDoor2 = false
global.triggeredOpenSecondDoor3 = false global.triggeredOpenSecondDoor3 = false
global.triggeredOpenSecondDoor4 = false global.triggeredOpenSecondDoor4 = false
level:deleteFourLights()
global.triggeredOpenSecondDoor4Undo = true global.triggeredOpenSecondDoor4Undo = true
print("openSecondDoor4Undo") print("openSecondDoor4Undo")

View File

@ -43,6 +43,9 @@ void Level::load() {
.addFunction("setSunDirection", &Level::setSunDirection) .addFunction("setSunDirection", &Level::setSunDirection)
.addFunction("forceMove", &Level::forceMove) .addFunction("forceMove", &Level::forceMove)
.addFunction("activateEndgame", &Level::activateEndgame) .addFunction("activateEndgame", &Level::activateEndgame)
.addFunction("preloadLightPosition", &Level::preloadLightPosition)
.addFunction("addLightByParameters", &Level::addLightByParameters)
.addFunction("deleteFourLights", &Level::deleteFourLights)
.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);
@ -259,6 +262,23 @@ void Level::addLight(Light light) {
this->lights.push_back(light); this->lights.push_back(light);
} }
void Level::preloadLightPosition(float xPos, float yPos, float zPos){
nextLightPosition = glm::vec3(xPos, yPos, zPos);
}
void Level::addLightByParameters(float redColour, float greenColour, float blueColour, float intensity, float flameYOffset, float flameHeight, float flameWidth){
glm::vec3 colour = glm::vec3(redColour, greenColour, blueColour);
this->lights.push_back(Light(nextLightPosition, colour, intensity, flameYOffset, flameHeight, flameWidth));
}
void Level::deleteFourLights(){
int indice = lights.size()-4;
lights.erase(lights.begin() + indice);
lights.erase(lights.begin() + indice);
lights.erase(lights.begin() + indice);
lights.erase(lights.begin() + indice);
}
void Level::addTrigger(Trigger trigger) { void Level::addTrigger(Trigger trigger) {
this->triggers.push_back(trigger); this->triggers.push_back(trigger);
} }

View File

@ -55,6 +55,9 @@ class Level {
unsigned int getPhysicsObjectsVectorSize(); unsigned int getPhysicsObjectsVectorSize();
void setCameraCenter(Object* object); void setCameraCenter(Object* object);
void addLight(Light light); void addLight(Light light);
void preloadLightPosition(float xPos, float yPos, float zPos);
void addLightByParameters(float redColour, float greenColour, float blueColour, float intensity, float flameYOffset, float flameHeight, float flameWidth);
void deleteFourLights();
void addTrigger(Trigger trigger); void addTrigger(Trigger trigger);
lua_State* getLuaState(); lua_State* getLuaState();
Terrain* getTerrain(); Terrain* getTerrain();
@ -81,6 +84,7 @@ class Level {
float skydomeSize; float skydomeSize;
float strength; float strength;
std::string xmlFilePath; std::string xmlFilePath;
glm::vec3 nextLightPosition;
}; };
#endif #endif