Finished loading of graphical objects, please check if my interpretation of the rotation is corect(copied from entity.cc). No physics loaded yet.
This commit is contained in:
parent
cf4cbd92fa
commit
030f2f3bdd
15
level.cc
15
level.cc
@ -128,7 +128,7 @@ void Level::load() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
float compXPos, compYOffset, compZPos;
|
float compXPos, compYOffset, compZPos;
|
||||||
glm::vec3 objectOffset, compRot, compPos;
|
glm::vec3 objectOffset, compRot;
|
||||||
error = object->FirstChildElement("xOffset")->QueryFloatText(&objectOffset[0]);
|
error = object->FirstChildElement("xOffset")->QueryFloatText(&objectOffset[0]);
|
||||||
errorCheck(error);
|
errorCheck(error);
|
||||||
error = object->FirstChildElement("yOffset")->QueryFloatText(&objectOffset[1]);
|
error = object->FirstChildElement("yOffset")->QueryFloatText(&objectOffset[1]);
|
||||||
@ -147,18 +147,23 @@ void Level::load() {
|
|||||||
errorCheck(error);
|
errorCheck(error);
|
||||||
error = thisComposition->FirstChildElement("zRot")->QueryFloatText(&compRot[2]);
|
error = thisComposition->FirstChildElement("zRot")->QueryFloatText(&compRot[2]);
|
||||||
errorCheck(error);
|
errorCheck(error);
|
||||||
compPos = glm::vec3(compXPos,
|
glm::vec3 compPos = glm::vec3(compXPos,
|
||||||
compYOffset+terrain.getHeightmap()[int(compXPos-0.5+0.5*terrain.getHeightmapHeight())]
|
compYOffset+terrain.getHeightmap()[int(compXPos-0.5+0.5*terrain.getHeightmapHeight())]
|
||||||
[int(compZPos-0.5+0.5*terrain.getHeightmapWidth())],
|
[int(compZPos-0.5+0.5*terrain.getHeightmapWidth())],
|
||||||
compZPos);
|
compZPos);
|
||||||
objectOffset = objectOffset * compScale;
|
objectOffset = objectOffset * compScale;
|
||||||
//TODO calculate position from objectOffset, compRot and compPos
|
glm::vec4 rotatedObjectOffset = glm::rotate(compRot.x, glm::vec3(1.0f, 0.0f, 0.0f))
|
||||||
//Object* object = new Object(model, material, position, compRot);
|
* glm::rotate(compRot.y, glm::vec3(0.0f, 1.0f, 0.0f))
|
||||||
|
* glm::rotate(compRot.z, glm::vec3(0.0f, 0.0f, 1.0f))
|
||||||
|
* glm::vec4(objectOffset, 0);
|
||||||
|
glm::vec3 objectPosition = compPos + glm::vec3(rotatedObjectOffset.x,rotatedObjectOffset.y,rotatedObjectOffset.z);
|
||||||
|
//Object* object = new Object(model, material, objectPosition, compRot);
|
||||||
//objects.push_back(object);
|
//objects.push_back(object);
|
||||||
//TODO if object has physics: physicObjects.push_back(object);
|
//TODO if object has physics: physicObjects.push_back(object); //should not all objects have physics in the end?
|
||||||
//TODO add object to physics
|
//TODO add object to physics
|
||||||
//if(compositionType == 20){
|
//if(compositionType == 20){
|
||||||
// cameraCenter = object;
|
// cameraCenter = object;
|
||||||
|
// this->physics.addPlayer(1.25f,*object,8.0f,physicObjects.size());
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
XMLElement* light = composition->FirstChildElement("light");
|
XMLElement* light = composition->FirstChildElement("light");
|
||||||
|
Loading…
Reference in New Issue
Block a user