Merge branch 'master' of github.com:Faerbit/swp

This commit is contained in:
Faerbit 2014-12-15 13:16:36 +01:00
commit 7dae5a5e8c
2 changed files with 34 additions and 29 deletions

View File

@ -6,6 +6,7 @@
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<scale>0.75</scale>
<mass>8.0</mass>
</object>
</composition>
@ -17,6 +18,7 @@
<yOffset>1.0</yOffset>
<zOffset>2.0</zOffset>
<scale>1.0</scale>
<mass>2.0</mass>
</object>
</composition>
@ -28,6 +30,7 @@
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<scale>1.0</scale>
<mass>2.0</mass>
</object>
</composition>
@ -39,6 +42,7 @@
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<scale>1.0</scale>
<mass>0.0</mass>
</object>
<light>
<xOffset>0.0</xOffset>
@ -59,6 +63,7 @@
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<scale>1.0</scale>
<mass>0.0</mass>
</object>
<object>
<modelPath>column.obj</modelPath>
@ -66,6 +71,7 @@
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<scale>1.0</scale>
<mass>0.0</mass>
</object>
<object>
<modelPath>block.obj</modelPath>
@ -73,6 +79,7 @@
<yOffset>3.0</yOffset>
<zOffset>0.0</zOffset>
<scale>1.0</scale>
<mass>0.0</mass>
</object>
</composition>
@ -84,6 +91,7 @@
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<scale>1.0</scale>
<mass>1.0</mass>
</object>
<object>
<modelPath>switch_outer.obj</modelPath>
@ -91,6 +99,7 @@
<yOffset>0.0</yOffset>
<zOffset>0.0</zOffset>
<scale>1.0</scale>
<mass>0.0</mass>
</object>
</composition>
@ -107,7 +116,6 @@
<shininess>3.0</shininess>
<physicType>Player</physicType>
<radius>1.25</radius>
<mass>8.0</mass>
</objectData>
<objectData>
@ -121,7 +129,6 @@
<width>1.0</width>
<height>1.0</height>
<length>3.0</length>
<mass>2.0</mass>
</objectData>
<objectData>
@ -131,8 +138,7 @@
<diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor>
<shininess>2.0</shininess>
<physicType>TriangleMeshBody</physicType>
<mass>2.0</mass>
<physicType>TriangleMesh</physicType>
<dampningL>1.0</dampningL>
<dampningA>1.0</dampningA>
</objectData>
@ -144,8 +150,7 @@
<diffuseFactor>0.3</diffuseFactor>
<specularFactor>0.7</specularFactor>
<shininess>10.0</shininess>
<physicType>TriangleMeshBody</physicType>
<mass>0.0</mass>
<physicType>TriangleMesh</physicType>
<dampningL>1.0</dampningL>
<dampningA>1.0</dampningA>
</objectData>
@ -157,10 +162,9 @@
<diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor>
<shininess>2.0</shininess>
<physicType>TriangleMeshBody</physicType>
<mass>1.0</mass>
<dampningL>1.0</dampningL>
<dampningA>1.0</dampningA>
<physicType>TriangleMesh</physicType>
<dampningL>0.5</dampningL>
<dampningA>0.5</dampningA>
</objectData>
<objectData>
@ -170,8 +174,7 @@
<diffuseFactor>0.6</diffuseFactor>
<specularFactor>0.4</specularFactor>
<shininess>2.0</shininess>
<physicType>TriangleMeshBody</physicType>
<mass>0.0</mass>
<physicType>TriangleMesh</physicType>
<dampningL>1.0</dampningL>
<dampningA>1.0</dampningA>
</objectData>

View File

