Difference between revisions of "Team Fortress Wiki:3D Models"

From Team Fortress Wiki
Jump to: navigation, search
m (The *right* way to escape this tag.)
m (Most of this is gone, which is good -- it means it's easier to use the script now.)
Line 15: Line 15:
 
*[https://pypi.python.org/pypi/pip pip Package installer]
 
*[https://pypi.python.org/pypi/pip pip Package installer]
 
**<code>pip install pillow</code> - Python Imaging Library aka PIL
 
**<code>pip install pillow</code> - Python Imaging Library aka PIL
**<code>pip install SendKeys</code> - SendKeys for changing the background
 
 
**<code>pip install pypiwin32</code> - PyWin for mouse clicks and window manipulation
 
**<code>pip install pypiwin32</code> - PyWin for mouse clicks and window manipulation
 
**<code>pip install numpy</code> - NumPy for image cropping
 
**<code>pip install numpy</code> - NumPy for image cropping
Line 26: Line 25:
 
=== Installation ===
 
=== Installation ===
 
* Install Python, Pip, and Visual C++ Compiler
 
* Install Python, Pip, and Visual C++ Compiler
* Install SendKeys, pypiwin32, PIL, numpy, wikitools, and poster
+
* Install pypiwin32, PIL, numpy, wikitools, and poster
 
* Download and save the automaton scripts to an easily accessible folder.
 
* Download and save the automaton scripts to an easily accessible folder.
 
* Extract the BlackFirePlusBlackBackground.zip file, and copy the contents to <code>Steam\steamapps\common\Team Fortress 2\tf\custom\</code>
 
* Extract the BlackFirePlusBlackBackground.zip file, and copy the contents to <code>Steam\steamapps\common\Team Fortress 2\tf\custom\</code>
Line 40: Line 39:
 
*** <nowiki>[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]</nowiki>
 
*** <nowiki>[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]</nowiki>
 
*** You should leave a few pixels gap from the window edge.
 
*** You should leave a few pixels gap from the window edge.
* {{code|fileButtonCoordinates}} is a tuple of the center x,y coordinates for the File menu button in HLMV. Likely, you don't have to change this.
 
* Close any programs that may pop up or take mouse control, as they will interfere with the process.
 
  
 
== Workflow ==
 
== Workflow ==
 
=== Taking images ===
 
=== Taking images ===
* Open up a weapon model in HLMV and center the model using Options &rarr; Center View.
+
* Open up the weapon in HLMV and ensure it rotates properly. There are three possible outcomes here:
* If the model does not face you directly when centered, it will need to be [[#Recompiling models|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 light source produces a glare that interferes with the model, hold {{Key|Ctrl}} and drag the light source around with the mouse until it is in a better position.
 
* Open regedit, navigate to {{code|\HKEY_CURRENT_USER\Software\Valve\hlmv}}, and locate the registry key entry for the model. This will be in the form of {{code|models.weapons.c_models.c_wrench.c_wrench.mdl}}.
 
* Copy and paste this key name into automate.py in the HLMVModelRegistryKey().
 
* Copy the {{code|Trans}} key entry for the model as the {{code|intialTranslation}} 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 {{code|rotationOffset}}.
 
** The model will rotate around the bottom corner of the model. If so, you will need to make use of {{code|rotationOffset}}.
 
*** Rotate the model so that it is facing left. Hold down {{Key|Shift}} and move the model sideways so that it is centered in the circle that appears.
 
*** Rotate the model so that it is facing left. Hold down {{Key|Shift}} and move the model sideways so that it is centered in the circle that appears.
Line 59: Line 48:
 
** 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 [[#Recompiling models|recompiled]].
 
** 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 [[#Recompiling models|recompiled]].
 
** 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 vertical '''and''' horizontal center of the model. If so, you are good to go.
* Set the item name in the script for {{code|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.
+
* Center the model using Options &rarr; Center View.
* Now you can run the script, from the command line. Navigate to the folder containing the scripts and type <code>python automate.py</code>.
+
* If the model does not face you directly when centered, it will need to be [[#Recompiling models|recompiled]] with a new rotation.
* You will be asked to enter the folder name for the generated images.
+
* Zoom the model out so that it is as large as possible, but will not clip outside the viewer window when rotated or tilted.
* 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.
+
* If the light source produces a glare that interferes with the model, hold {{Key|Ctrl}} and drag the light source around with the mouse until it is in a better position.
** To interrupt the image taking process, turn on Num Lock.
+
* Run the script, from the command line. Navigate to the folder containing the scripts and type <code>python automate.py</code>.
 +
* After the image finishes rotating, switch back to the command line and follow the prompts to upload the file.
  
 
=== Team-colored models ===
 
=== Team-colored models ===
* Extract the VMTs for the model from the {{code|tf2_misc_dir.vpk}} appropriate folder directories in the {{code|/custom/folder}}.
+
* This is now very simple, simply change this in HLMV (Model &rarr; Skin #), then re-run the script.
* In the automate.py script, set {{code|teamColours}} to {{code|True}} and set the paths to the VMTs with {{code|REDVMTFiles}} and {{code|BLUVMTFiles}}.
 
  
 
=== Models with other class arms/models blocking the view ===
 
=== 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.
 
* 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 {{code|/custom/folder}} and open them up in a text editor.
+
* Extract the VMTs using GCFScape to the same path in your <code>/custom/folder</code> and open them up in a text editor.
* Inside the {{code|"VertexLitGeneric"}} curly brackets add the line {{code|"$no_draw" "1"}}. This will make this part of the model invisible in HLMV.
+
* Inside the <code>"VertexLitGeneric"</code> curly brackets add the line <code>"$no_draw" "1"</code>. This will make this part of the model invisible in HLMV.
  
 
=== Recompiling models ===
 
=== Recompiling models ===
Line 82: Line 71:
  
 
== Uploading your image ==
 
== Uploading your image ==
* If you've installed poster, then this should happen automatically. The name you provided for <code>itemName</code> will be the file's location.
+
* This should happen automatically. If it does not, ensure that you have poster installed via <code>pip install poster</code>.
* If not, then follow these steps:
 
** First, [[Special:Upload|upload your image]]. If you are testing out the process, use a name like "User Darkid Test 3D.jpg".
 
** Second, edit the page. Copy the contents of <code>offsetmap.txt</code> (found in the same folder as the image) into the body of the page.
 
** Third, copy the image's URL (found by right-clicking on the wiki image) and place it between &lt;nowiki&gt; &lt;/nowiki&gt; tags in the description. Then save.
 
** The preview on the image page will now allow you to rotate the image.
 
  
 
== Tips and debugging ==
 
== Tips and debugging ==
* If your HLMV is opening too slowly, adjust the time in the {{code|mouse.sleep(time in seconds)}} entry that follows opening HLMV.
+
* You can set <code>vertical_rotations = 0</code> to generate the model with no tilting, or reduce the number of rotations with <code>number_of_images</code>.
* If something interrupts the image taking process, you can continue where you left off by setting the {{code|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 {{code|verticalRotations}} argument to {{code|0}} to generate the model with no tilting.
 
 
* 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.
 
* 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.
  

Revision as of 20:22, 8 January 2017

The 3D Models project's goal is to construct pseudo-3D images of the weapons in Team Fortress 2 that can be freely rotated.

Example

https://wiki.teamfortress.com/w/images/6/6a/Detonator_RED_3D.jpg?2018072610024612838,280,233,3,0,193,111,56,152,110,115,146,109,175,194,106,266,153,106,367,147,105,472,194,84,608,155,83,762,146,80,924,194,63,1098,157,60,1295,145,57,1503,194,44,1705,161,40,1932,145,35,2173,195,29,2392,165,24,2635,147,19,2895,195,20,3123,171,14,3377,151,7,3646,196,17,3872,177,11,4122,154,4,4386,198,22,4597,182,16,4829,159,9,5073,204,37,5255,188,31,5454,164,25,5663,210,61,5803,192,56,5955,168,51,6114,214,92,6203,195,89,6298,170,86,6396,215,114,6447,196,115,6497,172,115,6545,214,98,6633,195,95,6727,170,94,6825,210,78,6965,192,71,7116,168,68,7275,204,60,7457,188,49,7656,164,45,7865,198,46,8076,182,30,8308,159,25,8552,196,35,8778,177,17,9028,154,10,9292,195,31,9520,171,11,9774,151,2,10043,194,30,10263,165,12,10506,147,0,10766,194,33,10968,161,12,11195,145,2,11436,194,42,11610,157,21,11807,145,14,12015,194,58,12151,155,42,12306,146,35,12469,194,82,12560,153,72,12661,147,69https://wiki.teamfortress.com/w/images/3/36/Detonator_BLU_3D.jpg?2018072610042612842,280,232,3,0,193,111,56,153,110,114,146,110,173,194,106,264,154,106,365,146,105,470,194,84,607,155,82,761,146,80,923,194,62,1097,158,59,1294,145,56,1502,195,43,1704,162,39,1931,145,35,2172,195,28,2392,166,23,2635,148,18,2896,195,19,3125,171,14,3379,151,7,3649,196,17,3875,177,11,4125,154,4,4389,198,22,4600,182,16,4832,159,10,5076,203,37,5258,187,32,5457,164,25,5666,209,61,5806,191,57,5957,167,52,6116,213,92,6205,194,90,6299,170,87,6397,214,114,6448,195,114,6498,171,115,6546,213,98,6635,194,95,6729,170,93,6827,209,78,6967,191,70,7118,168,68,7277,203,60,7459,187,48,7658,164,44,7867,198,45,8078,182,30,8310,159,25,8554,196,35,8780,177,17,9030,154,10,9294,195,31,9523,171,11,9777,151,1,10047,195,30,10267,166,12,10510,148,0,10771,194,33,10973,162,12,11200,145,2,11441,194,42,11615,158,22,11812,145,14,12020,194,58,12157,155,42,12311,146,36,12473,194,82,12564,154,72,12665,146,69

Pictogram comment.png 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

Initial setup

Installation

  • Install Python, Pip, and Visual C++ Compiler
  • Install pypiwin32, PIL, numpy, wikitools, and poster
  • 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.
  • Start up TF2 so that it maps your custom folders (for material overrides) and generates gameinfo.txt.

Setting up automate.py

File:3D Tutorial HLMV Coordinates.png
HLMV screen where 1 is the location of fileButtonCoordinates, 2 is the location of optionsButtonCoordinates, and 3 is the boundary for imgCropBoundaries.
  • 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.
    • 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.

Workflow

Taking images

  • Open up the weapon in HLMV and ensure it rotates properly. There are 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.
    • The model will rotate around the vertical and horizontal center of the model. If so, you are good to go.
  • 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 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.
  • Run the script, from the command line. Navigate to the folder containing the scripts and type python automate.py.
  • After the image finishes rotating, switch back to the command line and follow the prompts to upload the file.

Team-colored models

  • This is now very simple, simply change this in HLMV (Model → Skin #), then re-run the script.

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

  • First, check here to see if a model has already been recompiled.
  • Download and install Crowbar, GCFScape, and the Source SDK (Steam -> Library -> Tools)
  • Extract the model with GCFScape, decompile with Crowbar.
  • For the most part, adding $autocenter to the .qc file should do the trick. If not, try using $origin X Y Z. For more complex concerns, see Category:QC Commands on the Valve Developer Community.
  • Recompile the model with Crowbar. You should be good to go!

Uploading your image

  • This should happen automatically. If it does not, ensure that you have poster installed via pip install poster.

Tips and debugging

  • You can set vertical_rotations = 0 to generate the model with no tilting, or reduce the number of rotations with number_of_images.
  • 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:

Pyro Weapons:

Heavy Weapons:

Demoman Weapons:

Medic Weapons:

Sniper Weapons:

Spy Weapons:

Multiple Class Weapons:

Finished weapons