From 6536459359c7d59cd357321f2e0bd7a62f380f8d Mon Sep 17 00:00:00 2001 From: Jasper Date: Fri, 23 Jan 2015 13:31:19 +0100 Subject: [PATCH] prepare for peoples --- level.cc | 7 ++++--- physics.cc | 8 ++++---- physics.hh | 8 ++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/level.cc b/level.cc index bf1b7ba..ce69c5d 100644 --- a/level.cc +++ b/level.cc @@ -248,6 +248,7 @@ void Level::load() { float mass; errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&mass)); float dampningL, dampningA; + bool rotate = true; errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL)); errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA)); if (physicType.compare("Player") == 0){ @@ -259,15 +260,15 @@ void Level::load() { errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width)); errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height)); errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length)); - this->physics.addBox(width, height, length, *object, mass, dampningL, dampningA, physicObjects.size()); + this->physics.addBox(width, height, length, *object, mass, dampningL, dampningA, physicObjects.size(), rotate); }else if (physicType.compare("Button") == 0){ float width, height, length; errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width)); errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height)); errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length)); - this->physics.addButton(width, height, length, *object, mass, dampningL, dampningA, physicObjects.size()); + this->physics.addButton(width, height, length, *object, mass, dampningL, dampningA, physicObjects.size(), rotate); }else if (physicType.compare("TriangleMesh") == 0){ - this->physics.addTriangleMeshBody(*object, modelPath, mass, dampningL, dampningA, physicObjects.size()); + this->physics.addTriangleMeshBody(*object, modelPath, mass, dampningL, dampningA, physicObjects.size(), rotate); } else{ printf("XMLError: Not a valid physicType.\n"); exit(-1); diff --git a/physics.cc b/physics.cc index 1139f97..7b82330 100644 --- a/physics.cc +++ b/physics.cc @@ -176,7 +176,7 @@ void Physics::addPlayer(float friction, float rad, Entity entity, float mass, fl addCamera(); } -void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, float dampningL, float dampningA,unsigned indice) +void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, float dampningL, float dampningA,unsigned indice,bool rotate) {//TODO look at convexHullShapes if(bodies.size() == indice) @@ -247,7 +247,7 @@ void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, f throw std::invalid_argument( "Bodies out of Sync" ); } -void Physics::addButton(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice) +void Physics::addButton(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice,bool rotate) { if(bodies.size() == indice) @@ -277,7 +277,7 @@ void Physics::addButton(float width, float height, float length, Entity entity, throw std::invalid_argument( "Bodies out of Sync" ); } -void Physics::addBox(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice) +void Physics::addBox(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice,bool rotate) { if(bodies.size() == indice) @@ -307,7 +307,7 @@ void Physics::addBox(float width, float height, float length, Entity entity, flo throw std::invalid_argument( "Bodies out of Sync" ); } -void Physics::addSphere(float rad, Entity entity, float mass, float dampningL, float dampningA, unsigned indice) +void Physics::addSphere(float rad, Entity entity, float mass, float dampningL, float dampningA, unsigned indice,bool rotate) { if(bodies.size() == indice) throw std::invalid_argument( "Bodies out of Sync" ); diff --git a/physics.hh b/physics.hh index 3c87fd7..4dd63a2 100644 --- a/physics.hh +++ b/physics.hh @@ -58,15 +58,15 @@ class Physics { void updateCameraPos(glm::vec2 mouseMovement, float strength); glm::vec3 getCameraPosition(); void addRigidBodyFromFile(Entity entity, float mass, float dampningL, float dampningA, std::string modelLocation, unsigned indice); - void addTriangleMeshBody(Entity entity, std::string path, float mass, float dampningL, float dampningA, unsigned indice); + void addTriangleMeshBody(Entity entity, std::string path, float mass, float dampningL, float dampningA, unsigned indice,bool rotate); void addTerrain(int width, int length, float** heightData); void addTerrainTriangles(int width, int length, float** heightData); //add the terrain as a trimesh instead of a heightmap void addPlayer(float friction, float rad, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); //use these AFTER physicObjects.push_back(object)! if mass == 0 then the object is unmoveable - void addSphere(float rad, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); //The Indice should be set to physicObjects.size() - void addBox(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); //this is used to ensuer that the system is synchronized + void addSphere(float rad, Entity entity, float mass, float dampningL, float dampningA, unsigned indice,bool rotate); //The Indice should be set to physicObjects.size() + void addBox(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice,bool rotate); //this is used to ensuer that the system is synchronized void addPositionConstraint(int bodyIndice, float strength, glm::vec3 position); void removePositionConstraint(int bodyIndice); - void addButton(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice); + void addButton(float width, float height, float length, Entity entity, float mass, float dampningL, float dampningA, unsigned indice,bool rotate); glm::vec3 getCameraToPlayer(); struct positionConstraint{btRigidBody* body; float strength; btVector3 position;};