PDA

View Full Version : [SOURCE] Compiling models for source



Sel
November 25th, 2009, 12:49 AM
Since this site is populated by modelers this might help some people out.

Now, you're going to need these : http://files.modacity.net/apps/Model%20Tools.rar

Download and place in a folder you'll remember. Now install VTFedit.

Second, you're going to need the appropriate plugins which can be found here : http://con.modacity.net/source/

Here are the above plugins, and some other related plugins, which may be of use if you don't use 3ds: http://www.wunderboy.org/3dapps.php

Before actually working with the model, you need to create some directories first. Navigate to your game folder, for this example I will use Team Fortress 2. In your tf folder create a folder called 'models', you can create another sub folder for organizations sake, I use props_sel, and inside that I make a folder for my models. Ex : tf/models/props_sel/tankblue

This is where all your model exports will be placed, and compiled.

Next navigate back to the tf folder, and open the folder called materials. Create a folder called models here, and inside have it match up to whatever you name the folders inside your above models folder in the previous step. Ex : tf/materials/models/props_sel/tankblue

This is where you will be placing your textures, and shaders. (VMTs, and VMFs)

Now at this point you should have all your plugins installed and ready to go.

So start up max and open your model, in my example I used a King Tiger model which wasn't really set up for source, and probably had more than enough detail on it, however for my own learning purposes, and for this example it is fine.

http://i93.photobucket.com/albums/l42/selentic/Models/tut1.jpg

Now the left is the actual mesh, and the other is a collision model, which is quite similar to what you would have done for one in halo, ie: have some geometry that relatively matches the shape of your mesh, and won't look absurd when players collide with it.

Now take your bitmap and import it into VTF Edit. (File --> Import)

Now save it as a VTF in your materials folder, for this example : tf/materials/models/props_sel/tankblue

Now goto tools, and select create VMT File, reference any related bitmaps here, but for this example we will only use a base map, which was a solid blue.

Under the options tab, set the Shader to VertexLitGeneric, and create your VMF. Save it in the same location as your VMT.

Now return to 3ds, and open up your material editor. Create a Standard material which directly references to the VMT in the bitmap field.

http://i93.photobucket.com/albums/l42/selentic/Models/tut2.jpg

Apply this material to your collision model, and your model, and ensure it is applied to the entire thing, ie: Every face has material ID #1.

Now select your model, (not the collision) and goto file --> Export Selected.

http://i93.photobucket.com/albums/l42/selentic/Models/tut3.jpg

When prompted, select 'Export Reference SMD', the other field is for animations.

Create 3 SMDs of your model, and save them in tf/models/????/????

modelname
modelname_anim
modelname_idle

Now go back into 3ds, and select your collision model, and export that as

modelname_phys

Save this in the above folder.

TROUBLE SHOOTING: To ensure you have applied the texture correctly you can open an SMD file with notepad, if you did it correctly it should look like this :


tankblue.vtf
0 -37.119904 14.413091 120.708740 -0.378926 0.656319 0.652427 0.685600 0.632234 1 0 1.000000
0 -12.891615 23.231474 120.708740 -0.131600 0.746338 0.652427 0.564458 0.632234 1 0 1.000000
0 -13.891865 28.904165 114.017761 -0.131600 0.746338 0.652427 0.569459 0.598779 1 0 1.000000
tankblue.vtf
0 -13.891865 28.904165 114.017761 -0.131600 0.746338 0.652427 0.569459 0.598779 1 0 1.000000
0 -40.000004 19.401571 114.017761 -0.378926 0.656319 0.652427 0.700000 0.598779 1 0 1.000000
0 -37.119904 14.413091 120.708740 -0.378926 0.656319 0.652427 0.685600 0.632234 1 0 1.000000
tankblue.vtf
0 -56.870979 -2.160037 120.708740 -0.580548 0.487137 0.652427 0.215645 0.252914 1 0 1.000000
0 -37.119904 14.413091 120.708740 -0.378926 0.656319 0.652427 0.314400 0.335780 1 0 1.000000
0 -40.000004 19.401571 114.017761 -0.378926 0.656319 0.652427 0.300000 0.360722 1 0 1.000000If tankblue was replaced with 'material', then you did something wrong, and the bitmap was not exported.

NOTE : If you did not apply the bitmap correctly, the exporter will give you a warning that it is skipping the mesh for that reason.

Now it gets complicated.

There is an example QC file in the model tools you downloaded at the beginning, set it to be opened with notepad, it's contents should look like this.


$modelname "modelname/model.mdl"

$cdmaterials "models/model texture name/"

$scale 1.0
$surfaceprop "Metal"

$body "Body" "modelname"

$staticprop

$sequence "idle" "modelname_idle" fps 30

$collisionmodel "modelname_phys.smd"
{
$mass 100
$concave
}



The one I used for my King Tiger looked like :


$modelname "props_sel/tankblue/tankblue.mdl"

$cdmaterials "models/props_sel/tankblue"

$scale 1.0
$surfaceprop "Metal"

$body "Body" "TankBlue"

$staticprop

$sequence "idle" "tankblue_idle" fps 30

$collisionmodel "tankblue_phys.smd"
{
$mass 100
$concave
}
These should be pretty self explanatory, they link all your model files together so that the compiler knows how to reference the animations, collision, etc.

Edit these according to your directory layout, so that they all reference the appropriate files.

Now return to your model tools, and run GUIStudioMDL.

You will probably get a warning that you have not set your game info files, so do this now. Once you have done that open up the QC file and set what you want to compile for.

http://i93.photobucket.com/albums/l42/selentic/Models/tut4.jpg

Now hit compile and wait for your model to compile.

I'm not going to cover errors at this time, because for the most part I don't understand them myself.

Once your model is compiled you should notice several new files in your tf/models/????/???? folder.

You should now be ready to open your model in source, so open the source SDK, and launch the model viewer, and open your model.

http://i93.photobucket.com/albums/l42/selentic/TF2/whoosh.jpg

Hope this helps, I'll try to update it as I learn more about how this engine works.

I'd also like to thank Tyker for teaching me pretty much everything regurgitated in this tutorial, and Youme for bringing my attention to ensuring the texture was exported in the SMD. Finally I'd like to thank wunderboy for the 3ds max plugins, these things are great.