Not enough ratings
Converting XNA Model Files to Work in SFM Using Blender
By Pte Jack
This is a video series demonstrating the process of converting XNA Model files into Valve Model Files and Materials for use in SFM.

It is a lengthy process, but learning this process will help you bring more custom content into your model inventory.

We will be using a variety of different programs during this process, these are XNALara, Blender, Gimp, VTFEdit, Notepad ++ and GUIStudioMDL. Part 1 of the Series shows you where to get these programs and Part 2 will show you how to install them. As we use the programs you will see further steps required to configure them.

It is beyond the scope of this guide to give DETAILED instruction in the use of Blender, XNALara, GIMP, or any of the other programs used here beyond what you see in the videos. For that kind of instruction visit the numerous tutorial websites out there that specialize in the program you want to learn.

I used this process to convert the BioShock Infinite Songbird seen in the workshop and depicted in the Title picture here. By the end of the series you will have converted an XNA model into a working SFM Model and the last video of the series will even show you how to upload your conversion to the SFM Workshop.

The beauty of this process is that the Blender and the compile portion is pretty much the same if you decide to create your own 3D content. The only thing that is different, is that you have to create your materials (with a GIMP or a 3D-Coat type program) before you can skin your model.

Anyway, without further ado...

We're GOin' a Wreck It....
Rate  
Favorite
Favorited
Unfavorite
Pt. 1 - Introduction and Getting the Required Programs
http:// http://youtu.be/rJipJO1CMTI

The Programs required to perform this process are as follow:

1. XNALara Poser
This is a poser program used to create 3d art. It also has the ability to export XNA models into .mesh.ascii text files or .obj type model files. The prefered export is the .mesh.ascii type file. This type of file contains most (if not all) the model information, including skeletal and texture information, required by Blender to make conversion easier. The .OBJ model will only contain rough mesh and minimal texture information and does not include the model skeleton.
Available at http://www42.zippyshare.com/v/11045391/file.html

2. Microsoft XNA Framework Redistributable 3.0
This is the background program that XNALara requires to run in Windows. If this is not loaded on your computer, XNALara will not start.
Available at http://www.microsoft.com/en-us/download/confirmation.aspx?id=22588

