Jump to content
  • Advertisement
Sign in to follow this  
andreahmed

loading md2 files usind directx 11

This topic is 847 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

Advertisement

Assimp (open asset import library) supports md2 if I'm not mistaken.  Not sure how it handles texture coordinates though since quake 2 was OpenGL.

Share this post


Link to post
Share on other sites

You could always look at the canonical source: the actual Quake 2 source code: https://github.com/id-Software/Quake-2/blob/master/ref_gl/gl_mesh.c

 

I suggest that the drawing code would be a good place to start because that's the actual data that will be going into your vertex buffer.  Also look at the loading code here: https://github.com/id-Software/Quake-2/blob/master/ref_gl/gl_model.c#L929 but that's incredibly simple and API-neutral.

 

MD2 files use keyframe animation so what you would do is load the model into two vertex buffers, one containing position/normal for all keyframes and one containing texcoords.  Also load an index buffer.  Then when drawing bind the first buffer to two slots, offsetting for current and previous frames, and do the keyframe interpolation in your vertex shader.

 

The only tricky part is getting the vertex and index counts before creating your buffers, and I'd suggest doing a pass through the model, similar to the drawing loop but accumulating the counts, as perhaps the simplest way.

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!