Add all glTF data to single buffer

pull/999/head
johnmaf 2016-09-14 18:14:23 -04:00
parent c98915e382
commit cd038209dd
1 changed files with 7 additions and 7 deletions

View File

@ -267,6 +267,13 @@ void glTFExporter::ExportMaterials()
void glTFExporter::ExportMeshes() 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) { for (unsigned int i = 0; i < mScene->mNumMeshes; ++i) {
const aiMesh* aim = mScene->mMeshes[i]; const aiMesh* aim = mScene->mMeshes[i];
@ -277,13 +284,6 @@ void glTFExporter::ExportMeshes()
p.material = mAsset->materials.Get(aim->mMaterialIndex); 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); 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); if (v) p.attributes.position.push_back(v);