Jump to content
  • Advertisement
Sign in to follow this  
JulianAssange

MD2 vertex array problem

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!