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

From Team Fortress Wiki
Jump to: navigation, search
m (Forgot to move this up)
m (Weapons: Gettin' to work!)
Line 142: Line 142:
 
* {{icon item|Half-Zatoichi|30px}} [[Half-Zatoichi]]
 
* {{icon item|Half-Zatoichi|30px}} [[Half-Zatoichi]]
 
* {{icon item|Holy Mackerel|30px}} [[Holy Mackerel]]
 
* {{icon item|Holy Mackerel|30px}} [[Holy Mackerel]]
* {{icon item|Kritzkrieg|30px}} [[Kritzkrieg]]
+
* {{icon item|Kritzkrieg|30px}} [[Kritzkrieg]] {{c|info}} - Reserved by [[User:Alex2539|Alex2539]]
* {{icon item|Medi Gun|30px}} [[Medi Gun]]
+
* {{icon item|Medi Gun|30px}} [[Medi Gun]] {{c|info}} - Reserved by [[User:Alex2539|Alex2539]]
 
* {{icon item|Original|30px}} [[Original]] {{c|info}} - Reserved by [[User:Moussekateer|Moussekateer]]
 
* {{icon item|Original|30px}} [[Original]] {{c|info}} - Reserved by [[User:Moussekateer|Moussekateer]]
 
* {{icon item|Powerjack|30px}} [[Powerjack]] {{c|info}} - Reserved by [[User:Moussekateer|Moussekateer]]
 
* {{icon item|Powerjack|30px}} [[Powerjack]] {{c|info}} - Reserved by [[User:Moussekateer|Moussekateer]]

Revision as of 01:49, 19 September 2011

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

Template:3D team viewer

Pictogram comment.png Note This is not for the faint of heart. It requires a bit of knowledge on how VMTs and HLMV work and a lot of time and patience as a lot of models will not be centered correctly by default, and require plenty of tweaking to get ready for the process.

Requirements

Initial setup

Installation

  • Install Python 2.6 and the required libraries (SendKeys, PIL, and pywin32).
  • 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.
  • Download and save the automaton scripts to an easily accessible folder.
  • Set up HLMV to produce the highest quality images possible by following the guide found here.

Setting up automate.py

File:3D Tutorial HLMV Coordinates.png
HLMV screen where 1 is the location of fileButtonCoordindates, 2 is the location of optionsButtonCoodinates, and 3 is the boundary for imgCropBoundaries.
  • Open up HLMV and maximise it.
  • Take a screenshot and paste it into an image viewer such as paint.NET or Photoshop.
  • Take note of the following pixel coordinates for your screen size.
    • SDKLauncherStartingPoint is a tuple of the x,y coordindates where the SDK Launcher will roughly be so the script can click on it. This can be a very rough estimate.
    • 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.
  • fileButtonCoordindates is a tuple of the center x,y coordinates for the File menu button in HLMV.
  • optionsButtonCoodinates is a tuple of the center x,y coordinates for the Options menu button in HLMV.
  • Close any programs that may interrupt or interfere with the process.
  • You're now set to take the images.

Workflow

Taking images

  • After opening the SDK Launcher, but before opening HLMV, run hlmv-tf2.bat found in the zipped file found here. This is to be done every time you open the SDK.
  • Open up a weapon model in HLMV and centre the model using 'Options -> Center View'.
  • If the model does not face you directly when centred then 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 section on dealing with team colored models 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 till 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 of models.weapons.c_models.c_wrench.c_wrench.mdl.
  • Copy and paste this key name into automate.py in the model = HLMVModelRegistryKey() entry.
  • Copy the Trans key entry for the model into automateDis as the intialTranslation argument (Don't forget to add the commas to separate the values).
  • Rotate the model by dragging near the centre 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 the shift key 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 does not rotate around the vertical or horizontal centre. If so the model will need to be recompiled. See the section on recompiling models.
    • The model will rotate around the vertical and horizontal centre of the model. If so, you're good to go.
  • Intially HLMV is open and maximixed. The script is started as so. From the commandline navigate to the folder containing the scripts and type python automate.py.
  • You will be asked to enter the folder name for the generated images.
  • You then have 3 seconds (by default) to do the following. Click on the SDK launcher and highlight the 'Model Viewer' entry. Then click on HLMV to bring it back into focus.
  • The script will now automate taking the required images. It's best not to try and use your computer while the script is running as it will likely result in an incorrect output.

Team-colored models

  • By default you will capture the images for the RED colored weapon. You will need to retake the images for the BLU variant.
  • Open up 'tf\materials\model\weapons' in GCFScape and extract the VMTs for the model into \Steam\steamapps\<username>\team fortress 2\tf\materials\models\weapons.
  • Open the VMTs in a text editor and copy over the contents of the BLU VMT into the RED VMT file and save.
    • If the model has a fire overlay then replace the value of "$detailblendfactor" with .00.
  • The model will now have BLU colored and you can repeat as before to take the images.

Models with other class arms/models blocking the view

  • If you wish to remove a model from the viewer (for example the Spy's arms holding onto the viewmodel Electro Sapper), 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 team fortress 2 folder and open them up in a text editor.
  • Inside the "VertexLitGeneric" curly brackets add the line "$no_draw" "1". This will make the model invisible in HLMV.

Recompiling models

  • Open the model in HLMV.
  • Launch GCFScape and load 'team fortress 2 materials.gcf'.
  • Navigate to tf\models\weapons and extract the relevant weapon folder to \Steam\steamapps\<username>\team fortress 2\tf\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're not done. The animation sequences you have just decompiled are all horribly borked. Launch StudioCompiler, go to the Model Decompile tab, decompile the same model (this time leaving do not fix rotations unticked). The decompiler will throw you an error, that's fine, click okay and it will finish extracting. Make sure you output to the SAME directory as the previous step so 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. change "parts/dmx/c_wrench.dmx.smd" to "c_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 your "mdldecompiler.qc" which you just edited and press compile. Note: If you get a compiler error about write access, it's probably because the directory that the compiler wants to output to as specified in the .qc doesn't exist. Create it.
  • Press F5 in HLMV to refresh the model state. If the model still does not rotate in the correct plane/centre of the model then 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.

Uploading your image for submission

  • After the script has finished it will generate a stitched image and a .txt file with the offset map.
  • Upload the image to the wiki under the name 'User <wikiusername> <weapon> <teamcolor (if applicable) 3D.jpg>' and copy and paste the offset map text into the summary box.
  • Create a page in your sandbox with 3D model viewer template (as seen here) and check that the model rotates correctly and there are no issues.
  • Post a link to the image on the talk page under a section titled after the weapon 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 then adjust the time in the mouse.sleep(time in seconds) entry that follows opening HLMV.
  • Stick the SDK launcher near the top left of your screen to speed up the step, as the script will start looking for the button there by default (this can be changed).
  • 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.

Weapon models repository

Weapons

Needed weapons

Pictogram comment.png Note Reserve the weapon you are working on by placing the line '{{c|info}} - Reserved by [[User:<username>|<username>]]' on the relevant weapon line. If you have any problems with a model please post on the talk page under a section titled after the weapon name.

Need to redo

Done weapons