Merge branch 'master' of github.com:Faerbit/swp
This commit is contained in:
commit
c92bb70ae5
@ -230,6 +230,9 @@
|
|||||||
<ignoreHeightmap>true</ignoreHeightmap>
|
<ignoreHeightmap>true</ignoreHeightmap>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>SimpleWall.obj</modelPath>
|
<modelPath>SimpleWall.obj</modelPath>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>40.0</yOffset>
|
<yOffset>40.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
@ -244,11 +247,14 @@
|
|||||||
<ignoreHeightmap>false</ignoreHeightmap>
|
<ignoreHeightmap>false</ignoreHeightmap>
|
||||||
<object>
|
<object>
|
||||||
<modelPath>block.obj</modelPath>
|
<modelPath>block.obj</modelPath>
|
||||||
<xOffset>0.0</xOffset>
|
<xOffset>0.0</xOffset>
|
||||||
<yOffset>5.0</yOffset>
|
<yOffset>20.0</yOffset>
|
||||||
<zOffset>0.0</zOffset>
|
<zOffset>0.0</zOffset>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
<scale>1.5</scale>
|
<scale>1.5</scale>
|
||||||
<mass>1.0</mass>
|
<mass>2.0</mass>
|
||||||
</object>
|
</object>
|
||||||
</composition>
|
</composition>
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
@ -8,7 +8,7 @@
|
|||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>-220.500000</zPos>
|
<zPos>-220.500000</zPos>
|
||||||
<idGreen>2</idGreen>
|
<idGreen>2</idGreen>
|
||||||
<idBlue>221</idBlue>
|
<idBlue>224</idBlue>
|
||||||
<typeID>20</typeID>
|
<typeID>20</typeID>
|
||||||
<trigger>
|
<trigger>
|
||||||
<name>-</name>
|
<name>-</name>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
<yOffset>0.0</yOffset>
|
<yOffset>0.0</yOffset>
|
||||||
<zPos>-220.500000</zPos>
|
<zPos>-220.500000</zPos>
|
||||||
<idGreen>2</idGreen>
|
<idGreen>2</idGreen>
|
||||||
<idBlue>220</idBlue>
|
<idBlue>223</idBlue>
|
||||||
<typeID>80</typeID>
|
<typeID>80</typeID>
|
||||||
<trigger>
|
<trigger>
|
||||||
<name>-</name>
|
<name>-</name>
|
||||||
@ -56,6 +56,100 @@
|
|||||||
</trigger>
|
</trigger>
|
||||||
</composition>
|
</composition>
|
||||||
|
|
||||||
|
<composition>
|
||||||
|
<scale>1.0</scale>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
|
<xPos>200.500000</xPos>
|
||||||
|
<yOffset>0.0</yOffset>
|
||||||
|
<zPos>-222.500000</zPos>
|
||||||
|
<idGreen>2</idGreen>
|
||||||
|
<idBlue>222</idBlue>
|
||||||
|
<typeID>200</typeID>
|
||||||
|
<trigger>
|
||||||
|
<name>-</name>
|
||||||
|
<xPosition>0</xPosition>
|
||||||
|
<yPosition>0</yPosition>
|
||||||
|
<zPosition>0</zPosition>
|
||||||
|
<targetIdGreen>-</targetIdGreen>
|
||||||
|
<targetIdBlue>-</targetIdBlue>
|
||||||
|
<distance>1.0</distance>
|
||||||
|
<isBiggerThan>false</isBiggerThan>
|
||||||
|
<objectNum>0</objectNum>
|
||||||
|
<luaScript>-</luaScript>
|
||||||
|
<toChangeIdGreen>0</toChangeIdGreen>
|
||||||
|
<toChangeIdBlue>0</toChangeIdBlue>
|
||||||
|
<toChangeObjNum>0</toChangeObjNum>
|
||||||
|
</trigger>
|
||||||
|
<positionConstraint>
|
||||||
|
<objectNum>0</objectNum>
|
||||||
|
<xPosition>200.5</xPosition>
|
||||||
|
<yPosition>30.0</yPosition>
|
||||||
|
<zPosition>-222.5</zPosition>
|
||||||
|
<strength>20</strength>
|
||||||
|
</positionConstraint>
|
||||||
|
</composition>
|
||||||
|
|
||||||
|
<composition>
|
||||||
|
<scale>1.0</scale>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
|
<xPos>198.500000</xPos>
|
||||||
|
<yOffset>0.0</yOffset>
|
||||||
|
<zPos>-213.500000</zPos>
|
||||||
|
<idGreen>2</idGreen>
|
||||||
|
<idBlue>221</idBlue>
|
||||||
|
<typeID>200</typeID>
|
||||||
|
<trigger>
|
||||||
|
<name>-</name>
|
||||||
|
<xPosition>0</xPosition>
|
||||||
|
<yPosition>0</yPosition>
|
||||||
|
<zPosition>0</zPosition>
|
||||||
|
<targetIdGreen>-</targetIdGreen>
|
||||||
|
<targetIdBlue>-</targetIdBlue>
|
||||||
|
<distance>1.0</distance>
|
||||||
|
<isBiggerThan>false</isBiggerThan>
|
||||||
|
<objectNum>0</objectNum>
|
||||||
|
<luaScript>-</luaScript>
|
||||||
|
<toChangeIdGreen>0</toChangeIdGreen>
|
||||||
|
<toChangeIdBlue>0</toChangeIdBlue>
|
||||||
|
<toChangeObjNum>0</toChangeObjNum>
|
||||||
|
</trigger>
|
||||||
|
</composition>
|
||||||
|
|
||||||
|
<composition>
|
||||||
|
<scale>1.0</scale>
|
||||||
|
<xRot>0.0</xRot>
|
||||||
|
<yRot>0.0</yRot>
|
||||||
|
<zRot>0.0</zRot>
|
||||||
|
<manualPos>false</manualPos>
|
||||||
|
<xPos>191.500000</xPos>
|
||||||
|
<yOffset>0.0</yOffset>
|
||||||
|
<zPos>-213.500000</zPos>
|
||||||
|
<idGreen>2</idGreen>
|
||||||
|
<idBlue>220</idBlue>
|
||||||
|
<typeID>200</typeID>
|
||||||
|
<trigger>
|
||||||
|
<name>-</name>
|
||||||
|
<xPosition>0</xPosition>
|
||||||
|
<yPosition>0</yPosition>
|
||||||
|
<zPosition>0</zPosition>
|
||||||
|
<targetIdGreen>-</targetIdGreen>
|
||||||
|
<targetIdBlue>-</targetIdBlue>
|
||||||
|
<distance>1.0</distance>
|
||||||
|
<isBiggerThan>false</isBiggerThan>
|
||||||
|
<objectNum>0</objectNum>
|
||||||
|
<luaScript>-</luaScript>
|
||||||
|
<toChangeIdGreen>0</toChangeIdGreen>
|
||||||
|
<toChangeIdBlue>0</toChangeIdBlue>
|
||||||
|
<toChangeObjNum>0</toChangeObjNum>
|
||||||
|
</trigger>
|
||||||
|
</composition>
|
||||||
|
|
||||||
<composition>
|
<composition>
|
||||||
<scale>1.0</scale>
|
<scale>1.0</scale>
|
||||||
<xRot>0.0</xRot>
|
<xRot>0.0</xRot>
|
||||||
|
7
level.cc
7
level.cc
@ -248,6 +248,7 @@ void Level::load() {
|
|||||||
float mass;
|
float mass;
|
||||||
errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&mass));
|
errorCheck(xmlObject->FirstChildElement("mass")->QueryFloatText(&mass));
|
||||||
float dampningL, dampningA;
|
float dampningL, dampningA;
|
||||||
|
bool rotate = true;
|
||||||
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
|
errorCheck(objectData->FirstChildElement("dampningL")->QueryFloatText(&dampningL));
|
||||||
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
|
errorCheck(objectData->FirstChildElement("dampningA")->QueryFloatText(&dampningA));
|
||||||
if (physicType.compare("Player") == 0){
|
if (physicType.compare("Player") == 0){
|
||||||
@ -259,15 +260,15 @@ void Level::load() {
|
|||||||
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
||||||
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
||||||
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
|
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){
|
}else if (physicType.compare("Button") == 0){
|
||||||
float width, height, length;
|
float width, height, length;
|
||||||
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
errorCheck(objectData->FirstChildElement("width")->QueryFloatText(&width));
|
||||||
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
errorCheck(objectData->FirstChildElement("height")->QueryFloatText(&height));
|
||||||
errorCheck(objectData->FirstChildElement("length")->QueryFloatText(&length));
|
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){
|
}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{
|
} else{
|
||||||
printf("XMLError: Not a valid physicType.\n");
|
printf("XMLError: Not a valid physicType.\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
10
physics.cc
10
physics.cc
@ -25,7 +25,7 @@ void Physics::takeUpdateStep(float timeDiff)
|
|||||||
{
|
{
|
||||||
if(allPositionConstraints[i].position != allPositionConstraints[i].body->getCenterOfMassPosition())
|
if(allPositionConstraints[i].position != allPositionConstraints[i].body->getCenterOfMassPosition())
|
||||||
{
|
{
|
||||||
btVector3 dir = allPositionConstraints[i].body->getCenterOfMassPosition() - allPositionConstraints[i].position;
|
btVector3 dir = allPositionConstraints[i].position - allPositionConstraints[i].body->getCenterOfMassPosition();
|
||||||
allPositionConstraints[i].body->applyCentralForce(dir*allPositionConstraints[i].strength);
|
allPositionConstraints[i].body->applyCentralForce(dir*allPositionConstraints[i].strength);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -176,7 +176,7 @@ void Physics::addPlayer(float friction, float rad, Entity entity, float mass, fl
|
|||||||
addCamera();
|
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
|
{//TODO look at convexHullShapes
|
||||||
|
|
||||||
if(bodies.size() == indice)
|
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" );
|
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)
|
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" );
|
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)
|
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" );
|
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)
|
if(bodies.size() == indice)
|
||||||
throw std::invalid_argument( "Bodies out of Sync" );
|
throw std::invalid_argument( "Bodies out of Sync" );
|
||||||
|
@ -58,15 +58,15 @@ class Physics {
|
|||||||
void updateCameraPos(glm::vec2 mouseMovement, float strength);
|
void updateCameraPos(glm::vec2 mouseMovement, float strength);
|
||||||
glm::vec3 getCameraPosition();
|
glm::vec3 getCameraPosition();
|
||||||
void addRigidBodyFromFile(Entity entity, float mass, float dampningL, float dampningA, std::string modelLocation, unsigned indice);
|
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 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 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 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 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); //this is used to ensuer that the system is synchronized
|
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 addPositionConstraint(int bodyIndice, float strength, glm::vec3 position);
|
||||||
void removePositionConstraint(int bodyIndice);
|
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();
|
glm::vec3 getCameraToPlayer();
|
||||||
|
|
||||||
struct positionConstraint{btRigidBody* body; float strength; btVector3 position;};
|
struct positionConstraint{btRigidBody* body; float strength; btVector3 position;};
|
||||||
|
Loading…
Reference in New Issue
Block a user