Tutorial: Create your own models

From Empires Wiki
Jump to navigation Jump to search

Home > Tutorial: Create your own models

Limitations and features of HL2 models

  • You can use 32 different textures on one model and up to eight different LOD models.
  • Faces without texture specified will be ignored while compiling.
  • Textures must be defined with VMT files as VertexLitGeneric.
  • You can add static entities in your model, such as smokeemitters.
  • Up to 20 sub models for physics collision detection. (can be overwritten by $maxconvexpieces)
  • Custom gibs, that spawn on zero health and disappear after a while.

Item checklist for Empires model creation

1. 3D model editor to build the model and it's collision mesh. (Blender, 3DMax, XSI...)
2. Texture (Graphics) Editor. (gimp, mspaint, photoshop....)
3. Text editor to create the "QC" model build description file.
4. The VTFEdit utility to covert Textures to VTF format and create the associated .VMT file (link below)
5. Valve model building utility, studiomdl.exe. (located in the ../empires/bin folder)

These are the basics needed to complete and put a model in Empires.
If this is your first experience with model making, the learning curve may be steep, but you can do it!
There are endless internet and youtube video tutorials on most of these topics to help.

How to create your own models for Empires

Setup

Set up a folder to place your project files and materials. I used VTFEdit and converted the .VTF 's to TGA 's, because your model editor may don't know the VTF format. Make sure you used the same filenames (except the ending, like .TGA ). To compile the model you don't need the VTF's, but you need them for proper rendering ingame.

Brushes and models use different texture shaders, and models can only use VertexLitGeneric shaders. Each texture has an individual VMT file that contains information about the shader to use, which is always the first line. If parts of your model are invisible and you getting warnings in the console your possible not using VertexLitGeneric.

Create your model

You can use any model editors you wish. If you have not used 3D software before, there are many good internet and youtube sources to learn from.

If you work with Solidworks, it's also possible to build a model, export as a .obj file, then convert the object file to SMD with one of the other free apps.

When your model is complete it will need to be saved in SMD file format. Research plugins if you don't have native SMD support in your editor.

Valve developer tutorial - Model Creation

Valve developer tutorial - How to export models

Prepare for compiling

Find studiomdl.exe, by using file search or have a look at <path to steam>\Steam\steamapps\<your steamname>\sourcesdk\bin\ep1\bin.
Note
<your steamname> is your Steam login name. (ex: bob123 , \Steam\steamapps\bob123\sourcesdk\bin\ep1\bin)
Note
<path to steam> is the path to your Steamfolder (ex: C:\Program Files (x86)\ )
Create a shortcut to studiomdl.exe.


Right-click your newly created shortcut and select Properties


Append this to the path in the Target-field:
-game <path to steam>\Steam\steamapps\SourceMods\Empires
click OK.


Now copy your smd file (my is named nf_radar.smd ) to this folder \Steam\steamapps\SourceMods ,right next to the Empires-directory.
The next step explains how to create a new file in the same folder named Empires.qc.
The Empires.qc file tells studiomdl how to handle your model. Use for example notepad to create this file. Open notepad and Copy&paste the example below, modify it, select Save As... *.* and save it as Empires.qc (make sure its not Empires.qc.txt !)


example content of Empires.qc

//modelname and folder
$modelname "NF/Buildings/radar/NF_radar.mdl"
//LOD
$model "base" "reference.smd"
$lod 300
{
 replacemodel "reference" "lod1_reference"
}
$model "inside" "inside.smd"
$lod 100
{
replacemodel "inside" "lod1_inside"
}
$lod 300
{
replacemodel "inside" "lod2_inside"
}
$model "crates" "crates.smd"
$lod 100
{
replacemodel "crates" "lod1_crates"
}
$lod 300
{
 replacemodel "crates" "lod2_crates"
}
$cdmaterials "NF\Buildings\"
$cdmaterials "Common\Glass\"
$cdmaterials "\common\props"
$cdmaterials "NF\Props\"
$cdmaterials "NF\Buildings\Radar\"
$cdmaterials "\"
$cdmaterials "\metal"
//hitbox
$hboxset "default"
$hbox 0 "static_prop" -351.416  -352.793  -140.800  379.501  351.355  405.290
//attached entities
$attachment "build" "static_prop" 0.00 0.00 0.00 rotate 0.00 90.00 0.00
$attachment "smoke_damage_1" "static_prop" -176.00 -38.50 198.00 rotate 0.00 90.00 0.00
$attachment "smoke_damage_2" "static_prop" -0.00 299.20 132.00 rotate 0.00 90.00 0.00
$attachment "smoke_damage_3" "static_prop" 19.80 -88.00 330.00 rotate 0.00 90.00 0.00
$surfaceprop "default"
$illumposition 14.043 -0.719 132.245
//animation sequence
$sequence idle "idle" fps 1.00
$collisionmodel "phymodel.smd" {
$concave
$mass 180.0
$inertia 1.00
$damping 0.00
$rotdamping 0.00
}
//scale the model by this factor
$scale 1.0


