Skip to content

Instantly share code, notes, and snippets.

@GreenSwede
Last active October 19, 2022 08:52
Show Gist options
  • Save GreenSwede/f81527e378eed4debbc9ef6e49e77765 to your computer and use it in GitHub Desktop.
Save GreenSwede/f81527e378eed4debbc9ef6e49e77765 to your computer and use it in GitHub Desktop.
How to turn custom cosmetics into bodygroups for custom TF2 player models

These are my own documented steps on how to turn cosmetics from Steam Workshop into bodygroups for custom TF2 player models

written by GreenSwede#0001
last edited 2022-10-19

  1. Download Crowbar: https://steamcommunity.com/groups/CrowbarTool

  2. In this guide I will use the following Gmod addon: https://steamcommunity.com/sharedfiles/filedetails/?id=332220769

  3. Extract the .gma file (tf2_hex_-_mountain_lab_accident_332220769.gma) using /Steam/steamapps/common/GarrysMod/bin/gmad.exe

  4. Place everything in a tf/custom folder, e.g. mountain_lab_accident. This makes it easier to test the model later on in HLMV. Here is how my folder structure looks like: tf\custom\mountain_lab_accident\models\workshop\player\items\medic\scientist_head tf\custom\mountain_lab_accident\models\workshop\player\items\medic\scientist_pants tf\custom\mountain_lab_accident\models\workshop\player\items\medic\scientist_shirt tf\custom\mountain_lab_accident\materials\models\workshop\player\items\medic\scientist_head tf\custom\mountain_lab_accident\materials\models\workshop\player\items\medic\scientist_pants tf\custom\mountain_lab_accident\materials\models\workshop\player\items\medic\scientist_shirt

  5. Open Crowbar and click on the "Decompile" tab

  6. Browse and select one of the .mdl files. I will start with "models\workshop\player\items\medic\scientist_head\scientist_head.mdl".

  7. Change Output directory if you wish. I prefer using "Subfolder (of MDL input)"

  8. Click Decompile. You can leave all decompile settings to default. Now you'll have a "decompiled 0.72" folder in the scientist_head folder.

  9. Next you will want to decompile the Medic player model. To extract the Medic model, use GCFScape. Extract all "models/player/medic" files (.dx80.vtx, .dx90.vtx, .mdl, .phy, .sw.vtx, .vvd, _animations.mdl, _user_animations.mdl) to a folder by opening "tf/f2_misc_dir.vpk". As mentioned earlier I like using the tf/custom folder to place new files, so I will place them in tf/custom/mountain_lab_accident/medic_model

  10. With the Medic model extracted, use Crowbar and point to "medic.mdl", and then click on Decompile.

  11. Now, copy all the scientist_head decompiled files over to the Medic decompiled folder. (scientist_head/decompiled 0.72/ -> medic_model/decompiled 0.72/)

  12. Since scientist_head has its own facial flexes, this will be tricky. I don't know how to add bodygroups that use their own facial flexes. I will instead add it as its own model inside medic.qc. Is this the right approach? I have no idea.

  13. Open "scientist_head.qc" with a text editor

  14. Copy $model "default" "berliners_bucket_helm_reference.smd" { starting at line 5 down all the way down to line 143.

  15. Now paste this into medic.qc underneath the end bracket of $model "medic" "medic_morphs_low.smd" { Here is how it should look: https://pastebin.com/UtB5ATb7

  16. Now we'll want to include the lod model. Since there is only one, I have added replacemodel "berliners_bucket_helm_reference.smd" "berliners_bucket_helm_reference_lod1.smd" to $lod 44 and later.

  17. Add $cdmaterials "models\workshop\player\items\medic\scientist_head\" underneath $cdmaterials "models\player\items\all_class\"

  18. Now compile by clicking on the Compile tab on Crowbar. Select Team Fortress 2 as the game, and select medic.qc as QC input file. Now click Compile. If this doesn't work then set up the Steam library path in the "Set Up Games" tab.

  19. Now you should have new medic model files in the output folder you chose. You can inspect medic.mdl using HLMV and see how it looks. You can compare your medic.qc file with mine here: https://pastebin.com/XcSCTTg8 certified medic moment There is an issue here where the scientist head is clipping through Medic's facial mesh. I don't know what's causing this. It might be because this was not set up as a bodygroup, however I had success using the same approach with another Engineer facial cosmetic (Big Texas chin).

  20. Todo: write skinfamilies instructions & ubercharge texture support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment