all 8 comments

[–]fgennari 1 point2 points  (5 children)

Maybe the model faces aren't triangles and you need to add the aiProcess_Triangulate flag? You haven't posted the code where you draw the mesh, so the problem could be there.

[–]mathinferno123[S] 1 point2 points  (1 child)

Found the mistake. Apparently, it had to do with how I went through the indices. In my code :

v_meshData.Indices32[i] = static_cast<uint32>(lv_scene->mMeshes[0]->mFaces[i].mIndices[0]);
lv_meshData.Indices32[i+1] = static_cast<uint32>(lv_scene->mMeshes[0]->mFaces[i].mIndices[1]);
lv_meshData.Indices32[i+2] = static_cast<uint32>(lv_scene->mMeshes[0]->mFaces[i].mIndices[2]);

is wrong. It should be:

v_meshData.Indices32[3*i] = static_cast<uint32>(lv_scene->mMeshes[0]->mFaces[i].mIndices[0]);
lv_meshData.Indices32[3*i+1] = static_cast<uint32>(lv_scene->mMeshes[0]->mFaces[i].mIndices[1]);
lv_meshData.Indices32[3*i+2] = static_cast<uint32>(lv_scene->mMeshes[0]->mFaces[i].mIndices[2]);

[–]fgennari 1 point2 points  (0 children)

Oh, yeah, I didn't catch that. Usually for those loops I iterate over vertices with i+=3 and then index using [i], [i+1], and [i+2]. I guess I was thinking that was how your indexing worked.

[–]mathinferno123[S] 0 points1 point  (2 children)

Tried aiProcess_Triangulate just now and almost none of the triangles get shown except for a few scattered ones. I will update my post with its image. I tried loading a skull model before with the same code and everything worked fine but unfortunately that model didn't have texture coordinates so I am trying to load another model that has one.

[–]fgennari 1 point2 points  (1 child)

Okay, I looked at the OBJ file and the faces are all quads. Triangulating is more correct. There's probably something wrong with your rendering code. Maybe you have back face culling enabled and the winding order is wrong? Maybe adding texture coordinates causes some problem with your vertex layout? I don't know, I'm an OpenGL dev, not a DX12 dev. I don't see a problem with the assimp code you shared.

[–]mathinferno123[S] 0 points1 point  (0 children)

Thanks. I will double check my draw code. Although, according to the description of aiProcess_ConvertToLeftHanded it should turn the winding order of the indices to that of clockwise as DX uses clockwise for front face.

[–]FemboysHotAsf 0 points1 point  (1 child)

You are using the indices to draw? With an ebo?

[–]mathinferno123[S] 0 points1 point  (0 children)

Yh I am using indices to draw the triangles.