From: Peter Schaefer Date: Tue, 9 Jun 2015 06:49:03 +0000 (+0200) Subject: Bulllet Collision working X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=33f4f50b9bcdc3bd8e79fc1fefabad0dc8056901;p=cgue_weave.git Bulllet Collision working --- diff --git a/Weave/Graphix/Model/IMetaMesh.cpp b/Weave/Graphix/Model/IMetaMesh.cpp index 494a3a0..6a0b3cf 100644 --- a/Weave/Graphix/Model/IMetaMesh.cpp +++ b/Weave/Graphix/Model/IMetaMesh.cpp @@ -31,6 +31,7 @@ IMetaMesh::IMetaMesh(const string& _modelpath, const vec3& _scale) : modelpath(_ IMesh* tmpIMesh; aiMatrix4x4* aimat; mat4 tmpModelMat, tmpModelMatClean; + btTransform tmpModelMatBT; //vec3 BBmin, BBmax, tmpMin, tmpMax; btCompoundShape* tmp_shape = new btCompoundShape; @@ -39,12 +40,11 @@ IMetaMesh::IMetaMesh(const string& _modelpath, const vec3& _scale) : modelpath(_ 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); tmpModelMatClean = removeScale(tmpModelMat); + tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean)); tmpIMesh = new IMesh(scene->mMeshes[0], tmpModelMatClean, _scale* getScale(tmpModelMat)); models.push_back(std::pair(tmpIMesh,tmpModelMatClean)); setBB(tmpIMesh->getBBox()); - - - tmp_shape->addChildShape(btTransform(),*tmpIMesh); + tmp_shape->addChildShape(tmpModelMatBT,*tmpIMesh); for (uint i = 1; i < scene->mNumMeshes; i++) { @@ -52,11 +52,12 @@ IMetaMesh::IMetaMesh(const string& _modelpath, const vec3& _scale) : modelpath(_ 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); tmpModelMatClean = removeScale(tmpModelMat); + tmpModelMatBT.setFromOpenGLMatrix(value_ptr(tmpModelMatClean)); tmpIMesh = new IMesh(scene->mMeshes[i], tmpModelMatClean, _scale* getScale(tmpModelMat)); models.push_back(std::pair(tmpIMesh, tmpModelMatClean)); updateBB(tmpIMesh->getBBox()); - tmp_shape->addChildShape(btTransform(), *tmpIMesh); + tmp_shape->addChildShape(tmpModelMatBT, *tmpIMesh); //tmpIMesh->getBBmm(tmpMin, tmpMax); //for (auto j = 0; j < 3; ++j) //{ @@ -109,7 +110,7 @@ void IMetaMesh::drawBBox(const mat4& _modelMat,const vec4& _color) const if (models.size() == 1) { auto i = models.front(); - i.first->drawBBox(_modelMat* i.second, _color); + i.first->drawBBox(_modelMat, _color); } else { @@ -118,7 +119,7 @@ void IMetaMesh::drawBBox(const mat4& _modelMat,const vec4& _color) const { for (auto i = models.begin(); i != models.end(); ++i) { - i->first->drawBBox(_modelMat* i->second, _color*0.8f); + i->first->drawBBox(_modelMat, _color*0.8f); } } }