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\$
2

1 Answer 1

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; 
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .