Source 2/Docs/Porting Legacy Content/Models

has a built-in system for taking old .mdl files from and converting them to Source 2. You can utilize this to convert files you don't have the sources to, but there are some issues.
== Prerequisites ==
This system is very picky as to what kind of .mdl formats are imported. Currently, Source Filmmaker so far has been the most successful place to port models from, which can be beneficial as the already ships with content from a ton of games. However, and , among others, have all been tested and are incompatible, but luckily, Valve has already ported a lot of content from those games.
== Creating the .vmdl File ==
To convert the .mdl file, you must first create a structure for your content to live in. Let's say that we are converting a model from , let's say "models/humans/group01/male_07.mdl" for use in . To do this, you will need to have the tools installed and a content folder for the mod you're attempting to compile for. In this case, we have a mod called hl2 which has a corresponding folder in my content and game folders inside of "steamapps/common/Half-Life Alyx".
Next, you'll want to drop your .mdl and its corresponding files into the same file structure it had in . So for instance, our male_07 model files will now be in "Half-Life Alyx/content/hl2/models/humans/group01/male_07.mdl".
Finally, you'll want to create a new .vmdl file. Open it in your favorite text editor and add the following code to it. Close the file and then open the Source 2 Tools.
<!-- kv3 encoding:text:version{e21c7f3c-8a33-41c5-9977-a76d3a32aa0d} format:generic:version{7412167c-06e9-4698-aff2-e63eb59037e7} -->
{
	m_sMDLFilename = "models/humans/group01/male_07.mdl"
}
Once done, you can now open your .vmdl file and it will automatically compile itself to a .vmdl_c file!
The only thing left to do is to create material files which should have the same names and file structures as the .vmt files. So for instance, We'd want to create a citizen_sheet.vmat file in the following file structure: materials/models/humans/male/group01/citizen_sheet.vmat
== ModelDoc Editor ==
Half-Life: Alyx introduced a new model editor called (later backported to ). ModelDoc grants us a much wider variety of what we can do with our models, and allows access to special tools not available in the old Model Editor.
With ModelDoc, you can import an old .vmdl file by clicking File → Import → Import and Convert old .VMDL. When you do this, the model will actually process out all of it's sources (using the previously compiled .VMDL_C,) and it will spit out some FBX files for you to mess about with. You will then have the option to delete the old .mdl file, as it's unneeded.
This is ideal if you want to make modifications to help facilitate your model's transition to . Currently there's not a known way to batch process all of the .VMDL files in the game, but you can utilize this tool to fix problems with the importer.
== Troubleshooting ==
Models that have flexes will import, but if the flexes have flex rules (such as HWM or FACs character models) then they will not import correctly. There is no known fix for this quite yet, but possibly with the decompiling process that ModelDoc does, we might be able to solve this.
Some models that are more complex will cause random crashes or breaks in the system, and won't import correctly. There is not much that can be done to help these at the moment, but taking a look at the VConsole might help you discover what's wrong.
== The SourceIO Method ==
You can also convert .mdl files to FBX to import into ModelDoc using SourceIO for Blender which can be found here. https://github.com/REDxEYE/SourceIO
Import your .Mdl file into an empty scene and export it as a .Fbx file. Then in ModelDoc click add new mesh, and then select your .Fbx file.
== cs_mdl_import Method ==
cs_mdl_import can be found here: .
Usage: cs_mdl_import -o <path> [options] <filespecs...>
Options:
 -h : Print this message
 -game <game> : Override the mod (Default csgo)
 -v : Verbose mode
 -i <path> : Input path (this is replaced by the ouputpath from -o
 -o <path> : Output path (Required)
 -l filelist.txt : List of files or filespecs
 -r : Recurse input dirs
 -skipcommondmxwrite : Skip writing dmx files (anims)
 -YupToZup : Change bindpose from Yup to Zup
 -c <changelist> : Changelist to use, "default" by default.
 -overridelean : Override "lean" sequence
 -write_weapon_anim_prefab : Write sequences & weighlists into a prefab.
 All sequences & weightlists will be prefixed with the weapon filename in the prefab
 -header_hull_bounds : Import mdl hull bounds from the studiohdr (typically we use we derive from physics hulls)
 -weapon_anim_prefab <path> : Path to a prefab to be included. Path relative to 'output path'.
 -lods : Import all lods. By default, only lod 0 is imported.
Example usage: 
== Read More ==
* MDL
* VMDL
* Model Editor
* ModelDoc
Category:Source 2
Category:Modeling