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

This commit is contained in:
Steffen Fündgens 2014-12-15 16:34:54 +01:00
commit 04e5b3a5ac
7 changed files with 169 additions and 29 deletions

BIN
Blenderfiles/torch.blend Normal file

Binary file not shown.

View File

@ -5,7 +5,7 @@
<xOffset>0.0</xOffset> <xOffset>0.0</xOffset>
<yOffset>0.0</yOffset> <yOffset>0.0</yOffset>
<zOffset>0.0</zOffset> <zOffset>0.0</zOffset>
<scale>0.75</scale> <scale>1.0</scale>
<mass>8.0</mass> <mass>8.0</mass>
</object> </object>
</composition> </composition>
@ -17,8 +17,8 @@
<xOffset>0.0</xOffset> <xOffset>0.0</xOffset>
<yOffset>1.0</yOffset> <yOffset>1.0</yOffset>
<zOffset>2.0</zOffset> <zOffset>2.0</zOffset>
<scale>1.0</scale> <scale>1.5</scale>
<mass>2.0</mass> <mass>0.0</mass>
</object> </object>
</composition> </composition>
@ -35,7 +35,7 @@
</composition> </composition>
<composition> <composition>
<typeID>99</typeID> <typeID>80</typeID>
<object> <object>
<modelPath>torch.obj</modelPath> <modelPath>torch.obj</modelPath>
<xOffset>0.0</xOffset> <xOffset>0.0</xOffset>
@ -55,14 +55,15 @@
</light> </light>
</composition> </composition>
<!-- Block on 2 Pillars -->
<composition> <composition>
<typeID>100</typeID> <typeID>99</typeID>
<object> <object>
<modelPath>column.obj</modelPath> <modelPath>column.obj</modelPath>
<xOffset>0.0</xOffset> <xOffset>0.0</xOffset>
<yOffset>0.0</yOffset> <yOffset>0.0</yOffset>
<zOffset>0.0</zOffset> <zOffset>0.0</zOffset>
<scale>1.0</scale> <scale>1.5</scale>
<mass>0.0</mass> <mass>0.0</mass>
</object> </object>
<object> <object>
@ -70,7 +71,7 @@
<xOffset>2.0</xOffset> <xOffset>2.0</xOffset>
<yOffset>0.0</yOffset> <yOffset>0.0</yOffset>
<zOffset>0.0</zOffset> <zOffset>0.0</zOffset>
<scale>1.0</scale> <scale>1.5</scale>
<mass>0.0</mass> <mass>0.0</mass>
</object> </object>
<object> <object>
@ -78,7 +79,7 @@
<xOffset>1.0</xOffset> <xOffset>1.0</xOffset>
<yOffset>3.0</yOffset> <yOffset>3.0</yOffset>
<zOffset>0.0</zOffset> <zOffset>0.0</zOffset>
<scale>1.0</scale> <scale>1.5</scale>
<mass>0.0</mass> <mass>0.0</mass>
</object> </object>
</composition> </composition>
@ -126,9 +127,9 @@
<specularFactor>0.4</specularFactor> <specularFactor>0.4</specularFactor>
<shininess>2.0</shininess> <shininess>2.0</shininess>
<physicType>Box</physicType> <physicType>Box</physicType>
<width>1.0</width> <width>5.0</width>
<height>1.0</height> <height>1.0</height>
<length>3.0</length> <length>1.8</length>
</objectData> </objectData>
<objectData> <objectData>

View File

