Add all glTF data to single buffer
authorjohnmaf <johns@matterandform.net>
Wed, 14 Sep 2016 22:14:23 +0000 (18:14 -0400)
committerjohnmaf <johns@matterandform.net>
Thu, 15 Sep 2016 14:38:02 +0000 (10:38 -0400)
code/glTFExporter.cpp

index e333272..960dd3b 100644 (file)
@@ -267,6 +267,13 @@ void glTFExporter::ExportMaterials()
 
 void glTFExporter::ExportMeshes()
 {
+    std::string bufferId = mAsset->FindUniqueID("", "buffer");
+
+    Ref<Buffer> b = mAsset->GetBodyBuffer();
+    if (!b) {
+        b = mAsset->buffers.Create(bufferId);
+    }
+
     for (unsigned int i = 0; i < mScene->mNumMeshes; ++i) {
         const aiMesh* aim = mScene->mMeshes[i];
 
@@ -277,13 +284,6 @@ void glTFExporter::ExportMeshes()
 
         p.material = mAsset->materials.Get(aim->mMaterialIndex);
 
-        std::string bufferId = mAsset->FindUniqueID(meshId, "buffer");
-
-        Ref<Buffer> b = mAsset->GetBodyBuffer();
-        if (!b) {
-            b = mAsset->buffers.Create(bufferId);
-        }
-
         Ref<Accessor> v = ExportData(*mAsset, meshId, b, aim->mNumVertices, aim->mVertices, AttribType::VEC3, AttribType::VEC3, ComponentType_FLOAT);
         if (v) p.attributes.position.push_back(v);