]> git.xonotic.org Git - xonotic/xonotic.wiki.git/blob - modeldecompile-tool.md
Make author name bold
[xonotic/xonotic.wiki.git] / modeldecompile-tool.md
1 `modeldecompile` is a powerful command, decompiles any model format (DPM, IQM, MD3, ...).
2
3 [**LegendGuard**](https://gitlab.com/LegendaryGuard) discovered something magical, if you put the .dpm file and .dpm.framegroups file (also, .iqm, .iqm.framegroups, md3...) in 
4 <br/> (`darkplaces_game` can be `xonotic`, `quake`, `wrath` or any DarkPlaces game)
5 - Windows: `%USERPROFILE%\Saved Games\darkplaces_game\data\` <br/> 
6 - Linux: `~/.darkplaces_game` <br/>
7 - Mac: `~/Library/Application Support/darkplaces_game`
8 - Or in `darkplaces_game-data.pk3dir` directory.
9
10 the tool decompiles the mesh and the animations of a model in one action (the animations aren't distributed per actions).
11
12 No matter if the model is a weapon, a player or any object/entity.
13
14 An example of a .framegroups file from a player model (`okrobot1.dpm.framegroups`):
15
16 ```
17 1 41 30 0 // okrobot1 die1
18 67 56 30 0 // okrobot1 die2
19 133 11 15 1 // okrobot1 draw
20 144 6 10 1 // okrobot1 duck
21 150 17 15 1 // okrobot1 duckwalk
22 167 31 40 0 // okrobot1 duckjump
23 198 1 10 1 // okrobot1 duckidle
24 199 101 15 1 // okrobot1 idle
25 300 17 20 1 // okrobot1 jump
26 317 6 10 0 // okrobot1 pain1
27 323 6 10 0 // okrobot1 pain2
28 329 6 30 0 // okrobot1 shoot
29 335 17 15 1 // okrobot1 taunt
30 352 17 30 1 // okrobot1 run
31 369 17 30 1 // okrobot1 runbackwards
32 386 17 30 1 // okrobot1 strafeleft
33 403 17 30 1 // okrobot1 straferight
34 41 1 10 0 // okrobot4 dead1
35 122 1 10 0 // okrobot4 dead2
36 424 17 30 1 // okrobot1 forwardright
37 441 17 30 1 // okrobot1 forwardleft
38 458 17 30 1 // okrobot1 backright
39 475 17 30 1 // okrobot1 backleft
40 492 21 15 1 // okrobot1 melee
41 ```
42
43 The hacky way to obtain all animations of a model is setting the last keyframe in an exaggerated value (don't care if the fps have that value or aren't loopable) of the .framegroups file, the file must contain ONLY **one line**:
44
45 ```
46 1 9999 30 0 // LegendGuard's legendary method
47 ```
48
49 What that legendary method does is setting the initial keyframe to `1` and `9999` the last keyframe, we can know `9999` doesn't exist but reaches into a limit. (ignore `30` (means fps) and `0` (means nonloop, if `1` means loopable)).
50 In the game, execute `modeldecompile any_model.dpm` (any_model.iqm, any_model.md3, ...).
51
52 <img src="uploads/6140abcafb7b60cb154b43ce5e835105/image.png" alt="model_decompile_okrobot1_xon" width=760 />
53 <br/>
54
55 After that, go to the data directory where the files were decompiled.
56 Use the SMD files to import into [Blender](https://www.blender.org/) using [Blender Source Tools](http://steamreview.org/BlenderSourceTools/) addon. 
57 First, import the mesh (`ref1.smd`) with the Bone Append Mode set to "Make New Armature" and "Import Animations" option disabled. 
58 After, select the armature of the imported model (orange highlighted) and import other SMD file (`groupified_0_anim.smd`), before that, set the Bone Append Mode to "Validate Against Target" and enable "Import Animations" option. The animations in one action are applied to the armature.
59
60 Result (video): https://streamable.com/1egthv 
61
62 The actions can be created with the imported one to separate the keyframes of every animation.
63 <br/>