This article relates to the game "Half-Life: Alyx". Click here for more information.
This article relates to the workshop tools for "Half-Life: Alyx". Click here for more information.
This article's documentation is for Source 2. Click here for more information.

Models

来自Valve Developer Community
跳转至: 导航搜索
English (en)Русский (ru)中文 (zh)Translate (Translate)


Source 2 Source 2 has a built-in system for taking old .mdl files from Source Source 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.

Note.pngNote:Models that use flexes, such as character models, need extra work to make functional in Source 2, and will in most cases require having the sources of those files.

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 Source Filmmaker Source Filmmaker already ships with content from a ton of games. However, Half-Life 2 Half-Life 2 and Left 4 Dead 2 Left 4 Dead 2, among others, have all been tested and are incompatible, but luckily, Valve has already ported a lot of content from those games.

Todo: This may just have something to do with headers, which are easily modifiable. Please do more testing to determine which branches are the most stable.

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 Half-Life 2 Half-Life 2, let's say "models/humans/group01/male_07.mdl" for use in Half-Life: Alyx Half-Life: Alyx. 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 Source Source. 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 Source Source .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

Note.pngNote:You don't need to do this if you're running with '-nocustomermachine' as a launch parameter. This will enable you to modify the m_sMDLFilename line in the Model Editor.
Note.pngNote:source1import can be used to automate this whole process.

Half-Life: Alyx and ModelDoc

ModelDoc-ImportAndConvertOldVMDL.png

Half-Life Alyx introduced a new model editor called ModelDoc. 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 Source 2 Source 2. 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.

Todo: Note other issues and test compatibility with more games.

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: 🖿.../game/bin/win64/cs_mdl_import.exe.

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: cs_mdl_import -game csgo -r -i [import path] -o [output path] *.mdl

Read More