Generating a mesh

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
barakatx2
Posts: 14
Joined: Tue Aug 24, 2010 7:00 am

Generating a mesh

Post by barakatx2 »

I am trying to generate a mesh. I have the vertices generating properly but after I add all the indices it only shows one triangle from the quad instead of filling it with two triangles. IE:

0 1 2 3 4 5
6 7 8 9 ..... these are the vertex numbers

Then I have these indices (just a couple of examples):
0, 6, 1
1, 7, 6
1, 7, 2
2, 8, 7

It shows the rectangle of faces properly, but only half of each face is filled and the other half is an empty triangle. Am I doing the indices wrong? Can a vertex only be in one set of indices?
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Some of your tris might be "backwards" and therefore not being drawn due to backface culling. If your indices for that triangle are not in a certain order (I believe it's clockwise), the renderer assumes that it's looking at the back of the surface, and doesn't draw it to save rendering time. Try disabling backface culling in the mesh's material. If the triangles show up all of a sudden, just flip the order of the indices for that triangle.
barakatx2
Posts: 14
Joined: Tue Aug 24, 2010 7:00 am

Post by barakatx2 »

That was exactly it! thank you very much, I would have never thought of that. Just had to switch 2 lines of code to fix it :)
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

Awesome! When working properly, it's actually an optimization, since you usually don't see the back side of a mesh, and therefore it doesn't draw things you don't see. The only reason I thought that might be the problem is because it gave me loads of trouble when I started with Irrlicht. Best of luck! :D
Post Reply