Cleanup is going to take awhile, so the site is back up but editing has been disabled.

Importing Custom Models

From HalfLife 2 Knowledge Base

Jump to: navigation, search

by Sideeffect

Contents

File Structure

Alright, here is how I did it. First of all here is how I set it up to compile.

  • sourcesdk/cstrike_sample_content/ (this is where your .qc file will be)
  • sourcesdk/cstrike_sample_content/materialsrc/models/tree (the folder that contains your textures in .tga format)
  • sourcesdk/cstrike_sample_content/materials/models/tree/ (the folder that contains your compiled textures in .vtf and .vmt format)
  • sourcesdk/cstrike_sample_content/models/tree/ (the folder that contains your .smd files and where your .mdl will be compiled)

Compiling Textures

Now that thats set up I compiled my textures. Open up the command prompt and define VPROJECT by typing this in.

set VPROJECT=c:\sourcesdk\cstrike_sample_content

or wherever your cstrike_sample_content folder is. This is just basically asking you to define what your mod folder is.

Now while you're still in the command prompt you have to run vtex to compile your .tga into .vtf and .vmt. Go to the directory that your vtex.exe is in by typing

cd <directory>

Now you have to run vtex and tell it to compile the textures you want by doing this.

vtex.exe -mkdir -shader VertexLitGeneric c:\sourcesdk\cstrike_sample_content\materialsrc\models\tree\tree.tga

After it's done compiling, a .vtf and .vmt should appear in your materials folder. Now since these textures are going to be applied to a model you'll have to open the .vmt in notepad.

"VertexLitGeneric"
{
	"$baseTexture" "models/tree/tree"
}

Add in this line after the $baseTexture line. "$model" 1 In this file you can also make your materials have transparency and other effects.

Compiling The Model

Now we have to get the model ready for importing. In 3D Max or another program make sure your model is assigned to your .tga texture. After you're done export 3 .smd files (this is the minimum).

  1. Export a .smd set to refrence.
  2. Export a .smd set to skeletal animation.
  3. Export another .smd set to refrence using your physics model.

Alright the final step is to compile the .mdl file. Create your .qc file. Here is mine for refrence.

$modelname tree/tree.mdl
$cdmaterials models/tree
$staticprop
$scale 1.0
$body studio "models/tree/tree.smd"
$sequence idle "models/tree/idle" fps 1
$collisionmodel "models/tree/tree_phys.smd" {
       $Mass 100
   $concave
}

When you're done open the command prompt again and go to the folder that has your studiomdl.exe. Now run studiomdl.exe and tell it to use your .qc file.

studiomdl.exe c:\sourcesdk\cstrike_sample_content\tree.qc

You've now finished importing your model. Move your files into your Counter-Strike Source folder and make sure to keep the folder

Finished product

Image:tree2.jpg

Also here is my files for you guys to use as a refrence if you need to: treecompile.zip

Good luck guys.

Personal tools