Hello guys,
my engine currently supports only loading single 3D-Models. I am using ASSIMP and now i want to load files with several meshes in it.
I have tried to put the data from the following meshes into one list (and therefore into one VBO / IBO) but that doesnt work out for me (the mesh is deformed):
for (unsigned int m = 0; m < scene->mNumMeshes; m++)
{
aiMesh* aMesh = scene->mMeshes[m];
// Fill vertices
for (unsigned int j = 0; j < aMesh->mNumVertices; j++)
{
aiVector3D* pPos = &(aMesh->mVertices[j]);
aiVector3D* pTexCoord = &(aMesh->mTextureCoords[0][j]);
aiVector3D* pNormal = &(aMesh->mNormals[j]);
aiVector3D* pTangent = &(aMesh->mTangents[j]);
aiVector3D* pBiTangent = &(aMesh->mBitangents[j]) ;
// Create vertex and push it onto the list
Vertex vertex{
Vec3f(pPos->x, pPos->y, pPos->z),
Vec2f(pTexCoord->x, pTexCoord->y),
Vec3f(pNormal->x, pNormal->y, pNormal->z),
Vec3f(pTangent->x, pTangent->y, pTangent->z),
Vec3f(pBiTangent->x, pBiTangent->y, pBiTangent->z)
};
vertices.push_back(vertex);
}
// Fill indices
for (unsigned int k = 0; k < aMesh->mNumFaces; k++)
{
const aiFace& Face = aMesh->mFaces[k];
if (Face.mNumIndices != 3)
continue;
indices.push_back(Face.mIndices[0]);
indices.push_back(Face.mIndices[1]);
indices.push_back(Face.mIndices[2]);
}
}
// Then upload them via staging buffers
// and draw the mesh via vkCmdDrawIndexed();
I feel like im missing only a little peace of information to get this working. What i doing wrong?
Thanks in Advance