diff --git a/AssimpToMesh/AssimpToMesh.vcxproj b/AssimpToMesh/AssimpToMesh.vcxproj
index 46477b8..2c7977b 100644
--- a/AssimpToMesh/AssimpToMesh.vcxproj
+++ b/AssimpToMesh/AssimpToMesh.vcxproj
@@ -80,7 +80,9 @@
+
+
@@ -88,8 +90,13 @@
+
+
+
+
+
diff --git a/AssimpToMesh/AssimpToMesh.vcxproj.filters b/AssimpToMesh/AssimpToMesh.vcxproj.filters
index 9a185ee..7a4b7e3 100644
--- a/AssimpToMesh/AssimpToMesh.vcxproj.filters
+++ b/AssimpToMesh/AssimpToMesh.vcxproj.filters
@@ -33,6 +33,12 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
@@ -47,5 +53,20 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
\ No newline at end of file
diff --git a/AssimpToMesh/src/assimputils/assimpgeometry.cpp b/AssimpToMesh/src/assimputils/assimpgeometry.cpp
new file mode 100644
index 0000000..1d8efbf
--- /dev/null
+++ b/AssimpToMesh/src/assimputils/assimpgeometry.cpp
@@ -0,0 +1,69 @@
+#include "utils.h"
+
+// determine if a vertex is already contained in the bucket, if so matchingIndex will contain the index of the matching vertex
+bool FindVertex(const aiVector3D &vertex, const AssimpVertices &bucket, unsigned int &matchingIndex)
+{
+ for (unsigned int i = 0; i < bucket.size(); ++i)
+ {
+ if (vertex == bucket[i])
+ {
+ matchingIndex = i;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void CollectVerticesInMesh(
+ const aiMesh *mesh,
+ AssimpVertices &verticesBucket,
+ AssimpVertices &normalsBucket,
+ AssimpVertices &texCoordsBucket,
+ AssimpVertexIndices &indexMapping)
+{
+ indexMapping.resize(mesh->mNumVertices);
+
+ for (unsigned int i = 0; i < mesh->mNumVertices; ++i)
+ {
+ unsigned int matchingIndex = 0;
+ aiVector3D vertex = mesh->mVertices[i];
+
+ if (!FindVertex(vertex, verticesBucket, matchingIndex))
+ {
+ // vertex isn't in the bucket already, add it, and then record mapping between the mesh vertex index and the bucket vertex index
+ verticesBucket.push_back(vertex);
+ matchingIndex = verticesBucket.size() - 1;
+
+ // also copy the normal and tex coord into the appropriate buckets
+ // TODO: check if mesh has normals and/or tex coords first!
+ aiVector3D normal = mesh->mNormals[i];
+ normalsBucket.push_back(normal);
+ aiVector3D texCoord = mesh->mTextureCoords[0][i];
+ texCoordsBucket.push_back(texCoord);
+ }
+
+ // stating the obvious so when i come back here and read this, i know instantly
+ // what the fuck is going on (sad, I know):
+ // i = index into mesh's separate vertices list
+ // matchingIndex = index into bucket's vertices list
+ indexMapping[i] = matchingIndex;
+ }
+}
+
+void CollectAllMeshVertices(
+ const aiScene *scene,
+ AssimpVertices &verticesBucket,
+ AssimpVertices &normalsBucket,
+ AssimpVertices &texCoordsBucket,
+ AssimpVerticesMap &indexMapping)
+{
+ for (unsigned int i = 0; i < scene->mNumMeshes; ++i)
+ {
+ aiMesh *mesh = scene->mMeshes[i];
+ AssimpVertexIndices indexes;
+ CollectVerticesInMesh(mesh, verticesBucket, normalsBucket, texCoordsBucket, indexes);
+
+ indexMapping[i] = indexes;
+ }
+}
diff --git a/AssimpToMesh/src/assimputils/types.h b/AssimpToMesh/src/assimputils/types.h
new file mode 100644
index 0000000..bc7eb9d
--- /dev/null
+++ b/AssimpToMesh/src/assimputils/types.h
@@ -0,0 +1,13 @@
+#ifndef __ASSIMPUTILS_TYPES_H_INCLUDED__
+#define __ASSIMPUTILS_TYPES_H_INCLUDED__
+
+#include
+#include
+#include