Fixing lights not getting rotated correctly with compositions.

This commit is contained in:
Faerbit 2015-03-15 21:11:56 +01:00
parent 6bb9624908
commit 22d4ee0769

View File

@ -363,6 +363,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
compRot[0] = queryFloat(thisComposition, "xRot"); compRot[0] = queryFloat(thisComposition, "xRot");
compRot[1] = queryFloat(thisComposition, "yRot"); compRot[1] = queryFloat(thisComposition, "yRot");
compRot[2] = queryFloat(thisComposition, "zRot"); compRot[2] = queryFloat(thisComposition, "zRot");
compRot *= 0.0174532925; //transform degrees to radians
lightOffset[0] = queryFloat(xmlLight, "xOffset"); lightOffset[0] = queryFloat(xmlLight, "xOffset");
lightOffset[1] = queryFloat(xmlLight, "yOffset"); lightOffset[1] = queryFloat(xmlLight, "yOffset");
lightOffset[2] = queryFloat(xmlLight, "zOffset"); lightOffset[2] = queryFloat(xmlLight, "zOffset");
@ -375,16 +376,11 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
float compZPos = queryFloat(thisComposition, "zPos"); float compZPos = queryFloat(thisComposition, "zPos");
float lightIntensity = queryFloat(xmlLight, "intensity"); float lightIntensity = queryFloat(xmlLight, "intensity");
bool ignoreHeightmap = queryBool(composition, "ignoreHeightmap"); bool ignoreHeightmap = queryBool(composition, "ignoreHeightmap");
glm::vec3 compPos = glm::vec3(0.0f);
if (!ignoreHeightmap) { if (!ignoreHeightmap) {
compPos = glm::vec3(compXPos, compYOffset = compYOffset+level->getTerrain()->getHeightmap()[int(compXPos-0.5+0.5*level->getTerrain()->getHeightmapHeight())]
compYOffset+level->getTerrain()->getHeightmap()[int(compXPos-0.5+0.5*level->getTerrain()->getHeightmapHeight())] [int(compZPos-0.5+0.5*level->getTerrain()->getHeightmapWidth())];
[int(compZPos-0.5+0.5*level->getTerrain()->getHeightmapWidth())],
compZPos);
}
else {
compPos = glm::vec3(compXPos, compYOffset, compZPos);
} }
glm::vec3 compPos = glm::vec3(compXPos, compYOffset, compZPos);
lightOffset = lightOffset * compScale; lightOffset = lightOffset * compScale;
glm::vec4 rotatedLightOffset = glm::rotate(compRot.x, glm::vec3(1.0f, 0.0f, 0.0f)) glm::vec4 rotatedLightOffset = glm::rotate(compRot.x, glm::vec3(1.0f, 0.0f, 0.0f))
* glm::rotate(compRot.y, glm::vec3(0.0f, 1.0f, 0.0f)) * glm::rotate(compRot.y, glm::vec3(0.0f, 1.0f, 0.0f))