@ -128,16 +128,16 @@ void Level::load() {
//corect composition found
if(thisType == compositionType){
//iterate over all objects of the composition
XMLElement* object = composition->FirstChildElement("object");
XMLElement* xmlObject = composition->FirstChildElement("object");
int objectNum = 0;
for(; object; object=object->NextSiblingElement("object")){
const char* charModelPath = object->FirstChildElement("modelPath")->GetText();
for(; xmlObject; xmlObject=xmlObject->NextSiblingElement("object")){
const char* charModelPath = xmlObject->FirstChildElement("modelPath")->GetText();
if(charModelPath == NULL){
printf("XMLError: No modelPath found in object.\n");
}
std::string modelPath = charModelPath;
float objectScale, compScale;
errorCheck(object->FirstChildElement("scale")->QueryFloatText(&objectScale));
errorCheck(xmlObject->FirstChildElement("scale")->QueryFloatText(&objectScale));
errorCheck(thisComposition->FirstChildElement("scale")->QueryFloatText(&compScale));
Model model = Model(modelPath, objectScale * compScale);
//find the objectData for the current object
@ -164,9 +164,9 @@ void Level::load() {
Material material = Material(texturePath, ambientFactor, diffuseFactor, specularFactor, shininess);
float compXPos, compYOffset, compZPos;
glm::vec3 objectOffset, compRot;
errorCheck(object->FirstChildElement("xOffset")->QueryFloatText(&objectOffset[0]));
errorCheck(object->FirstChildElement("yOffset")->QueryFloatText(&objectOffset[1]));
errorCheck(object->FirstChildElement("zOffset")->QueryFloatText(&objectOffset[2]));
errorCheck(xmlObject->FirstChildElement("xOffset")->QueryFloatText(&objectOffset[0]));
errorCheck(xmlObject->FirstChildElement("yOffset")->QueryFloatText(&objectOffset[1]));
errorCheck(xmlObject->FirstChildElement("zOffset")->QueryFloatText(&objectOffset[2]));
errorCheck(thisComposition->FirstChildElement("xPos")->QueryFloatText(&compXPos));
errorCheck(thisComposition->FirstChildElement("yOffset")->QueryFloatText(&compYOffset));
errorCheck(thisComposition->FirstChildElement("zPos")->QueryFloatText(&compZPos));
@ -195,7 +195,7 @@ void Level::load() {
objectIdentifier[2] = idBlue;
objectIdentifier[3] = objectNum;
objectIdentifiers.push_back(objectIdentifier);
/*
physicObjects.push_back(object);
const char* charPhysicType = objectData->FirstChildElement("physicType")->GetText();
if(charPhysicType == NULL){
@ -203,28 +203,30 @@ void Level::load() {
}
std::string physicType = charPhysicType;
//add object to physics
float mass;
errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&mass));
if (physicType.compare("Player") == 0){
float radius, mass;
float radius;
errorCheck(objectData->FirstChildElement("radius")->QueryFloatText(&radius));
errorCheck(objectData->FirstChildElement("mass")->QueryFloatText(&mass));
this->physics.addPlayer(radius, *object, mass, physicObjects.size());
}else if (physicType.compare("Box") == 0){
float width, height, length, mass;
float width, height, length;
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
errorCheck(objectData->FirstChildElement("mass")->QueryFloatText(&mass));
this->physics.addBox(width, height, length, *object, mass, physicObjects.size());
}else if (physicType.compare("TriangleMeshBody") == 0){
float mass, dampningL, dampningA;
errorCheck(objectData->FirstChildElement("mass")->QueryFloatText(&mass));
}else if (physicType.compare("TriangleMesh") == 0){
float dampningL, dampningA;
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
this->physics.addTriangleMeshBody(*object, mass, dampningL, dampningA, physicObjects.size());
std::string bulletModelPath = modelPath.substr(0, modelPath.length()-3);
bulletModelPath += "bullet";
//this->physics.addRigidBodyFromFile(*object, mass, dampningL, dampningA, bulletModelPath, physicObjects.size());
this->physics.addBox(1, 1, 1, *object, mass, physicObjects.size());
} else{
printf("XMLError: Not a valid physicType.\n");
}
*/
if(compositionType == 20){
cameraCenter = object;
}