• 13
• 18
• 19
• 27
• 9

MD2 vertex array problem

This topic is 2409 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hello! I'm trying to convert md2 rendering from immediate mode into regular vertex arrays.

Immediate mode: works fine, all textures and normals works like intended.

Vertex array mode: the triangles draws correctly, but both the texture and normals are supplied wrong into the triangles.

I have (really) debugged this for about three days now, my brain is starting to get a little slow, BUT I know the problem.

The problem: The vertex list I have, is assigned from 0 -> numVertices * numFrames. When putting the vertices into the vertex array I do this by just looping through the numVertices (+ the frame number). The problem is that the normals and texture coords are assigned by their vertexIndices and textureIndices. So when I'm setting the normal array I just loop through the numTriangles, get the triangle's vertices and calculate the normal. The wrong here is that the indices for the vertices is not in the same order in which I use when I put vertices into the vertex array. Therefore, I'm getting correct drawing, but wrong supplying effects of normals and texture coords.

The solution: I need to, when looping through the numTriangles, find which triangle in the model the indices really is describing and after that put the correct offset into the normal and texture coord array. The problem is, how?

Thanks in advance! I'll gladly explain it more if you don't fully understand it.

Share on other sites

The vertex list I have, is assigned from 0 -> numVertices * numFrames.

Put the vertex values for each frame of animation into a separate VBO.

Once its working, you can play with interpolating between the two adjancet sets of vertices for each tween frame of animation, using the mix() function.

Share on other sites

[quote name='JulianAssange' timestamp='1312887039' post='4846623']
The vertex list I have, is assigned from 0 -> numVertices * numFrames.

Put the vertex values for each frame of animation into a separate VBO.

Once its working, you can play with interpolating between the two adjancet sets of vertices for each tween frame of animation, using the mix() function.
[/quote]

You can put them in the same VBO.