glUniformMatrix4fv(tmp, 1, GL_FALSE, value_ptr(_model));
}
+Model::operator btCollisionShape*() const
+{
+ return bt_collision_shape;
+}
Overlap Model::isColliding(const Model* _modelThis, const Model* _modelOther, const mat4& _modelMatThis, const mat4& _modelMatOther)
{
#include "../../Overlap.h"
+#include <btBulletDynamicsCommon.h>
+
class Shader;
class Texture;
class Overlap;
virtual operator std::string() const = 0;
+ virtual operator btCollisionShape*() const;
+
class SplitMat
{
public:
static vec3 rotateSize(const vec3& size, const mat4& modelMat);
static float directSize(const vec3& size, const vec3& direction);
+ //Bullet
+ btCollisionShape* bt_collision_shape;
+
private:
// vec3 BBmin, BBmax;
// vec3 BBsize, BBposition;
#include <iostream>
+#include <btBulletDynamicsCommon.h>
+
using std::list;
using std::set;
using std::stack;
#define timestep 0.01f
+#define SCENE_SIZE 500.0
+#define MAX_OBJECTS 16000
+
+
Scene::Scene(unsigned int x, unsigned int y, unsigned int width, unsigned int height, float fovy, float zNear, float zFar, vec3 pos, SceneObject* _lookat) :
viewPort(x, y, width, height, fovy, zNear, zFar),
move_delta(0)
{
currenttime = 0;
+
+ bt_collision_configuration = new btDefaultCollisionConfiguration();
+ bt_dispatcher = new btCollisionDispatcher(bt_collision_configuration);
+
+ btScalar sscene_size = (btScalar)SCENE_SIZE;
+ btVector3 worldAabbMin(-sscene_size, -sscene_size, -sscene_size);
+ btVector3 worldAabbMax(sscene_size, sscene_size, sscene_size);
+
+ bt_broadphase = new bt32BitAxisSweep3(worldAabbMin, worldAabbMax, MAX_OBJECTS, 0, true);
+
+ bt_collision_world = new btCollisionWorld(bt_dispatcher, bt_broadphase, bt_collision_configuration);
}
delete (*i);
}
-
-
+ //Bullet
+ delete bt_collision_world;
+ delete bt_broadphase;
+ delete bt_dispatcher;
+ delete bt_collision_configuration;
+
//if (viewPort != nullptr)
// delete viewPort;
#include <list>
#include <set>
+#include <btBulletDynamicsCommon.h>
#include <stack>
class SceneObject;
float currenttime;
std::stack<mat4> PlayerModels;
//std::stack<vec3> PlayerDirections;
+
+ //class btDefaultCollisionConfiguration;
+ //class btCollisionDispatcher;
+ //class btDbvtBroadphase;
+ //class btSequentialImpulseConstraintSolver;
+ //class btDiscreteDynamicsWorld;
+
+ //Bullet
+ btCollisionConfiguration* bt_collision_configuration;
+ btCollisionDispatcher* bt_dispatcher;
+ btBroadphaseInterface* bt_broadphase;
+ btCollisionWorld* bt_collision_world;
};
#define YFALL_SPEED 9.8f
+#define BIT(x) 1<<(X)
+
SceneObject::SceneObject(Shader* _shader, const mat4& _modelMat, const vec4& _material, string _modelpath, string texturepath) :
model(nullptr),
modelMat(_modelMat),
ySpeed(0),
yStatic(true),
ignore(false),
-newModel(true)
+newModel(true),
+bt_collision_object(new btCollisionObject())
{
//Message::info("Error from befor?");
//Graphix::getGlError();
//Graphix::getGlError();
//Message::info("Done");
+ bt_collision_object->setCollisionShape(*model);
}
SceneObject::SceneObject(Shader* _shader, const mat4& _modelMat, const vec4& _material, Model* _model, string texturepath) :
ySpeed(0),
yStatic(true),
ignore(false),
-newModel(false)
+newModel(false),
+bt_collision_object(new btCollisionObject())
{
//Message::info("Error from befor?");
//Graphix::getGlError();
//Message::info("Binding Shader");
//Graphix::getGlError();
//Message::info("Done");
-
+
+ //TypeCast btCollisionShape
+ bt_collision_object->setCollisionShape(*model);
}
SceneObject::~SceneObject()
Texture::deleteTexture(*texture);
if (newModel)
Model::deleteIMetaModel(*model);
+
+ delete bt_collision_object;
}
float SceneObject::getFloor() const
#include "../GLM.h"
#include <string>
+#include <btBulletDynamicsCommon.h>
+
using std::string;
class Scene;
bool collision_ignore;
+ //Bullet
+ btCollisionObject* bt_collision_object;
+
};