Created
October 11, 2018 18:19
-
-
Save DubThink/44c6e8a5e34a3afeaa9ccec7c9f5bbf3 to your computer and use it in GitHub Desktop.
A python script for taking screenshots in hlmv to make thumbnails from. Replaces solutions with tfmv, which is broken
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import winreg as wr | |
import os | |
''' | |
Sets settings in hlmv using the registry to automate taking uniform screenshots for item thumbnails. | |
Tested with python 3.2 and 3.5 | |
USE AT YOUR OWN RISK. This script should be pretty safe, but it is modifying the registry, so be careful. | |
CONFIGURATION: | |
Set up the paths to match your system. Hopefully they're relatively intuitive. | |
Setting up values: open up one of the models in hlmv, then adjust it to your liking. Once you're happy, | |
open a different model in hlmv, then close the program. Then open up the registry editor, navigate to the | |
Software\\Valve\\hlmv\\<item.path.here> entry, and copy the corresponding values into the main loop of | |
the script. | |
The values can also be adjusted manually if you wish. | |
USAGE: | |
1. Open each of the models in hlmv once, then open one again. (The initial registry entry is created when | |
a file is closed, so each file should be closed once) | |
2. Close hlmv. | |
3. Run the script. It will open each model listed in @var models in order twice: once with a black | |
background, once with white. Take screenshots using your favorite tool. I use shareX. After each screenshot, | |
close hlmv, and the script will open up the next. Don't close the terminal window that opens- close hlmv | |
itself. | |
4. Use photoshop or something to edit the images. I use photoshop layers to find the pixels that are different | |
between the black image and the white image, and remove those. | |
ADVICE: | |
I highly recommend setting your monitor to portrait mode so you can take the biggest screenshots possible. | |
This does depend on the shape of your model. | |
Photoshop macros(actions) are the best thing this world has created. | |
Copyright (c) 2018 DubThink. All rights reserved. | |
truedubthink@gmail.com | |
This work is licensed under the terms of the MIT license. | |
For a copy, see <https://opensource.org/licenses/MIT> | |
''' | |
reg=wr.ConnectRegistry(None,wr.HKEY_CURRENT_USER) | |
# path to the model in registry form (dots instead of slashes) | |
model_rpath="models.workshop.player.items.all_class" | |
# List your model names here, minus the _<class>.mdl | |
models=["rgb3_participant2","rgb3_silver2","rgb3_bronze2","rgb3_gold2"] | |
# I use the scout model for screenshots | |
mdl_suffix="_scout.mdl" | |
# the path hlmv uses in the registry | |
hlmv_rpath="Software\\Valve\\hlmv\\D..SteamLibrary.steamapps.common.Team Fortress 2.tf" | |
# the path to the folder with your items | |
tf_path="D:\\SteamLibrary\\steamapps\\common\\Team Fortress 2\\tf\\models\\workshop\\player\\items\\all_class\\" | |
# the path to hlmv | |
hlmv_path="D:\\SteamLibrary\\steamapps\\common\\Team Fortress 2\\bin\\" | |
os.chdir(hlmv_path) | |
# Runs a system command after printing it | |
def prun(cmd): | |
print(cmd) | |
os.system(cmd) | |
for color in ['(0.000000 0.000000 0.000000 0.000000)','(1.000000 1.000000 1.000000 0.000000)']: | |
for version in models: | |
rpath=hlmv_rpath+"."+model_rpath+"."+version+"."+version+mdl_suffix | |
print("Editing registry @",rpath) | |
key=wr.OpenKey(reg,rpath,access=wr.KEY_WRITE) | |
wr.SetValueEx(key,'bgColor',0,wr.REG_SZ,color) | |
# light color. I mostly adjust it to change the intensity | |
wr.SetValueEx(key,'lColor',0,wr.REG_SZ,'(0.486275 0.486275 0.486275 0.000000)') | |
# light direction/rotation (controlled in hlmv by ctrl+lmouse) | |
wr.SetValueEx(key,'lightrot',0,wr.REG_SZ,'(26.542059 151.765823 68.832710)') | |
# rotation of model | |
wr.SetValueEx(key,'Rot',0,wr.REG_SZ,'(86.891808 169.085938 179.002350)') | |
# translation(location) of model | |
wr.SetValueEx(key,'Trans',0,wr.REG_SZ,'(4.498322 0.000000 -2.056069)') | |
wr.FlushKey(key) | |
wr.CloseKey(key) | |
#hangs until window closed | |
prun('.\hlmv.exe "{mdl}"'.format(mdl=(tf_path+version+'\\'+version+mdl_suffix))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment