]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
Bulllet Collision working
authorPeter Schaefer <schaeferpm@gmail.com>
Tue, 9 Jun 2015 06:49:03 +0000 (08:49 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Tue, 9 Jun 2015 06:49:03 +0000 (08:49 +0200)
Weave/Graphix/Model/IMetaMesh.cpp

index 494a3a03ac4296e2ad05759a387ee8c9fbec70a3..6a0b3cff431e7780e360dd640074085c0658d30a 100644 (file)
@@ -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<IMesh*,mat4>(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<IMesh*, mat4>(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);
                        }
                }
        }