0

currently I am learning Vulkan api and everything was great until I got the problem with properly layout the data which I have after parsing .obj file. The problem is that I don't have the same amount of vertices and normal vectors. For example, I have 11472 vertices and 14851 Normal Vectors

I want to layout this data in order like this: (VN VN VN ...).

Everything is fine until I run out of vertices, and then my buffer becomes like this: (0N, 0N, 0N ...) until the end.

For right now I have this chunk of code:

    LoadMeshData(&NewMesh, ObjectPath);

    for(uint32_t Index = 0;
        Index < ((NewMesh.Vertices.size()));
        Index += 6)
    {
        if(NewMesh.Vertices.size() != 0) {
            NewMesh.Mesh[Index+0] = NewMesh.Vertices[Index+0]; 
            NewMesh.Mesh[Index+1] = NewMesh.Vertices[Index+1]; 
            NewMesh.Mesh[Index+2] = NewMesh.Vertices[Index+2];
        }
        if(NewMesh.Normals.size() != 0) 
        {
            NewMesh.Mesh[Index+3] = NewMesh.Normals[Index+0]; 
            NewMesh.Mesh[Index+4] = NewMesh.Normals[Index+1]; 
            NewMesh.Mesh[Index+5] = NewMesh.Normals[Index+2];
        }
    }

memcpy(VertexBuffer.Data, Meshes[0].Mesh.data(), Meshes[0].Mesh.size() * sizeof(float)*3);

What is the best way to process this data in correct way?

Zhukov Artem
  • 195
  • 1
  • 1
  • 10
  • If your position and normal lists have different sizes, that means that you have two different sets of indices, one for the position list and one for the normal list. – Nicol Bolas Nov 20 '21 at 21:57

0 Answers0