explanation of Empires.qc

$modelname is the path and name of your model as mdl. The model nf_radar.mdl will be placed in .\Steam\steamapps\SourceMods\Empires\nf\buildings\radar\nf_radar.mdl after compiling.

$cdmaterials is the path to your materials (VTF 's) in the .\materials folder. If you use more than 1 folder, you can use the '$cdmaterials' command again to set the remaining folders (this includes subfolders).

$scale Scales your model by this factor.

$body main-smd

$sequence smd with animation

$staticprop for prop_static, Be careful, models compiled with $staticprop don't cast shadows !

$collisionmodel smd file with a collisionmodel

List of all QC-Commands

Before you compile

Check following points:

  • Collisionmodel: Overlapping submodels will be seens as one, which may result in an ugly physics collision model.
  • Textures: Create your model and texture all faces. Faces without a proper texture mapping will be ignored while compiling and won't occur in game. If you don't care about texturing, apply any name, HL2 wont find the texture and will apply the deafult purple-black chess texture. Finally save your model as SMD-file.

What your SMD-file should look like:

texturename1
0 101.417053 -13.837116 6.270448 -0.673222 0.446155 0.589677 0.000000 1.000000 0
0 106.823196 -11.187776 6.270448 -0.161431 0.795829 0.583607 0.000000 0.000000 0
0 101.342369 -13.836076 2.145702 -0.652646 0.757568 0.012008 1.000000 0.000000 0
texturename2
0 106.823196 -11.187776 6.270448 -0.161431 0.795829 0.583607 0.000000 1.000000 0
0 106.748520 -11.186735 2.145702 0.074252 0.997239 -0.001093 0.000000 0.000000 0
0 101.342369 -13.836076 2.145702 -0.652646 0.757568 0.012008 1.000000 0.000000 0


What your SMD-file look like if your faces have no texture:

0 101.417053 -13.837116 6.270448 -0.673222 0.446155 0.589677 0.000000 1.000000 0
0 106.823196 -11.187776 6.270448 -0.161431 0.795829 0.583607 0.000000 0.000000 0
0 101.342369 -13.836076 2.145702 -0.652646 0.757568 0.012008 1.000000 0.000000 0

0 106.823196 -11.187776 6.270448 -0.161431 0.795829 0.583607 0.000000 1.000000 0
0 106.748520 -11.186735 2.145702 0.074252 0.997239 -0.001093 0.000000 0.000000 0
0 101.342369 -13.836076 2.145702 -0.652646 0.757568 0.012008 1.000000 0.000000 0
  • Convert all textures to the vtf format, create the appropriate vmt file with VertexLitGeneric shaders (see ontop) and place all files in the folder specified in the QC file.
  • Make sure your modeleditor created a valid SMD file. I had some difficulties with XSI Demo, which saves only 2 different textures and 'forgets' all other. Also Blender SMD-plugins didn't work. I found Milkshape is the best solution for me, never had broken SMDs yet.
  • Your model needs at least one (empty) animation, thats called "idle".
  • Your model needs at least one bonejoint, more if you want to use animations.


Compile your model

Start Steam and make sure Empires isn't running.

Execute your created shortcut to studiomdl. studiomdl will read the Empires.qc and compile your smd-files to mdl format and place it in the specified folder. To see the output of studiomdl.exe open the command shell and drag&drop the shotcut to it.


Blender specific SMD export plugin sample setting


Links