Skip to main content
GameDev.net gamedev.net
🔒 Locked

MD2 vertex array problem

Started by JulianAssange Aug 9, 2011 at 10:50 AM 1 replies 1.5k views
Original Post
JulianAssange
JulianAssange
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.
willvarfar
willvarfar

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.
V-man
V-man

[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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.