Really stupid question on TriMeshes!

Howdy partners,

Can trimeshes only hold 3 vertex’s and 3 colorRGBA’s? hence the name? or am I completely wrong?

No, it can hold any number of vertices, normals, colors, texture coords (although they should all be the same). It’s a tri mesh, because it uses indices to point to three indices in the vertex array to define triangles.



God, that explaination may have been the worst yet.

i get what ya mean!! :smiley:

i just tried to make a quad from a trimesh, i.e. with 4 vertexs. But as soon as i ran it, the program hangs. I took it down to 3, and it was fine!!



strange!

TriMesh requires you set the indices. This is using OpenGL vertex pointers. This means the following:



Set your vertices… (array of four points).

set your color, normal and texture coords (if needed). Note they all correspond, that is, vertex[0] == color[0] == normal[0] == texture[0]. Only vertex is required, rest are optional.



Last set your indices. You are defining TWO triangles so you are going to have 6 indices. And the triangle should be wound counter clock-wise for the right handed coordinate system.



so IF you had the following vertices (referring to them by the index)



0–1

| / |

2–3



your indices would be {0,2,1,2,3,1}





EDIT: Fixed quad ASCII art.

thats awsome, thx mojomonkey

There are 4 vertices in the quad, 2 of them are shared between the two triangles… thus instead of needing 6 vertices or 6 texture coords, you only need the 4. If you went with 6, you’d end up with 2 sets that were identical anyhow.

Then yeah, you’d need to create two vertices at each point along the edges where that occurs and set the texture coords on those as needed.

Which a modeling tool will handle for you.