genBuffer(vertexBuffer, numvertices * 3 * sizeof(float), (void*)vertex);
// genBuffer(indexBuffer, 4 * sizeof(float), (void*)indexL1);
+ bt_collision_shape = new btBoxShape(btVector3(.5f,.5f,.5f));
+
}
BBox::~BBox()
{
+ //delete bt_collision_shape; //done inside Model.cpp
+
glDeleteBuffers(1, &vertexBuffer);
//glDeleteBuffers(1, &indexBuffer);
//glDeleteBuffers(1, &normalBuffer);
import(_modelpath, numvertices, numfaces, vertex, uvs, normals, index, _mindex);
+ btConvexHullShape* tmp_shape = new btConvexHullShape();
+
+ for (int i = 0; i < numvertices; i += 3)
+ tmp_shape->addPoint(btVector3(vertex[i], vertex[i + 1], vertex[i + 2]));
+
+ bt_collision_shape = tmp_shape;
+
#ifdef COMPARE_MTREE
root = buildMeshTree(mat4(1.f), numvertices, numfaces, vertex, normals, index);
import(_mesh, numvertices, numfaces, vertex, uvs, normals, index);
+ btConvexHullShape* tmp_shape = new btConvexHullShape();
+
+ for (int i = 0; i < numvertices; i += 3)
+ tmp_shape->addPoint(btVector3(vertex[i], vertex[i + 1], vertex[i + 2]));
+
+ bt_collision_shape = tmp_shape;
+
#ifdef COMPARE_MTREE
root = buildMeshTree(_transformation, numvertices, numfaces, vertex, normals, index);
mat4 tmpModelMat;
//vec3 BBmin, BBmax, tmpMin, tmpMax;
+ btCompoundShape* tmp_shape = new btCompoundShape;
+
aimat = &(root->mChildren[0]->mTransformation);
tmpModelMat = mat4(aimat->a1, aimat->c1, -aimat->b1, aimat->d1, aimat->a2, aimat->c2, -aimat->b2, aimat->d2, aimat->a3, aimat->c3, -aimat->b3, aimat->d3, aimat->a4, aimat->c4, -aimat->b4, aimat->d4);
models.push_back(tmpIMesh);
setBB(tmpIMesh->getBBox());
+
+ tmp_shape->addChildShape(btTransform(),*tmpIMesh);
+
for (uint i = 1; i < scene->mNumMeshes; i++)
{
aimat = &(root->mChildren[i]->mTransformation);
tmpIMesh = new IMesh(scene->mMeshes[i], tmpModelMat);
models.push_back(tmpIMesh);
updateBB(tmpIMesh->getBBox());
+
+ tmp_shape->addChildShape(btTransform(), *tmpIMesh);
//tmpIMesh->getBBmm(tmpMin, tmpMax);
//for (auto j = 0; j < 3; ++j)
//{
}
//setBB(BBmin, BBmax);
+
+ bt_collision_shape = tmp_shape;
}
else
{
vertexBuffer(-1),
normalBuffer(-1),
uvBuffer(-1),
-indexBuffer(-1)
+indexBuffer(-1),
+bt_collision_shape(nullptr)
{
}
Model::~Model()
{
+ if (bt_collision_shape!=nullptr)
+ delete bt_collision_shape;
for (auto i = shader_map.begin(); i != shader_map.end(); ++i){
glDeleteVertexArrays(1, &(i->second));
}