Divine Skins
Divine Skins Wiki

Hero swap part 2: build the model in ModelDoc

Open the hero model in CSDK 12's ModelDoc, swap in your meshes, and rebuild bodygroups, materials, the ragdoll, and LODs.

Advanced

Part 2 of 4. You start with the hero's decompiled .vmdl and your DMX files from part 1. You finish with a model that compiles in CSDK 12, with your meshes, materials, bodygroups, ragdoll, and LODs. The whole path is in Hero model swap: overview.

The four parts of a hero model swap, with part 2, build in ModelDoc, highlighted

What you need

CSDK 12

Source 2 Viewer

Notepad++

or VS Code

Your files from part 1

Materials for your mesh

ModelDoc in CSDK 12 builds the model. Source 2 Viewer shows the original hero, so you can compare. From part 1 you need your addon: the decompiled viper.vmdl and your DMX files in its dmx folder. The materials step below shows where to make your materials.

Watch the walkthrough

Pugzilla's video swaps the meshes and materials from 23:17. The CSDK 12 addon setup starts at 14:10.

This video uses an older interface

The video does not show the first step below. Pugzilla added it to the video description after a Source 2 Viewer update.

What changes in the model

A hero .vmdl is a tree of nodes. This part replaces some, rebuilds some, and keeps the rest.

NodeWhat it holdsIn this part
RenderMeshListThe visible meshesReplace with your meshes, under the same names
MaterialGroupListWhich material each mesh usesPoint to your materials
BodyGroupListParts that switch on and offRebuild with the same names
PhysicsShapeListThe ragdollRebuild
LODGroupListSimpler versions for long distancesRebuild
AnimationListOld-style animationsDelete most entries
SkeletonThe bonesKeep. Never move or rename bones
HitboxSetListHit detection shapesKeep exactly as they are
AttachmentList, GameDataListCamera points, health bar, soundsKeep. Part 3 checks them
NmSkeletonList, AnimGraph2ListLinks to the hero's animationsDelete now. Part 4 adds them back

Build the model

Remove the AnimGraph 2 lines

Source 2 Viewer 19.1 and newer write two animation nodes into a decompiled hero. CSDK 12 cannot read them, so it crashes or refuses to open the model.

  1. Make a backup copy of viper.vmdl.
  2. Open viper.vmdl in your text editor.
  3. Search for AnimGraph2List. Delete that whole block, from its opening { to its matching }.
  4. Search for NmSkeletonList. It sat right above the block you deleted. Delete this block too.
  5. Save the file.

Do this even if your build does not crash. It costs nothing, because part 4 adds both back.

Open the model in ModelDoc

  1. Open the CSDK 12 launcher, select your addon, and click Launch Tools.
  2. In the Asset Browser, search for vmdl and find viper.vmdl.
  3. Double-click it to open it in ModelDoc.
  4. Click in the node tree and press Ctrl+A to select every node.
  5. Press Ctrl+C to copy them.
  6. Choose File, then New.
  7. Click in the new node tree and press Ctrl+V.
  8. Save the new file next to the original as viper_work.vmdl.
  9. Close viper.vmdl. From now on, edit only viper_work.vmdl.

The fresh file avoids skeleton and physics crashes. The work name also protects the original. Part 4 gives the finished model its real name back. For many heroes, File, then Save As with the work name works too.

Clear out the old meshes

  1. Open RenderMeshList. Delete the LOD meshes. Their names contain _lod.
  2. Select the original body meshes and click Disable. You delete them in the next section.
  3. Open AnimationList. Delete every entry except the tools preview entry.
  4. Click Compile.

Pocket and Haze need some of these animations for their particles. For them, disable the entries instead of deleting them.

Add your meshes

  1. Right-click RenderMeshList and choose Add Meshes.
  2. Pick your DMX files from the dmx folder.
  3. Compare your mesh with the hero. It should have the same size and facing.
  4. Click an original mesh and copy its name, such as viper or gun.
  5. Delete that original mesh.
  6. Click your matching new mesh. Its name field reads "Anonymous". Paste the original name there.
  7. Repeat the copy, delete, and rename for every mesh, then click Compile.

Names matter. Bodygroups and game events find meshes by name. Delete the original before you rename, or ModelDoc reports a name clash.

If your mesh is tiny or turned, fix it in Blender and export again. Do not fix it with ModelDoc's import scale, and never set a DMX scale below 1.

Rebuild the bodygroups

Bodygroups switch parts of the model on and off. The first choice of the default group is the normal look. Other groups react to abilities and game events, such as Pocket's frog. The decompiled bodygroups do not work, so you rebuild them with the same names.

  1. In Source 2 Viewer, open the original .vmdl_c. Use its Mesh Group checkboxes to see which meshes show in each state.
  2. Write down every group name and choice name. Decompiled choice names carry a prefix: keep only the part after #, so a choice ending in #default becomes default.
  3. Delete the old BodyGroup nodes. If ModelDoc crashes, close it, delete the BodyGroupList block in your text editor instead, and reopen.
  4. Choose Add, then BodyGroup and give it the exact original name.
  5. Add a BodyGroupChoice under it. Rename it from "anonymous" to the original choice name.
  6. Click + next to Meshes and add the meshes that show in that state.
  7. Leave a choice empty if the original shows nothing in that state.
  8. Click Compile.

Vyper needs little here. Heroes like Pocket have several groups.

Set the materials

  1. Choose Add, then DefaultMaterialGroup.
  2. Click Compile. One slot appears for each material name from Blender.
  3. Fill each slot. To reuse a game material, right-click it in Source 2 Viewer and choose Copy name. Paste it and delete the _c at the end.
  4. Fill the rest with your own materials. Make them first with Materials for custom models.
  5. Click Compile. The solid red mesh now shows your materials.

A slot is missing? That material ends in .001 in Blender. Rename it, then export again.

Build the ragdoll

The ragdoll is the body that falls when the hero dies.

  1. Open PhysicsShapeList and delete the old shapes. Your original viper.vmdl still has them if you need one back.
  2. Choose Add, then Biped Ragdoll. ModelDoc finds the bones by itself.
  3. Set Surface Property to flesh.
  4. Click Compile, then Simulate All Physics. Watch the body fall.
  5. Does it fall wrong? Delete the ragdoll, make a new one, and adjust its shapes.

Make LODs

LODs are simpler copies of your mesh. The game shows them when the hero is far away.

  1. Choose Add, then LODGroup and add all your meshes. This is LOD 0.
  2. Duplicate it. Set Switch Threshold to 14, tick Copy and Simplify, and set the target triangle percent to 0.5.
  3. Duplicate it again. Set the threshold to 35 and the target to 0.2.
  4. Click Compile.

You can also model your own LOD meshes. One current mod uses hand-made LODs at thresholds 0, 14, 30, and 50.

Compile and fix errors

  1. Click Compile.
  2. Read every error and fix it.
ProblemFix
The mesh is solid redAdd a DefaultMaterialGroup and fill its slots
ModelDoc refuses to rename a meshDelete the original mesh with that name first
Compile error after a new export from BlenderA collection name changed. Fix the file path on that mesh
ModelDoc crashesSee ModelDoc crashes

Do not test in game yet. Without part 4, the hero stands in an A-pose and does not turn.

Want moving hair or a coat? Add it now with Add cloth to a model.

Next steps

Hero swap part 3: attachments, camera, and game data
Advanced

Copy the original hero's attachments, camera previews, and game data so the camera, health bar, and sounds work.

Credits

This guide is based on the work of these creators. Check out their original guides.