Do you want to learn how to port models but don't know how? Either because 3D modelling is daunting, you don't know how GMod or SFM works, or you don't know where to get the models in the first place? I hope this tutorial will help guide you through the process.
Texture details are explained in part 2, over here:
SFM/GMod Porting Tutorial Part 2 (Textures)This honestly took too long to come out. The previous part is
Extracting textures is easy. Using them correctly is another task, though. I hope to provide as much information on the texture parameters for SFM/GMod as I can along with information on the textures themselves.
Tools
I use Noesis to convert DDS files to TGA or PNG, and use VTFEdit to convert those to VTF. Switch Toolbox can extract textures from BNTX files, which are often included in the BFRES model files, directly into PNG.
Texture Types
What type of textures do the models use? More often than not, the suffix of a texture name denotes its role. Here's a list of the ones I personally know.
_Alb
Please let me know if there are details in the porting tutorial that require more explanation. I'd love to make this as clear as I can for everybody and it's hard to do without remembering how it felt when this was all new.
Tools
A major difficulty with porting is finding the required tools for importing, extracting, and converting, not to mention with free programs. Every tool required are included with links directing you to their source.
Blender (
Steam version) is what we'll use. This is not a Blender tutorial, though Blender tricks will be shared to help kick-start your modelling knowledge and UI screenshots are included to help you find where everything is (Blender 3.0 screenshots will be shared soon).
We're porting for SFM/GMod so we'll use the
Blender Source Tools. Its installation instructions are found on the website.
Crowbar will be used as the model compiler (raw-asset to game-usable converter). There are other options for compilation but this one is the simplest, and can also act as a decompiler if necessary.
A popular method of extracting Nintendo models like BFRES is using the
Switch Toolbox. Extracting the data from Switch cartridges themselves is beyond the scope of this guide. Already-extracted models can be found on the
Models Resource.
Model Manipulation
More often than not, model manipulation is required for the model to work in a new format. The only one absolutely required for GMod and SFM is the maximum number of weight groups a vertex is allowed to be in, which is 3 (in other words every point can be influenced by 3 bones at most). This can be assured by entering
Weight Paint mode and select Limit Total on the left menu.
This menu is on the left, in Weight Paint mode. Press T if it doesn't appear You can leave this step until the very end, but make sure to remember to do it. If you receive a "Too many bone influences per vertex!" error during compilation, it means you forgot this step.
If you want to create models to merge onto the existing Inklings and Octolings, you need to import their bones, which can be done by decompiling the models using
Crowbar.
New Materials
You want to make a certain part of a model transparent (such as a logo) without affecting the whole texture? Or maybe you want certain parts to have certain effects such as metallic reflection? Whatever the reason, adding a material is actually easy.
This menu is on the right, in Edit mode. Click on the plus button to add more materials or minus to remove the material.
Assign sets the selected faces to the selected material,
Select selects all faces that are assigned to the material, and
Deselect deselects all faces that are assigned to the material.
Split Model
Want to separate a wristband from a gear or make a part of a map its own object? After selecting the parts you want to split in Edit Mode, hit P and select the first menu's option (separate by selection). Pressing L while hovering over a vertex will select connecting vertices, helping you select parts of the full object, but it's up to you to properly select areas.
On the contrary, hitting Ctrl+J joins the selected objects.
Flexes
Flexes are called "Shape Keys", and they are found in the Data tab.
This menu is on the right.
Add shape keys using the plus button and remove them using the minus button. The Basis shape key will be the first key added and is simply the default state. A flex can only be edited when its slider is at 1, in case you're experiencing odd issues unable to edit the model. Pressing the tack sets the selected shape key to 1 automatically, allowing you to sort through them and quickly edit as necessary.
Flexes can be whatever you want. The bust adjust slider is created by adding bumps to clothing using
Sculpt Mode, for example.
Make sure the flex sliders are all set to 0 before compiling.
Eyes
All you need is the center of the individual eyeballs, either the actual center of a sphere or the center of the sphere section, and the center point of the eyes as a compilation parameter later. I'm not too sure of easy ways to calculate this, but some models have eye bones and those positions should suffice.
More information are found
on the wiki.
Physics collision
It's actually relatively easy: Just split the model and set the weight of each section to their corresponding bone to 1. Model pieces should not overlap to prevent collision glitches, and make sure each object's origin is set to (0,0,0) by hitting Ctrl+A in object mode and selecting Apply Location. More information on collision meshes can be found
on the wiki.
If you want to view collisions in GMod, type "vcollide_wireframe 1" in the console.
Model Export
More often than not you need to group the model(s) with its skeleton. This allows you to work on multiple parts at once (such as for creating body groups) and choose the exported DMX's name. This is relatively simple to do: just select the models to group and hit
New Group. Name the group as you please.
Now comes the exporting! The export function is unusually not placed in the export main menu, but rather as a property of the scene.
This menu is on the right, in object mode
The Export Path can be wherever you want, and the default values should suffice for both SFM and GMod. I recommend the DMX format over the SMD format due to its more convenient and up-to-date features. When hitting Export, select the group you have created.
Compilation
Tired? This is the final step, so keep it up! To be able to use the model in-game, it must be compiled into a game-specific format. The compiler requires instructions on how to create a model; these instructions are stored in a
QC file. A QC file is really just a text file with a different extension, so create a text file and
rename its extension. Every line is a command (empty lines are allowed for organization). Here's a list of important commands:
$modelname path
The path to the exported model, relative to the
models folder of the addon, including the mdl extension.
$body bodyname path
The path to the DMX file. There can be multiple of them, or none if they are all body groups (see below).
Bodyname can be whatever you like.
$cdmaterials path
The path to the materials, relative to the
materials folder of the addon. The path tends to be "models\" followed by the model path (without the mdl extension) by convention. There can be multiple paths, though keep in mind the order matters.
$sequence name file
An animation for the model. There has to be at least one animation, so usually it's just the DMX file itself with "idle" as its name.
$texturegroup skin {
{ texture name 1 }
{ texture name 2 }
}
A list of VMTs for the model's alternate skins ("skin" is actually the name of the texture group but goes unused). The first texture name must be the name of the material within Blender.
$bodygroup name {
studio dmx path 1
studio dmx path 2
blank
}
A list of DMX files for each model of the body group, or "blank" for no models. The DMX names do not appear in GMod but they do in SFM.
$scale number
In the offset chance that the model's scaling should change, there's no need to re-import the DMX into Blender just to scale it up; it's simpler to change it here. Make sure this command comes before other commands or else they will not be scaled.
Inkling and gear scale is 4. NPC scale is 3. Scaling can vary from model to model so it's recommended to set the scale here instead of scaling inside Blender.
$model name dmx file {
...
eyeball name bone X Y Z texture diameter angle unused scale
...
}
Use this instead of $body if you're doing NPCs with controllable eyes. XYZ is the sphere center coordinate for the eyeball (note that using $scale will not adjust these XYZ coordinates!). You should read up the
$model commands for more options.
$attachment name bone X Y Z
Special position relative to a particular bone, though this is mainly for the eyes. The name is "eyes" and they are normally attached to the head bone. Note that XYZ typed here should actually be X -Z Y of the eye center you calculated earlier.
$collisionjoints dmx file {
...
}
Particularly important for GMod. Use $collisionmodel if it's a static model like a box or simple prop. Check out the
$collisionjoints commands.
A list of all QC commands can be found
on the wiki.
Example
$modelname "test\folder\wooden_box.mdl"
$body body "WoodenBoxModel.dmx"
$sequence idle "WoodenModel.dmx"
$cdmaterials "models\test\folder\wooden_box"
$cdmaterials "models\test\shared"
$texturegroup skin {
{ "oak" }
{ "dark_oak" }
}
$bodygroup Sticker {
blank
studio "Sticker.dmx"
}
$collisionmodel "WoodenBoxPhysics.dmx" {
$mass 100
$inertia 5
}
Open up
Crowbarand find the QC file. Select the game from the drop-down list and hit compile (the UI can be found
here). It's that simple.
Note that the models won't have textures! Check out part 2 of the tutorial (link at the top of this page).
Blender Tips
Shortcuts
Ctrl + Tab Switch to Weight Paint Mode
Ctrl+J Join (objects and bones)
Ctrl+D Duplicate
Ctrl+A Apply Transform
Ctrl+P Split objects
L
Select vertex island
Ctrl + +/-
Selection step forward/backward
Simple functions
Remove duplicates
Recalculate normals (Ctrl + N in edit mode)
Subdivide
Complex functions
Trigs to Quads (Ctrl + F in edit mode)
Beautify faces (Ctrl + F in edit mode)