Made None an available physicsType for objects without physics.

This commit is contained in:
Steffen 2015-02-07 19:23:27 +01:00
parent e39adf56ed
commit 3e8689aae2
2 changed files with 24 additions and 15 deletions

View File

@ -445,7 +445,7 @@
<!-- Available physicTypes are Player, Box, Button and TriangleMesh. <!-- Available physicTypes are Player, Box, Button, TriangleMesh and None(no physics).
dampningL should be below 1, objects that can not move are enabled by setting their mass to 0. --> dampningL should be below 1, objects that can not move are enabled by setting their mass to 0. -->
<!-- Do not change the radius, it has to match the .obj --> <!-- Do not change the radius, it has to match the .obj -->

View File

@ -180,19 +180,6 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
objectRot *= 0.0174532925; //transform degrees to radians objectRot *= 0.0174532925; //transform degrees to radians
Object* object = new Object(model, material, objectPosition, compRot+objectRot, renderable); Object* object = new Object(model, material, objectPosition, compRot+objectRot, renderable);
level->addObject(object); level->addObject(object);
level->addPhysicsObject(object);
//create an identifier for this object
std::vector<int> objectIdentifier = std::vector<int>(5);
objectIdentifier[0] = level->getObjectsVectorSize()-1;
objectIdentifier[1] = level->getPhysicsObjectsVectorSize()-1;
int idGreen, idBlue;
errorCheck(thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen));
errorCheck(thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue));
objectIdentifier[2] = idGreen;
objectIdentifier[3] = idBlue;
objectIdentifier[4] = objectNum;
objectIdentifiers.push_back(objectIdentifier);
//add object to physics //add object to physics
const char* charPhysicType = objectData->FirstChildElement("physicType")->GetText(); const char* charPhysicType = objectData->FirstChildElement("physicType")->GetText();
@ -212,6 +199,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
float radius; float radius;
errorCheck(objectData->FirstChildElement("radius")->QueryFloatText(&radius)); errorCheck(objectData->FirstChildElement("radius")->QueryFloatText(&radius));
radius *= objectScale*compScale; radius *= objectScale*compScale;
level->addPhysicsObject(object);
level->getPhysics()->addPlayer(friction, radius, *object, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize()); level->getPhysics()->addPlayer(friction, radius, *object, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize());
}else if (physicType.compare("Box") == 0){ }else if (physicType.compare("Box") == 0){
float width, height, length; float width, height, length;
@ -221,6 +209,7 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
width *= objectScale*compScale; width *= objectScale*compScale;
height *= objectScale*compScale; height *= objectScale*compScale;
length *= objectScale*compScale; length *= objectScale*compScale;
level->addPhysicsObject(object);
level->getPhysics()->addBox(width, height, length, *object, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize(), rotate); level->getPhysics()->addBox(width, height, length, *object, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize(), rotate);
}else if (physicType.compare("Button") == 0){ }else if (physicType.compare("Button") == 0){
float width, height, length; float width, height, length;
@ -230,14 +219,34 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
width *= objectScale*compScale; width *= objectScale*compScale;
height *= objectScale*compScale; height *= objectScale*compScale;
length *= objectScale*compScale; length *= objectScale*compScale;
level->addPhysicsObject(object);
level->getPhysics()->addButton(width, height, length, *object, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize(), rotate); level->getPhysics()->addButton(width, height, length, *object, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize(), rotate);
}else if (physicType.compare("TriangleMesh") == 0){ }else if (physicType.compare("TriangleMesh") == 0){
level->addPhysicsObject(object);
level->getPhysics()->addTriangleMeshBody(*object, modelPath, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize(), objectScale*compScale, rotate); level->getPhysics()->addTriangleMeshBody(*object, modelPath, mass, dampningL, dampningA, level->getPhysicsObjectsVectorSize(), objectScale*compScale, rotate);
}else if (physicType.compare("None") == 0){
} else{ } else{
printf("XMLError: Not a valid physicType.\n"); printf("XMLError: Not a valid physicType.\n");
exit(-1); exit(-1);
} }
//create an identifier for this object
std::vector<int> objectIdentifier = std::vector<int>(5);
objectIdentifier[0] = level->getObjectsVectorSize()-1;
if (physicType.compare("None") == 0){
objectIdentifier[1] = 0;
}else{
objectIdentifier[1] = level->getPhysicsObjectsVectorSize()-1;
}
int idGreen, idBlue;
errorCheck(thisComposition->FirstChildElement("idGreen")->QueryIntText(&idGreen));
errorCheck(thisComposition->FirstChildElement("idBlue")->QueryIntText(&idBlue));
objectIdentifier[2] = idGreen;
objectIdentifier[3] = idBlue;
objectIdentifier[4] = objectNum;
objectIdentifiers.push_back(objectIdentifier);
if(compositionType == 20){ if(compositionType == 20){
level->setCameraCenter(object); level->setCameraCenter(object);
} }