Long time ago in thread “[MD5] EXPORT script for Blender 2.6x (OPEN)”
kat wrote (by answer to Rajveer):
“Just to check this further the below is the first line from the 'bounds' block exporting the same (original) Bob file from each script corresponding version of Blender - before export MESH objects were reset so their size and origin were relative to Blenders grid-centre (used "Apply" to set Origin points at 0,0,0) - the bounding box values are calculated relative to that position (outwards).
…
It looks like either there's an error in the script or Blender itself (in terms of what it's doing relative to the script) after the significant change that happened Blender 2.60 onwards - looking at the numbers from 2.62 the bounds do indeed appear to be a flat box compared to prior that.”
Rajveer talk about problem with incorrect values inside “bounds” section into .md5anim.
This is not obvious problem because Blender and modelviewer (imho) don’t show ‘bounds’.
But if anyone try to test exported model in Doom 3 with ‘testmodel <name>/testanim <name>/r_showskel 1’ console commands then we see as md5 bounding box is offset and distorted along one of axis (Y-components in max [X,Y,Z] as I think).
Not sure but it’s may be bad for game physics (see pictures).
Take a look (this is “io_export_md5.py” for Blender 2.59+ but algorithm is same in 2.4x-2.6x):
>>> corners.append(point_by_matrix (v, matrix)) <<<
(min, max) = getminmax(corners)
md5animation.bounds.append((min[0]*scale, min[1]*scale, min[2]*scale, max[0]*scale, max[1]*scale, max[2]*scale))
We see that ‘bounds’ based on ‘corners’ and ‘corners’ are mul by ‘matrix’ (few lines above):
def generateboundingbox(objects, md5animation, framerange):
…
matrix = [[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
>>> [0.0, 1.0, 1.0, 0.0], <<< there is two (not one) correction values!
[0.0, 0.0, 0.0, 1.0],
]
I belive this row (or column) >>> [0.0, 1.0, 1.0, 0.0] <<< give a distortion by added some value to Y-component (or other) in max[X,Y,Z] because:
def point_by_matrix(p, m):
…
return [p[0] * m[0][0] + p[1] * m[1][0] + p[2] * m[2][0] + m[3][0],
p[0] * m[0][1] + p[1] * m[1][1] + p[2] * m[2][1] + m[3][1],
p[0] * m[0][2] + p[1] * m[1][2] + p[2] * m[2][2] + m[3][2]]
Now try to solved (I hope):
1. Open “io_export_md5.py” in editor (Notepad).
2. Add “cornersb = []” after “corners = []”.
3. Add “matrixb = [[1.0, 0.0, 0.0, 0.0],
[0.0, 1.0, 0.0, 0.0],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0],
]”
after “matrix = […]”.
4. Add “cornersb.append(point_by_matrix (v, matrixb))” after “corners.append(point_by_matrix (v, matrix))”.
5. Change “(min, max) = getminmax(corners)” to “(min, max) = getminmax(cornersb)”.
6. Save modified “io_export_md5.py” in same place (blender/…/scripts/addons).
After this I see correct (well… almost correct) values into ‘bounds’ (see pictures).
Not sure about others but it seems work.
Hope this help.
Bitterman.