0
\$\begingroup\$

I'm pretty new to direct x and c++, I have a problem with loading .obj files.

This is a cube

I think the problem is with creating vertices and indecies.

list<vertex> FinalVertices;

list<unsigned long> Indecies;
for (int i = 0; i < Faces.size(); i++)
{
    for (int j = 0; j < Faces.size(); j++)
    {
        if (Faces[i] == Faces[j])
        {
            cout << 'b' << endl;
            if (i == j) 
            {
                FinalVertices.push_back(Faces[i]);
                Indecies.push_back(j);
            }
            goto a;
        }
    }
a:
    cout << ' ';
}
\$\endgroup\$
0
\$\begingroup\$

It looks like you're adding an index only when you encounter a new unique vertex. You want to add the index for repeated vertices too, so move that line outside the if (i==j) block.

if (Faces[i] == Faces[j]) { 
    cout << 'b' << endl;
    if (i == j) { 
        FinalVertices.push_back(Faces[i]);
     } 
     Indecies.push_back(j);
     goto a; 
}
| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.