MD2 Plugin writes invalid files
Closed, ArchivedPublic


The MD2 Export plugin writes invalid files. The light normal index n should fulfill 0 <= n < 162, but it happens to write a light normal index of 162.

This should be the relating code:

#swap y and x for difference in axis orientation
for j in xrange(0,162):
#dot = (x[0]*y[0]+x[1]*y[1]+x[2]*y[2])
dot = (x1*MD2_NORMALS[j][0]+
if (dot > maxdot):
maxdot = dot;
maxdotindex = j;


del maxdot, maxdotindex

xrange(0, 162) iterates from 0, 1, ..., 161. What is weired is the value of 2 which is added to the normal index.



I'm not familiar with this format but there was a patch to remove the +2

Could you read this and see if theres a good reason to add it back? how are you viewing the md2?

I don't see any reason to add the "+2" back again. From my understanding of the code the "+2" is wrong.

I was also following this spec

to create an application which loads MD2 models.

I just looked at to Quake 2 source code. Therefore I'm pretty sure that the value of the normal index must not be larger than or equal to 162.

in the code you show there is the +2 added back, could you provide a patch?

Here is the patch, to remove the +2. To apply it, go to the directory where the file "" is in and run

$ patch < blender_md2_normal.diff

. I was not able to locate the file in the repository. Is it maintained somewhere else?

Bastien Montagne (mont29) closed this task as "Archived".Aug 7 2014, 3:13 PM

Time to archive I guess…

Add Comment