MD5是一种简单的文件格式,通常用于存储3D模型、纹理等数据。该格式由3D模型软件Blender引入,随后已被广泛应用于其他3D软件。
MD5文件通常包括以下几个部分:
下面是一个MD5文件的简单示例:
MD5Version 10
numJoints 3
numMeshes 1
joints {
"baseJoint" -1 ( 0 0 0 ) ( 0 0 0 )
"upperArm" 0 ( 0 1 0 ) ( 0 0 90 )
"lowerArm" 1 ( 0 0 1 ) ( 0 0 90 )
}
mesh {
shader "myShader"
numverts 4
numtris 2
numweights 4
vert 0 ( 0.0 0.0 ) 0 1
vert 1 ( 1.0 0.0 ) 0 1
vert 2 ( 0.0 1.0 ) 0 1
vert 3 ( 1.0 1.0 ) 0 1
tri 0 0 1 2
tri 1 2 1 3
weight 0 1 0 ( 0.5 0.5 0.0 )
weight 1 2 0 ( 0.0 0.5 0.5 )
weight 2 2 1 ( 0.0 0.0 0.5 )
weight 3 1 2 ( 0.5 0.0 0.5 )
}
MD5文件格式没有官方规范链接,但是Blender官方文档中提供了相关的MD5导入和导出文档,可以供开发者参考。
开发者也可以查看其他软件的MD5解析翻译或开源代码进行理解和实战应用。
以下是一个较复杂的MD5文件的示例,其表示了一个复杂的机器人。
MD5Version 10
commandline "md5mesh.exe robot.md5mesh"
numJoints 62
numMeshes 20
joints { // 62 joints
// name parentID (x y z) (qx qy qz)
"hips" -1 (-4.9655428 0.02808994 13.84018) (0.01897068 0.9939297 0.1091197 )
"waist" 0 (-6.779017 0.02547158 25.386494) (-0.07935838 0.9962006 0.03205607)
"abdomen" 1 (-8.406221 0.031063 27.912445) (-0.11199218 0.99364144 -0.00087981)
"chest" 2 (-10.063856 0.03253553 30.704969) (-0.15616079 0.9887322 -0.00865129)
"neck_00" 3 (-10.063876 6.4918756 31.122066) (-0.20090184 0.9789781 -0.03123706)
"head_00" 4 (-10.997849 12.60478 32.446144) (-0.24276394 0.9641192 -0.10527447)
"rShldrBend" 5 (-10.453587 4.524621 14.929021) (-0.148561 0.98883665 0.00820261)
"rShldrTwist" 6 (-12.837705 3.60581 15.622108) (-0.2992979 0.94130737 0.15853716)
"rForearmBend" 7 (-13.989703 1.427221 13.312084) (-0.44461146 0.8708637 0.20715071)
"rForearmTwist" 8 (-14.647619 1.209406 12.039258) (-0.4058242 0.83390236 0.3740467 )
"rHand" 9 (-14.48101 2.236055 12.851007) (-0.35407546 0.913509 0.2024423 )
"rThumb_01" 10 (-13.467082 1.9891975 11.222879) (-0.39766398 0.90352666 0.16579761)
"rMid_01" 11 (-14.572786 1.1467754 12.433014) (-0.5106748 0.8359324 0.20128711)
"rPinky_01" 12 (-14.647619 1.209406 12.039258) (-0.3699685 0.92516124 0.08936682)
"rRing_01" 13 (-14.572906 1.2981157 12.228542) (-0.43670276 0.8910422 -0.1167307 )
"rIndex_01" 14 (-14.54188 1.4153422 12.659163) (-0.37390375 0.88683546 0.26894557)
"rThighBend" 3 (-6.5280733 -0.677515 14.443627) (0.07457987 0.9879689 0.13450347)
"rThighTwist" 16 (-7.943809 -1.076896 16.194788) (0.05838751 0.9923245 0.10834418)
"rShin" 17 (-5.805927 -8.02212 19.048868) (-0.1225454 0.9819634 -0.14483547)
"rFoot" 18 (-5.740446 -16.017086 17.160465) (0.02167679 0.9841371 -0.17606947)
"rToe" 19 (-6.6467896 -20.13229 17.276033) (0.04438952 0.9782263 -0.20265499)
"lShldrBend" 5 (-10.885515 4.4553194 15.160985) (-0.13705912 0.97376424 -0.18083538)
"lShldrTwist" 21 (-9.166135 2.339655 15.66445) (0.09199138 0.9541795 -0.28547072)
"lForearmBend" 22 (-6.7589506 3.82714 15.059504) (0.21453992 0.93639207 -0.27095893)
"lForearmTwist" 23 (-5.516815 1.784932 14.240596) (0.3574391 0.90687853 -0.22573872)
"lHand" 24 (-4.7107716 2.7775729 15.383309) (0.27611297 0.9457451 -0.17013296)
"lThumb_01" 25 (-5.669352 3.1640713 15.005597) (0.0797821 0.9823194 -0.16773167)
"lMid_01" 26 (-4.614719 2.2154698 14.723626) (0.37354946 0.89967346 -0.22879474)
"lPinky_01" 27 (-4.7107716 2.7775729 15.383309) (0.41759074 0.8825416 -0.21949361)
"lRing_01" 28 (-4.7981987 2.186981 14.873124) (0.22648935 0.96853626 -0.10370734)
"lIndex_01" 29 (-4.085808 3.3636165 15.142445) (0.3349644 0.9215884 -0.19473285)
"lThighBend" 3 (-6.2107954 -0.632468 13.926042) (0.16598102 0.9861201 0.01972069)
"lThighTwist" 31 (-4.9285975 -1.55896 16.233515) (0.10235845 0.99449426 -0.00293512)
"lShin" 32 (-6.241603 -7.344418 18.974508) (-0.01916719 0.98259157 -0.18469532)
"lFoot" 33 (-6.9829006 -15.315728 15.631683) (0.01125336 0.98212355 -0.18704505)
"lToe" 34 (-6.0363574 -20.163311 14.486126) (0.02643548 0.9914619 -0.12748973)
"backPack" 1 (-11.274247 -3.7014663 20.146816) (0.04630587 0.3466018 -0.93689454)
"lPectoral" 2 (-10.212025 5.8369055 34.292725) (0.37282085 -0.3207129 -0.7496861 )
"rPectoral" 2 (-10.212018 5.836921 34.29277) (-0.37281877 -0.32071298 -0.7496857 )
"genitalia" 1 (-9.92669 3.2938418 28.441086) (0.13223523 0.4446097 0.8854492 )
"tail_00" 0 (1.1674597 6.2925677 -3.2518253) (-0.28328043 -0.9710015 -0.2765305 )
"tail_01" 35 (1.466002 1.0126238 -2.565509 ) (-0.35149917 -0.9170114 -0.18798378)
"tail_02" 36 (2.6145294 -0.1589578 -4.8508005) (-0.46311614 -0.85654396 -0.2302305)
"tail_03" 37 (3.6920552 -2.7041101 -6.8727117) (-0.57158476 -0.7823233 -0.24607928)
"tail_04" 38 (4.6239934 -5.766245 -6.147305 ) (-0.5961301 -0.7441272 -0.3017459)
"tail_05" 39 (4.7679534 -8.189899 -5.7919245) (-0.6506452 -0.6805085 -0.34023824)
"tail_06" 40 (3.4121823 -9.597658 -3.3431027) (-0.55064183 -0.75846314 -0.3497617)
"tail_07" 41 (2.688587 -10.937171 -0.6651611) (-0.53527564 -0.8307692 -0.15357768)
"tail_08" 42 (1.6922798 -13.977639 0.4922191) (-0.52743846 -0.8302043 0.1795685)
"tail_09" 43 (1.0023774 -16.059397 2.0247347) (-0.5462941 -0.8036074 0.23313931)
"tail_10" 44 (0.1622552 -18.382944 1.0986774) (-0.48051247 -0.7991268 -0.36083364)
"tail_11" 45 (-0.6027947 -21.084766 -0.4705489) (-0.51061064 -0.6552956 -0.5567362)
"tail_12" 46 (-1.3216606 -23.314102 -3.1108732) (-0.70582837 -0.4504119 -0.54766774)
"tail_13" 47 (-1.6486211 -25.258417 -6.8015075) (-0.87371624 -0.25143087 -0.4150731)
"tail_14" 48 (-1.0545794 -27.276806 -9.1658 ) (-0.8804383 -0.2834519 -0.3779845)
"tail_15" 49 (-0.8614338 -28.30806 -11.767143) (-0.8349515 -0.3539312 -0.4217748)
"tail_16" 50 (-1.0590314 -27.207733 -14.957254) (-0.9035698 -0.21883126 -0.36753756)
"tail_17" 51 (-1.9279492 -26.589296 -16.874102) (-0.97184867 -0.11849744 -0.2011876)
"tail_18" 52 (-3.6975572 -26.274464 -17.921825) (-0.99879295 -0.03894377 -0.03040499)
"tail_19" 53 (-4.2953453 -25.130505 -18.000155) (-0.9971791 -0.07485798 0.01530361)
}
mesh {
shader "robotShader1"
numverts 1734
numtris 3250
numweights 5422
vert 0 (-1.988861 4.1612477 0.15324305) 4 21
vert 1 (-3.2172353 8.280891 0.84702516) 5 24
vert 2 (-1.323117 5.1767855 2.3264716) 21 199
// ... 省略 1731 行 ...
vert 1733 (-0.70785046 -33.843124 23.397987) 11 210
tri 0 0 1 2
tri 1 3 2 1
// ... 省略 3248 行 ...
tri 3248 1732 1202 1733
weight 0 3 0 (0.637844 0.12567374 0.0006600438)
weight 1 5 0 (0.6335865 0.09220468 0.0015981842)
weight 2 22 0 (0.5828574 0.28402394 0.00528195)
// ... 省略 5417 行 ...
weight 5420 44 2 (0.00095252065 0.007450501 0.992351 )
weight 5421 52 2 (0.0006140379