@ -13,6 +13,7 @@ uniform sampler2D uTexture;
uniform sampler2DShadow shadowMap_near; uniform sampler2DShadow shadowMap_near;
uniform sampler2DShadow shadowMap_middle; uniform sampler2DShadow shadowMap_middle;
uniform sampler2DShadow shadowMap_far; uniform sampler2DShadow shadowMap_far;
uniform samplerCubeShadow shadowMap_cube;
uniform vec3 ambientColor; uniform vec3 ambientColor;
uniform float ambientFactor; uniform float ambientFactor;
uniform float diffuseFactor; uniform float diffuseFactor;
@ -49,7 +50,7 @@ vec2 poissonDisk[16] = vec2[](
vec2( 0.14383161, -0.14100790 ) vec2( 0.14383161, -0.14100790 )
); );
float sampleShadow(sampler2DShadow shadowMap, vec4 shadowCoord) { float sampleDirectionalShadow(sampler2DShadow shadowMap, vec4 shadowCoord) {
float visibility = 1.0; float visibility = 1.0;
float bias = 0.001*tan(acos(clamp(dot(vNormal, -directionalLightVector), 0.0, 1.0))); float bias = 0.001*tan(acos(clamp(dot(vNormal, -directionalLightVector), 0.0, 1.0)));
bias = clamp(bias, 0.0, 0.01); bias = clamp(bias, 0.0, 0.01);
@ -68,6 +69,11 @@ float sampleShadow(sampler2DShadow shadowMap, vec4 shadowCoord) {
return visibility; return visibility;
} }
float samplePointShadow(samplerCubeShadow shadowMap, vec3 lightDirection) {
float bias = 0.005;
return texture(shadowMap, vec4(lightDirection.xyz , length(lightDirection) - bias));
}
float distanceToBorder(vec2 vector) { float distanceToBorder(vec2 vector) {
float xDistance = min(vector.x, 1.0-vector.x); float xDistance = min(vector.x, 1.0-vector.x);
float yDistance = min(vector.y, 1.0-vector.y); float yDistance = min(vector.y, 1.0-vector.y);
@ -92,8 +98,10 @@ void main()
} }
// point lights // point lights
float visibility = 1.0;
for(int i = 0; i<lightCount; i++) { for(int i = 0; i<lightCount; i++) {
float distance = distance(lightSources[i], vec3(fragPosition)); vec3 lightDirection = vec3(fragPosition) - lightSources[i];
float distance = length(lightDirection);
// only take lights into account with meaningful contribution // only take lights into account with meaningful contribution
if (distance > 0.001f) { if (distance > 0.001f) {
vec3 lightVector = normalize(lightSources[i]-vec3(fragPosition)); vec3 lightVector = normalize(lightSources[i]-vec3(fragPosition));
@ -103,21 +111,21 @@ void main()
vec3 cameraVector = normalize(camera - vec3(fragPosition)); vec3 cameraVector = normalize(camera - vec3(fragPosition));
specularColor += clamp(pow((dot((cameraVector+lightVector),normalize(vNormal))/(length(cameraVector+lightVector)*length(normalize(vNormal)))),shininess), 0.0, 1.0) specularColor += clamp(pow((dot((cameraVector+lightVector),normalize(vNormal))/(length(cameraVector+lightVector)*length(normalize(vNormal)))),shininess), 0.0, 1.0)
*specularFactor*intensity*lightColors[i]; *specularFactor*intensity*lightColors[i];
visibility = samplePointShadow(shadowMap_cube, lightDirection);
} }
} }
// shadows // shadows
float visibility = 1.0;
if (distanceToBorder(shadowCoord_middle.xy) <= 0.5 && distanceToBorder(shadowCoord_middle.xy) > 0.0) { if (distanceToBorder(shadowCoord_middle.xy) <= 0.5 && distanceToBorder(shadowCoord_middle.xy) > 0.0) {
if (distanceToBorder(shadowCoord_near.xy) <= 0.5 && distanceToBorder(shadowCoord_near.xy) > 0.0) { if (distanceToBorder(shadowCoord_near.xy) <= 0.5 && distanceToBorder(shadowCoord_near.xy) > 0.0) {
visibility = sampleShadow(shadowMap_near, shadowCoord_near); visibility *= sampleDirectionalShadow(shadowMap_near, shadowCoord_near);
} }
else { else {
visibility = sampleShadow(shadowMap_middle, shadowCoord_middle); visibility *= sampleDirectionalShadow(shadowMap_middle, shadowCoord_middle);
} }
} }
else { else {
visibility = sampleShadow(shadowMap_far, shadowCoord_far); visibility *= sampleDirectionalShadow(shadowMap_far, shadowCoord_far);
} }
specularColor *= visibility; specularColor *= visibility;

View File

@ -2,7 +2,7 @@
uniform mat4 modelMatrix; uniform mat4 modelMatrix;
uniform mat4 modelViewProjectionMatrix; uniform mat4 modelViewProjectionMatrix;
uniform mat4 shadowMVPs[35]; uniform mat4 shadowMVPs[5];
in vec3 aPosition; in vec3 aPosition;
in vec3 aNormal; in vec3 aNormal;

View File

@ -70,8 +70,10 @@ void Graphics::init(Level* level) {
framebuffer_far->setDepthTexture(depthTexture_far); framebuffer_far->setDepthTexture(depthTexture_far);
framebuffer_far->validate(); framebuffer_far->validate();
depth_cubeMaps = std::vector<ACGL::OpenGL::SharedTextureCubeMap>(level->getLights()->size()); /*depth_cubeMaps = std::vector<ACGL::OpenGL::SharedTextureCubeMap>(level->getLights()->size());
for (unsigned int i = 0; i<depth_cubeMaps.size(); i++) { for (unsigned int i = 0; i<depth_cubeMaps.size(); i++) {*/
depth_cubeMaps = std::vector<ACGL::OpenGL::SharedTextureCubeMap>(1);
for (unsigned int i = 0; i<1; i++) {
depth_cubeMaps.at(i) = SharedTextureCubeMap(new TextureCubeMap(glm::vec2(cube_size, cube_size), GL_DEPTH_COMPONENT16)); depth_cubeMaps.at(i) = SharedTextureCubeMap(new TextureCubeMap(glm::vec2(cube_size, cube_size), GL_DEPTH_COMPONENT16));
depth_cubeMaps.at(i)->setMinFilter(GL_NEAREST); depth_cubeMaps.at(i)->setMinFilter(GL_NEAREST);
depth_cubeMaps.at(i)->setMagFilter(GL_NEAREST); depth_cubeMaps.at(i)->setMagFilter(GL_NEAREST);
@ -102,14 +104,14 @@ void Graphics::render()
glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, 0.0f, -1.0f)}; glm::vec3(0.0f, -1.0f, 0.0f), glm::vec3(0.0f, 0.0f, 1.0f), glm::vec3(0.0f, 0.0f, -1.0f)};
framebuffer_cube->bind(); framebuffer_cube->bind();
for (unsigned int i_pointlight = 0; i_pointlight<level->getLights()->size(); i_pointlight++) { //for (unsigned int i_pointlight = 0; i_pointlight<level->getLights()->size(); i_pointlight++) {
for (unsigned int i_pointlight = 0; i_pointlight<1; i_pointlight++) {
// render each side of the cube // render each side of the cube
for (int i_face = 0; i_face<6; i_face++) { for (int i_face = 0; i_face<6; i_face++) {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(i_pointlight)->getObjectName(), 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i_face, depth_cubeMaps.at(i_pointlight)->getObjectName(), 0);
glClear(GL_DEPTH_BUFFER_BIT); glClear(GL_DEPTH_BUFFER_BIT);
glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * glm::lookAt(level->getLights()->at(i_pointlight).getPosition(), glm::mat4 depthViewProjectionMatrix_face = depthProjectionMatrix_pointlights * glm::lookAt(level->getLights()->at(i_pointlight).getPosition(),
level->getLights()->at(i_pointlight).getPosition() + looking_directions[i_face], glm::vec3(0.0f, 1.0f, 0.0f)); level->getLights()->at(i_pointlight).getPosition() + looking_directions[i_face], glm::vec3(0.0f, 1.0f, 0.0f));
depthShader->setUniform("viewProjectionMatrix", depthViewProjectionMatrix_face);
level->render(depthShader, false, &depthViewProjectionMatrix_face); level->render(depthShader, false, &depthViewProjectionMatrix_face);
if (!framebuffer_cube->isFrameBufferObjectComplete()) { if (!framebuffer_cube->isFrameBufferObjectComplete()) {
printf("Framebuffer incomplete, unknown error occured during shadow generation!\n"); printf("Framebuffer incomplete, unknown error occured during shadow generation!\n");
@ -182,6 +184,8 @@ void Graphics::render()
} }
glUniform1fv(lightingShader->getUniformLocation("lightIntensities"), glUniform1fv(lightingShader->getUniformLocation("lightIntensities"),
sizeof(lightIntensities), (GLfloat*) lightIntensities); sizeof(lightIntensities), (GLfloat*) lightIntensities);
lightingShader->setTexture("shadowMap_cube", depth_cubeMaps.at(0), 4);
} }
// set directional Light // set directional Light
if(level->getDirectionalLight()) { if(level->getDirectionalLight()) {

View File

@ -1,4 +1,5 @@
#include "physics.hh" #include "physics.hh"
#include "extern/bullet/Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h"
Physics::Physics() { Physics::Physics() {
@ -23,6 +24,44 @@ void Physics::takeUpdateStep(float timeDiff)
world->stepSimulation(timeDiff); world->stepSimulation(timeDiff);
} }
//TERRAIN SUBSET
void Physics::addTerrainTriangles(int width, int length, float** heightData)
{//not working correctly something with offset wrong?
btTriangleMesh* trimesh = new btTriangleMesh();
for(int i = 0; i < width-1;i++)
{
for(int j = 0; j < length-1; j++)
{
btVector3 v0(i,heightData[j][i],j);
btVector3 v1(i+1,heightData[j][i+1],j);
btVector3 v2(i,heightData[j+1][i],j+1);
trimesh->addTriangle(v0,v1,v2);
}
}
for(int i = 1; i < width;i++)
{
for(int j = 1; j < length; j++)
{
btVector3 v0(i,heightData[j][i],j);
btVector3 v1(i-1,heightData[j][i-1],j);
btVector3 v2(i,heightData[j-1][i],j-1);
trimesh->addTriangle(v0,v1,v2);
}
}
btBvhTriangleMeshShape* shape = new btBvhTriangleMeshShape(trimesh, true);
btRigidBody* tBody = new btRigidBody(0, new btDefaultMotionState(),shape);
tBody->getWorldTransform().setOrigin(btVector3(-length/2,0,-width/2));
terrainBody = tBody;
world->addRigidBody(tBody);
}
void Physics::addTerrain(int width, int length, float** heightData) void Physics::addTerrain(int width, int length, float** heightData)
{ {
@ -50,7 +89,7 @@ void Physics::addTerrain(int width, int length, float** heightData)
terrainBody = tBody; terrainBody = tBody;
world->addRigidBody(terrainBody); world->addRigidBody(terrainBody, COL_TERRAIN, COL_TERRAIN | COL_OBJECTS);
} }
void Physics::addStaticGroundPlane() void Physics::addStaticGroundPlane()
@ -63,6 +102,8 @@ void Physics::addStaticGroundPlane()
world->addRigidBody(staticGroundBody); world->addRigidBody(staticGroundBody);
} }
//players and objects
void Physics::addPlayer(float rad, Entity entity, float mass, unsigned indice) void Physics::addPlayer(float rad, Entity entity, float mass, unsigned indice)
{ {
if(bodies.size() == indice) if(bodies.size() == indice)
@ -79,6 +120,8 @@ void Physics::addPlayer(float rad, Entity entity, float mass, unsigned indice)
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia); btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia);
info.m_friction = 5;
playerBall = new btRigidBody(info); playerBall = new btRigidBody(info);
playerBall->setDamping(0.1f,0.3f); playerBall->setDamping(0.1f,0.3f);
@ -93,6 +136,77 @@ void Physics::addPlayer(float rad, Entity entity, float mass, unsigned indice)
} }
void Physics::addTriangleMeshBody(Entity entity, std::string path, float mass, float dampningL, float dampningA,unsigned indice)
{//TODO look at convexHullShapes
if(bodies.size() == indice)
throw std::invalid_argument( "Bodies out of Sync" );
std::vector< unsigned int > vertexIndices;
std::vector< btVector3 > temp_vertices;
path = "../Levels/Geometry/" + path;
FILE * file = fopen(path.c_str(), "r");
if( file == NULL ){
printf("Impossible to open the file !\n");
}
while( 1 ){
char lineHeader[128];
// read the first word of the line
int res = fscanf(file, "%s", lineHeader);
if (res == EOF)
break; // EOF = End Of File. Quit the loop.
// else : parse lineHeader
if ( strcmp( lineHeader, "v" ) == 0 ){
glm::vec3 vertex;
fscanf(file, "%f %f %f\n", &vertex.x, &vertex.y, &vertex.z );
temp_vertices.push_back(btVector3(vertex.x,vertex.y,vertex.z));
}
else if ( strcmp( lineHeader, "f" ) == 0 ){
std::string vertex1, vertex2, vertex3;
unsigned int vertexIndex[3], uvIndex[3], normalIndex[3];
int matches = fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%d\n", &vertexIndex[0], &uvIndex[0], &normalIndex[0], &vertexIndex[1], &uvIndex[1], &normalIndex[1], &vertexIndex[2], &uvIndex[2], &normalIndex[2] );
vertexIndices.push_back(vertexIndex[0]);
vertexIndices.push_back(vertexIndex[1]);
vertexIndices.push_back(vertexIndex[2]);
}
}
printf("olla");
//finally start making body
btTriangleMesh* triMesh = new btTriangleMesh();
for(unsigned i = 2; i < vertexIndices.size();i++)
{
triMesh->addTriangle(temp_vertices[vertexIndices[i]],temp_vertices[vertexIndices[i-1]],temp_vertices[vertexIndices[i-2]]);
}
btBvhTriangleMeshShape* shape = new btBvhTriangleMeshShape(triMesh,true);
btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z)));
btVector3 inertia(0,0,0);
if(mass != 0.0)
{
shape->calculateLocalInertia((btScalar)mass,inertia);
}
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,shape,inertia);
btRigidBody* body = new btRigidBody(info);
body->setDamping(dampningL,dampningA);
bodies.push_back(body);
world->addRigidBody(body);
if(bodies.size() != indice)
throw std::invalid_argument( "Bodies out of Sync" );
}
void Physics::addBox(float width, float height, float length, Entity entity, float mass, unsigned indice) void Physics::addBox(float width, float height, float length, Entity entity, float mass, unsigned indice)
{ {
@ -138,7 +252,7 @@ void Physics::addSphere(float rad, Entity entity, float mass, unsigned indice)
btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z))); btDefaultMotionState* motion = new btDefaultMotionState(btTransform(btQuaternion(0,0,0,1),btVector3(entity.getPosition().x,entity.getPosition().y,entity.getPosition().z)));
btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia); btRigidBody::btRigidBodyConstructionInfo info(mass,motion,sphere,inertia);
//info.
btRigidBody* body = new btRigidBody(info); btRigidBody* body = new btRigidBody(info);
@ -154,7 +268,7 @@ void Physics::addSphere(float rad, Entity entity, float mass, unsigned indice)
throw std::invalid_argument( "Bodies out of Sync" ); throw std::invalid_argument( "Bodies out of Sync" );
} }
/*
void Physics::addTriangleMeshBody(Entity entity, float mass, float dampningL, float dampningA,unsigned indice) void Physics::addTriangleMeshBody(Entity entity, float mass, float dampningL, float dampningA,unsigned indice)
{ {
btTriangleMesh* trimesh = new btTriangleMesh(); btTriangleMesh* trimesh = new btTriangleMesh();
@ -180,7 +294,7 @@ void Physics::addTriangleMeshBody(Entity entity, float mass, float dampningL, fl
body->setDamping(dampningL,dampningA); body->setDamping(dampningL,dampningA);
} }*/
void Physics::addCamera(float rad, float distance) void Physics::addCamera(float rad, float distance)
{ {
@ -206,6 +320,8 @@ void Physics::addCamera(float rad, float distance)
world->addConstraint(pdc); world->addConstraint(pdc);
} }
//update functions
glm::vec3 Physics::getCameraPosition() glm::vec3 Physics::getCameraPosition()
{ {
btVector3 origin = cameraBody->getCenterOfMassPosition(); btVector3 origin = cameraBody->getCenterOfMassPosition();

View File

@ -4,6 +4,8 @@
#include <ACGL/Base/Settings.hh> #include <ACGL/Base/Settings.hh>
#include <ACGL/Math/Math.hh> #include <ACGL/Math/Math.hh>
#include <vector> #include <vector>
#include <string>
#include <stdio.h>
#include "entity.hh" #include "entity.hh"
@ -17,6 +19,8 @@
#include "extern/bullet/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h" #include "extern/bullet/src/BulletCollision/CollisionShapes/btStaticPlaneShape.h"
#include "extern/bullet/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h" #include "extern/bullet/src/BulletCollision/CollisionShapes/btBvhTriangleMeshShape.h"
#include "extern/bullet/src/BulletCollision/CollisionShapes/btTriangleMesh.h" #include "extern/bullet/src/BulletCollision/CollisionShapes/btTriangleMesh.h"
#include "extern/bullet/src/BulletCollision/CollisionShapes/btCollisionShape.h"
#include "extern/bullet/src/BulletCollision/CollisionShapes/btConvexTriangleMeshShape.h"
#include "extern/bullet/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h" #include "extern/bullet/src/BulletDynamics/ConstraintSolver/btConstraintSolver.h"
#include "extern/bullet/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"//YAY! #include "extern/bullet/src/BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"//YAY!
@ -51,20 +55,21 @@ class Physics {
void addStaticGroundPlane(); void addStaticGroundPlane();
void addCamera(float rad,float distance); //Do NOT impliment before Player has been created; void addCamera(float rad,float distance); //Do NOT impliment before Player has been created;
glm::vec3 getCameraPosition(); glm::vec3 getCameraPosition();
void addTriangleMeshBody(Entity entity, float mass, float dampningL, float dampningA,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 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 addPlayer(float rad, Entity entity, float mass, unsigned indice); //use these AFTER physicObjects.push_back(object)! if mass == 0 then the object is unmoveable void addPlayer(float rad, Entity entity, float mass, 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, unsigned indice); //The Indice should be set to physicObjects.size() void addSphere(float rad, Entity entity, float mass, unsigned indice); //The Indice should be set to physicObjects.size()
void addBox(float width, float height, float length, Entity entity, float mass, unsigned indice); //this is used to ensuer that the system is synchronized void addBox(float width, float height, float length, Entity entity, float mass, unsigned indice); //this is used to ensuer that the system is synchronized
private: private:
btRigidBody* playerBall; //allows for quicker access to the ball btRigidBody* playerBall; //allows for easier access to the ball
btRigidBody* terrainBody; //duh btRigidBody* terrainBody; //duh
btRigidBody* cameraBody; btRigidBody* cameraBody;
std::vector<btRigidBody*> bodies; //list of all bodies. bodies are also in world, but save again to ease cleaning up process. std::vector<btRigidBody*> bodies; //list of all bodies. bodies are also in world, but save again to ease cleaning up process.
btRigidBody* staticGroundBody; btRigidBody* staticGroundBody;
btDynamicsWorld* world; //contains physical attributes of the world. btDynamicsWorld* world; //contains physical attributes of the world.
btDispatcher* dispatcher; // btDispatcher* dispatcher; //
btCollisionConfiguration* colConfig; //defines the type of collision detection. btCollisionConfiguration* colConfig; //defines the type of collision detection.
@ -72,6 +77,12 @@ class Physics {
btConstraintSolver* solver; //solver for forces and impulses. btConstraintSolver* solver; //solver for forces and impulses.
}; };
enum collisionTypes{
COL_NOTHING = 0,
COL_TERRAIN = 1,
COL_OBJECTS = 2,
COL_OBJECTS_NO_TERRAIN = 4
};
class btDistanceConstraint : public btPoint2PointConstraint class btDistanceConstraint : public btPoint2PointConstraint
{ {