Sign in to follow this  
JulianAssange

MD2 vertex array problem

Recommended Posts

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

[b]Immediate mode[/b]: works fine, all textures and normals works like intended.

[b]Vertex array mode[/b]: 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.

[b]The problem: [/b]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.

[b]The solution: [/b]I need to, when looping through the numTriangles, find which triangle in the model the indices [i]really[/i] 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 this post


Link to post
Share on other sites
willvarfar    102
[quote name='JulianAssange' timestamp='1312887039' post='4846623']
The vertex list I have, is assigned from 0 -> numVertices * numFrames.
[/quote]

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 [code]mix()[/code] function.

Share this post


Link to post
Share on other sites
V-man    813
[quote name='willvarfar' timestamp='1313273166' post='4848760']
[quote name='JulianAssange' timestamp='1312887039' post='4846623']
The vertex list I have, is assigned from 0 -> numVertices * numFrames.
[/quote]

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 [code]mix()[/code] function.
[/quote]

You can put them in the same VBO.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this