loading md2 files usind directx 11

Started by
1 comment, last by 21st Century Moose 7 years, 11 months ago

Has anybody tried to load md2 files using DirectX 11, I would like to know how to do it, I'm following the http://www.xbdev.net/3dformats/md2/md2.php tutorial and I want to convert it to directx11. is there any suggestions on how to load it ? probably sample code using directx11 ?

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.

-potential energy is easily made kinetic-

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.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement