]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
removed scaling fom Normals
authorPeter Schaefer <schaeferpm@gmail.com>
Tue, 16 Jun 2015 12:52:43 +0000 (14:52 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Tue, 16 Jun 2015 12:52:43 +0000 (14:52 +0200)
fixed not every point was loaded

Weave/Graphix/Model/IMesh.cpp
Weave/Graphix/Model/Model.cpp
Weave/Graphix/ViewPort.h

index 7c31d93c7e53232751e7c7da79b65d1608d7d85b..2058da7a7da30075d9de16379ba1f6f925d0c4ab 100644 (file)
@@ -55,27 +55,27 @@ IMesh::IMesh(const aiMesh* _mesh, const vec3& _scale) : modelpath("IMesh")
        import(_mesh, numvertices, numfaces, vertex, uvs, normals, index, _scale);
 
        btConvexHullShape* tmp_shape = new btConvexHullShape();
+       btTriangleMesh* tmp_mesh = new btTriangleMesh();
 
-       for (uint i = 0; i < numvertices; i += 3)
-               tmp_shape->addPoint(btVector3(vertex[i], vertex[i + 1], vertex[i + 2]));
-
-       //tmp_shape->recalcLocalAabb();
-       bt_collision_shape = tmp_shape;
+       for (uint i = 0; i < numfaces * 3; i += 3)
+       {
+               tmp_mesh->addTriangle(
+                       btVector3(vertex[index[i]], vertex[index[i] + 1], vertex[index[i] + 2]),
+                       btVector3(vertex[index[i + 1]], vertex[index[i + 1] + 1], vertex[index[i + 1] + 2]),
+                       btVector3(vertex[index[i + 2]], vertex[index[i + 2] + 1], vertex[index[i + 2] + 2]),
+                       false);
 
-       btVector3 minB,maxB;
-       btTransform t;
-       t.setIdentity();
+       }
 
-       tmp_shape->getAabb(t, minB, maxB);
+       //Message::info(std::to_string(tmp_mesh->getNumTriangles()));
 
-       //minB = t(minB);
-       //maxB = t(maxB);
-
-       vec3 min = (vec3)(vec4(minB.getX(), minB.getY(), minB.getZ(), 0.f));
-       vec3 max = (vec3)(vec4(maxB.getX(), maxB.getY(), maxB.getZ(), 0.f));
+       for (uint i = 0; i < numvertices*3; i += 3)
+               tmp_shape->addPoint(btVector3(vertex[i], vertex[i + 1], vertex[i + 2]));
 
-       vec3 size = (max - min) * .5f;
-       vec3 center = (max + min) * .5f;
+       //tmp_shape->recalcLocalAabb();
+       //bt_collision_shape = new btBvhTriangleMeshShape(tmp_mesh,true);
+       bt_collision_shape = new btConvexTriangleMeshShape(tmp_mesh,true);
+       //bt_collision_shape = tmp_shape;
 
        setBB(numvertices, vertex);
 
index 7608e9c5f011118cd1224316c28266a9e692327d..e010a4a8c489ca0acdd3244a30c8cf5c4be1de62 100644 (file)
@@ -428,9 +428,9 @@ bool Model::import(const aiMesh* mesh, uint& numvertices, uint& numfaces, float*
        //load normals from Mesh
        for (uint i = 0; i < numvertices; i++)
        {
-               normals[3 * i] = mesh->mNormals[i].x / _scale.x;
-               normals[3 * i + 1] = mesh->mNormals[i].y / _scale.y;
-               normals[3 * i + 2] = mesh->mNormals[i].z / _scale.z;
+               normals[3 * i] = mesh->mNormals[i].x;// / _scale.x;
+               normals[3 * i + 1] = mesh->mNormals[i].y;// / _scale.y;
+               normals[3 * i + 2] = mesh->mNormals[i].z;// / _scale.z;
        }
 
        return true;
index a4c28f47ea3cf263acd59e812f2065c9f1490665..02c4a9aa2246e7de516693abd5b2615e91f74e93 100644 (file)
@@ -13,6 +13,8 @@ public:
 
        void useViewPort() const;
 
+       void setView(unsigned int width, unsigned int height);
+
        void bindView(Shader* shader) const;
        void bindView(Shader* shader, vec3 lookat) const;