Team Fortress Wiki:3D Models
The 3D Models project's goal is to construct pseudo-3D images of the weapons in Team Fortress 2 that can be freely rotated.
Contents
Example
Note This is not for the faint of heart. It requires a bit of knowledge on how both VMTs and HLMV work, and a lot of time and patience since a lot of models will not be centered correctly by default, thus requiring plenty of tweaking to get them ready for the process.
Requirements
- Python 2.6 (32-bit version) (python-2.6.6.msi)
- SendKeys (SendKeys-0.3.win32-py2.6.exe)
- Python Imaging Library (PIL) (PIL-1.1.7.win32-py2.6.exe)
- pywin32 (pywin32-216.win32-py2.6.exe)
- NumPy (numpy-1.6.1-win32-superpack-python2.6.exe)
- cython (Cython-0.15.1.win32-py2.6.exe)
- Modified SendKeys.py
- (Optional) Psyco for speed improvements (available for 32-bit Python only)
OR
- Preinstalled image of the Python installation with all modules (STRONGLY RECOMMENDED)
Also:
- Visual C++ 2008 Express Edition with SP1 (Must be 2008, more recent versions will not work. Untick SQL server option) (vcsetup.exe)
- wikitools
- The automaton script
- The background and fire textures
- The Source SDK
- The sdktools_beta
- GCFScape
- For models that need to be recompiled: Crowbar.
Initial setup
Installation
- If manually installing Python:
- Install Python 2.6 and the required libraries (SendKeys, PIL, pywin32, NumPy and cython) and install Visual Studio Express 2008 C++ Express Edition.
- Extract the wikitools zipped file into the same directory as the script.
- Install the Source SDK from the Tools part of Steam. This is only needed for the files, not for any of the functions!
- Copy the MDL Decompiler .exe to
\Steam\steamapps\<username>\sourcesdk\bin\ep1\bin
. - Navigate to
\Python26\Lib\site-packages
and replace SendKeys.py with the modified version linked above.
- Otherwise extract the zipped Python folder somewhere.
- Download and save the automaton scripts to an easily accessible folder.
- Extract the BlackFirePlusBlackBackground.zip file, and copy the contents to
\Steam\steamapps\common\Team Fortress 2\tf\custom\
. - Set up HLMV to produce the highest quality images possible by following the guide found here.
Setting up automatebeta.py
- Open HLMV and maximize it.
- Take a screenshot and paste it into an image viewer such as paint.NET or Adobe Photoshop.
- Take note of the following pixel coordinates for your screen size.
monitorResolution
is simply a list of your screen resolution.imgCropBoundaries
is the boundary of the window the model in HLMV is contained within. The format is;- [pixel distance of left boundary from left of screen, pixel distance of top boundary from top of screen, pixel distance of right boundary from left of screen, pixel distance of bottom boundary from top of screen]
- You should leave a few pixels gap from the window edge.
fileButtonCoordinates
is a tuple of the center x,y coordinates for the File menu button in HLMV.- Close any programs that may interrupt or interfere with the process.
- You are now set to take the images.
Workflow
Taking images
- Open up a weapon model in HLMV and center the model using Options → Center View.
- If the model does not face you directly when centered, it will need to be recompiled with a new rotation.
- Zoom the model out so that it is as large as possible, but will not clip outside the viewer window when rotated or tilted.
- If the model has a fire overlay, see the Installation section on this page or the Program Limitations section on the Help: Model Viewer page on how to remove it.
- If the light source produces a glare that interferes with the model, hold Ctrl and drag the light source around with the mouse until it is in a better position.
- Open regedit, navigate to
\HKEY_CURRENT_USER\Software\Valve\hlmv
, and locate the registry key entry for the model. This will be in the form ofmodels.weapons.c_models.c_wrench.c_wrench.mdl
. - Copy and paste this key name into automatebeta.py in the model = HLMVModelRegistryKey() entry.
- Copy the
Trans
key entry for the model into automateDis as theintialTranslation
argument. (Don't forget to add the commas to separate the values) - Rotate the model by dragging near the center of the viewer.
- There will be three possible outcomes here.
- The model will rotate around the bottom corner of the model. If so, you will need to make use of
rotationOffset
.- Rotate the model so that it is facing left. Hold down ⇧ Shift and move the model sideways so that it is centered in the circle that appears.
- Press F5 in HLMV, and then in regedit. Note the new 'y' Trans value. The difference between the current value and the initial value is the
rotationOffset
value.
- The model will rotate around the wrong plane or the model will not rotate around the vertical or horizontal center. If so, the model will need to be recompiled. See the section on recompiling models.
- The model will rotate around the vertical and horizontal center of the model. If so, you are good to go.
- The model will rotate around the bottom corner of the model. If so, you will need to make use of
- Set the item name in the script for
itemName
. It is suggested you initially set this to 'User <username> <item>' so you can see the item looks fine before being moved to the correct title. - The script is started as so. From the commandline, navigate to the folder containing the scripts and type
python automatebeta.py
. - You will be asked to enter the folder name for the generated images.
- The script will now automate taking the required images. It is best not to try and use your computer while the script is running as it will likely result in an incorrect output.
- To interrupt the image taking process, turn on Num Lock.
Painted hats
Main article: Painted variants (tutorial)
Team-colored models
- Extract the VMTs for the model from the
tf2_misc_dir.vpk
appropriate folder directories in the/custom/folder
. - In the automatebeta.py script, set
teamColours
toTrue
and set the paths to the VMTs forREDVMTFile
andBLUVMTFile
.
Models with other class arms/models blocking the view
- If you wish to remove a model from the viewer (for example the Sniper's arms holding onto the view model Sniper Rifle), click on the Model tab in HLMV and find out which VMTs are being used for the model textures.
- Extract the VMTs using GCFScape to the same path in your
/custom/folder
and open them up in a text editor. - Inside the
"VertexLitGeneric"
curly brackets add the line"$no_draw" "1"
. This will make this part of the model invisible in HLMV.
Recompiling models
For convenience, check here to see if a model isn't already recompiled.
- Open the model in HLMV.
- Launch GCFScape and load
tf2_misc_dir.vpk
. - Navigate to
tf\models\weapons
and extract the relevant weapon folder to\Steam\steamapps\common\Team Fortress 2\tf\custom\folder\models\weapons
. - Launch MDL Decompiler, tick "do not fix rotations on animations", set your output directory to the same folder where the model was extracted, and extract.
- Unfortunately, you are not done. The animation sequences you have just decompiled are all horribly borked. Launch StudioCompiler, go to the Model Decompile tab, and decompile the same model (this time leaving "do not fix rotations" unticked). The decompiler will throw you an error. That is fine. Click okay and it will finish extracting. Make sure you output to the SAME directory as the previous step so that the files will be overwritten.
- Open up the outputted
mdldecompiler.qc
and change the $model line's value for the .dmx.smd file to not include a directory. i.e. changeparts/dmx/c_wrench.dmx.smd
toc_wrench.dmx.smd
. - Open up idle.smd in a text editor. You will find an entry/entries that start with time 0/1/etc. The 2nd/3rd/4th numbers in the entry correspond to back/forth, side to side, and up/down translations, respectively. The 5th/6th/7th numbers in the entry correspond to x, y, and z rotations, respectively. Correct these values for all lines (or delete the all the time lines except for the first) and save.
- Go back to StudioCompiler, go to the Model Compile tab, go to the
Compile w/Existing QC
section, select yourmdldecompiler.qc
which you just edited, and press compile. Note: If you get a compiler error about write access, it is probably because the directory that the compiler wants to output to as specified in the .qc doesn't exist. Create it. - Note: If StudioCompiler is crashing or otherwise fails to compile, you can compile manually (which is faster too). Open the command line to the directory with your "mdldecompiler.qc" and enter:
"[STEAMAPPS DIRECTORY]\common\Team Fortrees 2\bin\studiomdl" -game "[STEAMAPPS DIRECTORY]\common\Team Fortrees 2\tf" mdldecompiler.qc
- Press F5 in HLMV to refresh the model state. If the model still does not rotate in the correct plane/center of the model, change the values again and recompile. This may require a lot of trial and error.
- After successfully recentering the model, copy the recompiled .mdl, .vtx, .phy, and .vvd files into a zipped folder and upload to a file sharing site (preferably MediaFire) to post on the project page.
If you run into any trouble during this process, there is a page with extra help here which will list most likely difficulties of this process and explain them further
Uploading your image for submission
- Post a link to the image on the Talk page under a section titled after the weapon's name, along with your parameters for the script (weapon key name, initial rotation, initial translation, offsets, etc).
- Keep a copy of the individual frame images somewhere safe in case they are needed in the near future.
Tips and debugging
- If your HLMV is opening too slowly, adjust the time in the
mouse.sleep(time in seconds)
entry that follows opening HLMV. - If something interrupts the image taking process, you can continue where you left off by setting the
n
argument in the automateDis method.- You can also use this to check the images are coming out right by interrupting the script and checking the images. If the rotation looks okay, continue where you left off.
- You can also set the disableXRotation argument to
True
to just rotate the model with no tilt to see if it looks fine. - You will find it much easier when recompiling models to find out if they're centered correctly by checking the 'Ground' checkbox in HLMV and refreshing the model every time you make a change and recompile.
Models repository
Weapons
Needed weapons
Scout Weapons:
Soldier Weapons:
- Shell Shocker Rocket Launcher
- Aqua Marine Rocket Launcher
- Sand Cannon Rocket Launcher
- Woodland Warrior Rocket Launcher
Pyro Weapons:
Heavy Weapons:
Demoman Weapons:
- Stickybomb Launcher: Multiple Skins
- Sticky Jumper
- Scottish Resistance
- Liquid Asset Stickybomb Launcher
- Pink Elephant Stickybomb Launcher
- Sudden Flurry Stickybomb Launcher
- Carpet Bomber Stickybomb Launcher
Medic Weapons:
Sniper Weapons:
- Thunderbolt Sniper Rifle
- Purple Range Sniper Rifle
- Night Owl Sniper Rifle
- Low Profile SMG
- Woodsy Widowmaker SMG
- Self-Aware Beauty Mark
Spy Weapons:
Multiple Class Weapons:
- Teleport Canteen
- Lightning Rod Shotgun
- Backwoods Boomstick Shotgun
- Black Dahlia Pistol
- Sandstone Special Pistol
- Red Rock Roscoe Pistol
Finished weapons
- Air Strike
- Ali Baba's Wee Booties
- Ambassador: Multiple Skins
- Amputator
- Ap-Sap
- Apoco-Fists
- Atomizer
- AWPer Hand
- Axtinguisher: Multiple Skins
- Baby Face's Blaster
- Backburner
- Back Scatter
- Back Scratcher
- B.A.S.E. Jumper
- Bat: Multiple Skins
- Bat Outta Hell
- Battalion's Backup
- Bazaar Bargain
- Beggar's Bazooka
- Big Earner
- Big Kill
- Black Box: Multiple Skins
- Black Rose
- Blutsauger: Multiple Skins
- Bonesaw
- Bonk! Atomic Punch: Multiple Skins
- Bootlegger
- Boston Basher
- Bottle
- Brass Beast
- Bread Bite
- Buffalo Steak Sandvich
- Buff Banner: Multiple Skins
- Bushwacka
- Candy Cane
- Chargin' Targe: Multiple Skins
- Claidheamh Mòr
- Classic
- Cleaner's Carbine
- Cloak and Dagger
- Concheror
- Conniver's Kunai
- Conscientious Objector
- Cow Mangler 5000
- Cozy Camper
- Crit-a-Cola
- Crossing Guard
- Crusader's Crossbow: Multiple Skins
- Darwin's Danger Shield
- Dead Ringer
- Degreaser
- Detonator
- Diamondback
- Direct Hit
- Disciplinary Action
- Disguise Kit
- Electro Sapper: Multiple Skins
- Enforcer
- Enthusiast's Timepiece
- Equalizer
- Escape Plan
- Eureka Effect
- Eviction Notice
- Eyelander: Multiple Skins
- Family Business
- Fan O'War
- Fire Axe
- Fishcake
- Fists of Steel
- Fists
- Flame Thrower: Multiple Skins
- Flare Gun: Multiple Skins
- Flying Guillotine
- Force-A-Nature: Multiple Skins
- Fortified Compound
- Freedom Staff
- Frontier Justice: Multiple Skins
- Frying Pan
- Gloves of Running Urgently: Multiple Skins
- Golden Frying Pan
- Golden Wrench
- Grenade Launcher: Multiple Skins
- Gunboats
- Gunslinger
- Half-Zatoichi
- Ham Shank
- Hitman's Heatmaker
- Holiday Punch
- Holy Mackerel: Multiple Skins
- Homewrecker
- Horseless Headless Horsemann's Headtaker
- Huntsman: Multiple Skins
- Huo-Long Heater
- Invisibility Watch
- Iron Curtain
- Jag
- Jarate: Multiple Skins
- Killing Gloves of Boxing
- Knife: Multiple Skins
- Kritzkrieg
- Kukri
- L'Etranger
- Liberty Launcher
- Loch-n-Load
- Lollichop
- Loose Cannon
- Lugermorph
- Machina
- Mad Milk
- Manmelter
- Mantreads
- Market Gardener
- Maul
- Medi Gun: Multiple Skins
- Memory Maker
- Necro Smasher
- Neon Annihilator
- Nessie's Nine Iron
- Nostromo Napalmer
- Original
- Overdose
- Pain Train
- PDA Build/Demolish Tool
- Persian Persuader
- Phlogistinator
- Pistol
- Pomson 6000
- Postal Pummeler
- Powerjack
- Pretty Boy's Pocket Pistol
- Quackenbirdt
- Quick-Fix
- Rainblower
- Razorback
- Red-Tape Recorder
- Rescue Ranger
- Reserve Shooter
- Revolver: Multiple Skins
- Righteous Bison
- Robo-Sandvich
- Rocket Jumper
- Rocket Launcher: Multiple Skins
- Sandman
- Sandvich: Multiple Skins
- Sapper
- Saxxy
- Scattergun: Multiple Skins
- Scorch Shot
- Scotsman's Skullcutter
- Scottish Handshake
- Shahanshah
- Sharp Dresser
- Sharpened Volcano Fragment
- Short Circuit
- Shortstop
- Shotgun: Multiple Skins
- Shovel
- SMG: Multiple Skins
- Snack Attack
- Sniper Rifle: Multiple Skins
- Soda Popper
- Solemn Vow
- Southern Hospitality
- Splendid Screen
- Spy-cicle
- Sun-on-a-Stick
- Sydney Sleeper
- Syringe Gun
- Third Degree
- Three-Rune Blade
- Tomislav: Multiple Skins
- Tide Turner
- Toolbox
- Tribalman's Shiv
- Übersaw: Multiple Skins
- Ullapool Caber
- Unarmed Combat
- Vaccinator
- Vita-Saw
- Wanga Prick
- Warrior's Spirit
- Widowmaker
- Winger
- Wrangler: Multiple Skins
- Wrap Assassin
- Wrench: Multiple Skins
- Your Eternal Reward