3. Blender
This is a powerful and free 3D editing tool. (This series assumes you have a basic knowledge of Blender. If you don't, I would suggest you go to http://www.Blendtuts.com and watch the Begginner's tutorials, especially the tutorial on Basic Interface. (http://blendtuts.com/2010/06/blender-25-interface.html) Although this particular tutorial talks about Blender ver 2.5 the interfaces have not change too much to todays (v2.68) interfaces.
Available at http://www.blender.org/download/get-blender/

4. Blender 2.63 importer by Dusan, sephirostoy, XNAaraL and FigureSculptor
This is a Blender Plug-in that allows the ability to import the .mesh.ascii models exported by XNALara. Without this plug-in you will not be able to take advantage of the detailed information contained in the .mesh.ascii file.
Available at http://www27.zippyshare.com/v/27747054/file.html

5. Blender SMD Script
This is another Blender Plug-In required for the ability to import and export the Valve Model Source files reuired to build the model for SFM. This tool allows modelers to export in both .SMD and .DMX formats
Available at http://code.google.com/p/blender-smd/downloads/list

6. GIMP
This is is an extremely powerful and free Image Manipulator Tool. It is almost if not par with Photoshop (when you learn to use it effectively)
Available at http://www.gimp.org/downloads/

7. GIMP VTF Plugin
This is an extremely useful Plug-In for GIMP that allows you to convert almost any image file to the VTF Texture format required by Valve Models.
Available at http://code.google.com/p/gimp-vtf/

8. VTFEdit v.1.3.3
This tool is also used to convert images to and from VTF format. BUT, it also is an extremely useful tool for auto-generating simple .VMT files required by the Valve Model Material files.
Available at http://nemesis.thewavelength.net/index.php?p=41

9.Notepad++
A very powerful and effective pure text editing tool. (I prefer this one because of the programmer interfaces and plug-ins available.)
Available at http://notepad-plus-plus.org/download/v6.4.5.html

10. GUIStudioMDL
This is a graphic user interface program used to send commands to the Valve StudioMDL compiler. It is a useful tool when correctly set up. You can use the Valve StudioMDL tool directly, however it required that a batch file be written to send the proper commands. This tool does that chore and interfaces with the Valve program from a Windowed Environment.
Available at http://www.wunderboy.org/apps/guistudiomdl2.php
Pt. 2 - Installation of the Programs Downloaded in Pt1
In this Video we install the programs that we downloaded in Part 1. XNALara requires a Windows Feature to be activated and a framework shell be installed in order for it to work. Blender requires 2 plug-ins and Gimp requires 1 plug-in installed. Here's the breakdown of the actual install process:

1. XNALara and Blender contents are designed to run from anywhere on your computer, the main folder can be dragged straight on to your desktop from their zip files or you can tuck Blender into your Program Files Folder (if you downloaded the 64bit version) I would stick XNALara in your Program Files (x86) folder if you want to tuck it away.)

2. Gimp, VTFEdit, Notepad++ and the Microsoft XNA Framework programs all have installers, just double click and follow the install instructions.

3. GUIStudioMDL, open the zip file and extract the GUIStudioMDL.exe to your Steam\Steamapps\username\sdktools\bin\ep1\bin folder

4. The import_xnalaura_mesh_ascii_extended.py plug-in file goes into your blender\2.68\scripts\addons folder

5. Open the io_smd_tools-1.8.6.zip and drag the io_scene_valvesource folder and the io_smd_tools.py file into the same blender\2.68\scripts\addons folder

6. Open the gimp-vtf-1.2.1_x64.zip then use a file browers to find your GIMP install folder. Drag the file-vtf.exe and the VTFLib.dll files from the zip file to your GIMP 2\lib\gimp\2.0\plug-ins folder.

7. Open your Control Panel and goto Programs and Features, Click on Turn Windows Features on or off, Find .NET Framework 3.5 (includes .NET 2.0 and .Net 3.0) and ensure that the feature is turne on. (Required for XNALara)

8. After the install, it is always good to re-boot your computer, especially if you had to turn on the .NET Framework

http:// http://youtu.be/dTZ3PNirDdA
Pt 3 - XNALara - A 3D Model Posing Program and Required for Exporting XNA Models
In this video we look at what the XNALara Poser program is, what it can be used for and how to export model data into a format that can be imported into Blender for editing. We also look at a new resource for possible model content for SFM, the XNALara forum at Deviantart.

http:// http://youtu.be/J5abbO1D1-8

Export Process for XNA models to .mesh.ascii format which is readable by Blender if the proper plug-ins are installed.

1. Download the applicable XNA model from wherever.
2. Extract the model folder (including materials) to the XNALara Data folder.
3. Load XNALara
4. If XNALara displays an error message and crashes, go to the XNALara main folder and delete the XNA.cfg file then re-launch XNALara. (It should load)
5. Select File, then Add Model(s) in the Control Window, then select the model you want to load, click OK.
6. View the model in the Pose Window to ensure it is the model you want.
7. At this point you can pose the model, or just leave it as is.
8. To Export the model to work in Blender, if you hve more than one model loaded in XNALara, ensure you have the model you want displayed in the Model: text box. Select File, then use the export as method of choice.
1. Export scene as .obj - no skeletal info and limited texture info will be exported
2. Export selected as .mesh.ascii (T-Pose) - This is the preferred method This should export all the model info required by Blender to include skeletal Vertex group and texture information.
3. Export selected as .mesh.ascii (Posed) - Same as above, but if you posed the character in XNALara, that pose position will be exported to the .mesh.ascii file and should load in Blender that way.

Once the export is complete, you can close XNALara. It is no longer required.

If you wish to find out more about the XNALara Poser tool, Check out the #XNALara group at Deviant Art.

3D Model Resource Warning:
This is an artists' website which caters to all types of artistic flavours. The site does contain mature content which may include nudity and sexually explicit content, therefore user descression is advised!!!

Deviant Art XNALara Gallery:
http://xnalara.deviantart.com/gallery/
Pt 4 - Blender - A Free Open Source 3D Editing Program (and much more!!)
This video discusses the set up of the required plug ins for Blender. I also give you a really good source for beginner tutorials. A website called Blendtuts. If you have never used, or are just starting to use Blender for the first time, I suggest you go to this site and watch the Basic Interfaces video there. It will explain the fundimental set up and basic keys needed to manouver in the Blender world.

Tutorial Resource
www.blendtuts.com

http:// http://youtu.be/1Sp8R-7eZig
Pt 5 through Pt 11 - Using Blender
It is hard to give a step by step proceure for these videos. This is where we import the mesh.ascii file and begin the Blender process of removing duplicate vertexes, working the armature (bone/skeleton) settings, rename Bones so they fall into known bone groups in SFM, fixing any broken meshes, assigning vertex groups to make linking the armature easier, skin and name textures and materials and make UV maps so the SMDs know what materials to call for the model in SFM, rescale the model so it is the scale you want it to be in SFM and export the SMD files required for compiling.

Pt 5 - Blender - Looking at and Identifing the Imported Model

http:// http://youtu.be/eXQBrQEJfdA

Pt 6 - Working the Armature (skeleton) AKA "Dem Bones"

http:// http://youtu.be/m6vEP-y_orU

Pt 7 - Materials and Texturing the Model - Ensuring that the Materials are properly named

http:// http://youtu.be/SIRIt9VS62w

Pt 8 - He's Not Normal - Discussing the Normals Direction of the Mesh Faces and Applying Light to see What the Model will Look Like.

http:// http://youtu.be/iv14P-tQnvw

Pt 9 - Scaling the Model - Is your Model really as BIG as You Think IT is??

http:// http://youtu.be/8bTjZkCGELY

Pt 10 - More on Scaling and Bone Naming Conventions - Getting rid of those UNKNOWN Bone Groups

http:// http://youtu.be/SGw1jSDKe9M

Pt 11 - Creating the Idle Sequence - Required for Posable Characters and Exporting the SMD

This segment shows you how to set up the required Idle Sequence for nonStatic models. It also goes through the SDM Plug-in settings and the export process to export your smd files.

http:// http://youtu.be/3yDrjaUneVw
Pt 12 - The GIMP (General Image Manipulation Program) - A Free Graphics Editor
We use The GIMP Image Manipulator Program and it's VTF Plug-in to convert the skin's TGA image files to Valve Texture Files (VTF). model.

http:// http://youtu.be/hBq-Iqg1m9g
Pt 13 - VTFEdit - Used to create the VMTs for Our Material Files
We use VTFEdit to create the basic VMT files that call the skins to the model using the GUI VMT creation tool in the program.

http:// http://youtu.be/wI0bNmUQgDg
Pt 14 - Creating the file that Pulls it All Together, a Basic .qc and Using the GUIStudioMDL Compiler Interface
We create a very simple .qc file which is used by the Valve StudioMDL program to compile the model. As this is a multi-part model, you get some limited experience calling the various parts that build the model.

We then set up the Graphic User Interface program that assists us with getting the .qc to StudioMDL. This program is called GUIStudioMDL. We first have to configure the tool, then we have to inform it about the GameInfo.txt file for SFM. This will allow us to use the correct version of the Valve StudioMDL Compiler so the model will load into SFM correctly.

We finish this part by bringing our newly compiled model into SFM.

Your finished .qc file should look something like this:

Your end qc should look like this

$cd "C:\{change this to the folder path where you put your smd files}\ralph"
$modelname "ralph/ralph.mdl"
$model "body" "body.smd"
$model "body" "eyes.smd"
$model "body" "hair.smd"
$model "body" "head.smd"
$poseparameter body_pitch -45.00 45.00
$poseparameter body_yaw -45.00 45.00
$cdmaterials "models\ralph"
// Model uses material materials\models\ralph\body.vmt
// Model uses material materials\models\ralph\hair.vmt
// Model uses material materials\models\ralph\eyes.vmt
$surfaceprop "flesh"
$illumposition 0.000 1.680 40.090
$sequence idle "idle" fps 30.00

http:// http://youtu.be/QxPCdxbnGYo
Pt 15 - The Conclusion - Uploading Your Newly Compiled Model to the SFM Workshop
In this part, I show you that properly named bones will appear in the known bone groups in SFM, then take you through the step of uploading your model to the SFM Workshop.

http:// http://youtu.be/mN_gmikx5ks


And there you have it..

19 Comments
< >
Pte Jack  [author] 14 hours ago 
You have to be careful with that. Studiomdl has a limit to how many verts can be in a object before it starts splitting the object into separate model. I think the limit is somewhere around 12,000 to 15,000 verts. If Studiomdl starts splitting the model, then some things make break, especially flex controls.
GOOD NIGHT CLOUD NINE 18 hours ago 
Just want to add a tip that if you want your model to be exported as a single .SMD in Blender, put all the meshes that you want to be grouped into one SMD into a Group in the Object panel. Grouping doesn't affect the individual meshes in any way except it makes the Source tool able to export the "grouped" meshes as one big SMD.
I'm surprised I missed that. Thanks.
Pte Jack  [author] Apr 17 @ 3:56pm 
Try this, Flexes is the section I'm having problems writing, there are so many things to cover (especially when it comes to Advanced shapekeys...)
http://steamcommunity.com/sharedfiles/filedetails/?id=245723825
I was wondering if you would be interesting in creating a video tutorial on creating facial flexes for source models. I've only found one guide on steam and one simple video about on youtube.
OK, I think I found the answer. This worked for me:

In the VMT there needs to be these command: "phong" "1", "$ambientocclusion" "1", and "$AmbientOcclTexture" "models/ modelname / modeltexture_o "
However, that might not enable the AO correctly (it'll create a weird transparent effect when SSAO is enabled in SFM).

To fix that you need to re-compile the model with these commands in the qc:
$mostlyopaque
$ambientboost

There was a disscussion about it here: http://facepunch.com/showthread.php?t=1304930
At the very bottom, user "Gmod4ever" made a PDF about it.

Remember that this is the first I'm going anything like this and might be adding/using unnecessary commands
Pte Jack  [author] Apr 2 @ 5:22pm 
What I usually do for occusion is use Blender to create occulsion skins. I'll select an object in Blender and set the Blender texture to pure white. (this method kind of suck if you're using layered uvs, ie, left and right or inside and outside UVs use the same uv island, but there are work arounds for that too.) I'll create a new TEMPORARY material in blender and assign the objects vertexes to that. Heck, it's easier for me to make a tut for this than explain it... Give me a bit to do one up. All in all though, once I have a bake OA skin, I use gimp to overlay the AO onto the skin material. As for DuDv, Detail textures, etc, these are some of the VMT commands that are available
Pte Jack  [author] Apr 2 @ 5:21pm 
"$basetexture" "material path\name"
"$bumpmap" "material path\name"
"$basetexture2" "material path\name"
"$bumpmap2" "material path\name"
"$envmap" "material path\name"
"$envmapmask" "material path\name"
"$detail" "material path\name"
"%tooltexture" "material path\name"
"$normalmap" "material path\name"
"$dudvmap" "material path\name"
"$additive" 1
"$alphatest" 1
"$envmapcontrast" 1
"$envmapsaturation" 1
"$nocull" 1
"$nodecal" 1
"$nolod" 1
"$translucent" 1
"$vertexalpha" 1
"$vertexcolor" 1

You would have to try them out to see what actually works in SFM.
Cool.
Then would you know how to set the occlusion texture file when creating the vmt (like do I set it to "detail texture" or "DuDv Map")?
Weird about the medic skin mishap.
Thanks for the response.
Pte Jack  [author] Apr 2 @ 3:53pm 
Loading the materials in Blender is not going to affect how they look in SFM. Loading them in blender just gives you how they look according to the current UV layout. Materials in SFM are controlled via the commands given to them in the vmts. The reason I load them all in blender is to giveme a visual reference of how they should look after I write the vmt commands and to ensure that the seams and general lay out is correct (So I don't end up with a model that looks like the TF_Movies Casual Medic when I load it, the texturess aren't laid out properly for the uv map on that skin.)