missed faces #5997
-
|
Hey, guys. I started using assimp in my project and got the problem. I am loading a FBX model from the https://sketchfab.com/3d-models/survival-guitar-backpack-799f8c4511f84fab8c3f12887f7e6b36 and getting this result: To load I am using this call: Assimp::Importer importer;
const aiScene* ai_scene = importer.ReadFile(_file_name,
aiProcess_Triangulate |
aiProcess_GenBoundingBoxes |
aiProcess_FlipUVs |
aiProcess_GenNormals |
aiProcess_CalcTangentSpace |
aiProcess_FixInfacingNormals |
aiProcess_GenUVCoords
);
Then I read the vertices and take into account the transformation. for (unsigned int i = 0; i < _ai_mesh->mNumVertices; i++)
{
Stride stride;
stride.position = _t* glm::vec4(a2g(_ai_mesh->mVertices[i]), 1);
stride.normal = glm::normalize(_t * glm::vec4(a2g(_ai_mesh->mNormals[i]), 1));
stride.tangent = glm::normalize(_t * glm::vec4(a2g(_ai_mesh->mTangents[i]), 1));
stride.bitangent = glm::normalize(_t * glm::vec4(a2g(_ai_mesh->mBitangents[i]), 1));
if (_ai_mesh->mTextureCoords[0])
{
stride.uv0 = a2g2d(_ai_mesh->mTextureCoords[0][i]);
}
mesh->addStride(stride);
}All this works fine. for (unsigned int i = 0; i < _ai_mesh->mNumFaces; i++)
{
const aiFace& face = _ai_mesh->mFaces[i];
const TriangleFace tf{ face.mIndices[0], face.mIndices[1], face.mIndices[2] };
mesh->addFace(tf);
}where TriangleFace is defined as: #pragma pack(push,1)
struct TriangleFace
{
uint16_t indices[3];
};
#pragma pack(pop)I use very trivial fragment shader: and use static buffer: bool MeshPainter::loadStatic()
{
h[0] = h[1] = -1;
glGenBuffers(2, h);
if (h[0] != -1 && h[1] != -1)
{
glBindBuffer(GL_ARRAY_BUFFER, h[0]);
glBufferData(GL_ARRAY_BUFFER, data->getStridesBufferSize(), data->getStridesBuffer(), GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, h[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, data->getIndecesBufferSize(), data->getIndiciesBuffer(), GL_STATIC_DRAW);
}
return h[0] != -1 && h[1] != -1;
}
void MeshPainter::draw()
{
glBindBuffer(GL_ARRAY_BUFFER, h[0]);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, h[1]);
size_t stride_size = sizeof(Stride);
for (uint16_t index = 0; index < Stride::ATTRIBUTES_QTY; index++)
{
glVertexAttribPointer
(
index,
Stride::getAttributeSize(index),
GL_FLOAT,
false,
stride_size,
Stride::getAttributeOffset(index)
);
}
glDrawElements(GL_TRIANGLES, 3 * data->getFacesQty(), GL_UNSIGNED_SHORT, 0);
}
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.


I switched to FBX SDK and found one issue in my code