Difference between revisions of "User:Fiskie/AutoHLMV"

From Team Fortress Wiki
Jump to: navigation, search
(Created page with "'''AutoHLMV''' is my C++ tool for automation of screenshots of painted models inside HLMV into Photoshop, where they can simply be trimmed, given alpha and exported using the Scr...")
 
 
(14 intermediate revisions by the same user not shown)
Line 1: Line 1:
'''AutoHLMV''' is my C++ tool for automation of screenshots of painted models inside HLMV into Photoshop, where they can simply be trimmed, given alpha and exported using the Scripts -> Export Layers as Files tool.
+
{{DISPLAYTITLE:AutoHLMV 0.4}}
 +
'''AutoHLMV''' is a command line utility written in C++ for the automation of screenshots of painted models inside HLMV into Photoshop, where they can simply be trimmed, given alpha and exported using the Scripts -> Export Layers as Files tool.
  
 
== Current Features ==
 
== Current Features ==
 
* Automated Registry editing for values
 
* Automated Registry editing for values
 
* Automated model opening - do not have to open it beforehand
 
* Automated model opening - do not have to open it beforehand
 +
* Automated layer naming
 
* FOV Setting
 
* FOV Setting
  
 
== Requirements ==
 
== Requirements ==
* Preferably Photoshop CS5. CS4 and CS3 works, but due to the nature of C++ FindWindow it's difficult to regex with, so other versions with different window titles may not work. The current titles are supported:
+
* Source SDK
 +
* Preferably Photoshop CS5. CS4 and CS3 works, but due to the nature of C++'s FindWindow it's difficult to regex with, so other versions with different window titles may not work. The current titles are supported:
 
** Adobe Photoshop CS5 Extended
 
** Adobe Photoshop CS5 Extended
 
** Adobe Photoshop CS5.5
 
** Adobe Photoshop CS5.5
Line 14: Line 17:
 
** Adobe Photoshop CS4
 
** Adobe Photoshop CS4
 
** Adobe Photoshop CS3
 
** Adobe Photoshop CS3
 +
* Exported the hat material files using GCFscape to their matching directory in the <code>team fortress 2/tf/materials</code> folder. All these files are contained inside <code>team fortress 2 materials.gcf</code> under <code>tf/materials/player/items</code>.
 +
== Download ==
 +
[http://cbs.hopto.org/autohlmv/ Download Page]
 +
 +
== Pre-Configuration ==
 +
 +
=== autohlmv.ini ===
 +
Lines that are comments can be written using a hash (#).
 +
 +
If there is only one VMT for a model (for example, if it doesn't have team colors), leave targetTex2 blank or comment it with a #.
 +
 +
*'''targetModel''': Path to the model, starting from the <code>player</code> directory, for example: <code>player\items\spy\noblehair.mdl</code>
 +
*'''targetTex1''': Full file path to the model's default RED texture.
 +
*'''targetTex2''': Full file path to the model's default BLU texture (optional).
 +
*'''targetFov''': Desired Field of View to use inside HLMV. Bigger number = smaller model, and will often be used on monitors with a wide aspect ratio if the model is obscured by the window. Default value is 65.
 +
*'''targetRot''', '''targetTrans''', '''targetLightrot''', '''targetLcolor''': Values used for rotating and positioning the model and its lighting. Use the [[Template:Painted_variants/Tutorial/Rotations|Rotations List]].
 +
*'''targetMode''': Currently the only value for this can be '''Paint''', so leave this alone for now.
 +
*'''speed''': An amount in milliseconds the program will pause for when switching windows, in case graphical problems or strange things occur. Lower number = faster, but increase it if problems happen. 200 is a safe option.
 +
 +
==== Area Variables ====
 +
These variables are used for clicking the mouse button at certain events, and should be configured if it is clicking in the wrong place. This was configured under Windows 8 on a 1080p screen.
 +
 +
*'''modelViewerX/Y''': The button to the Model Viewer (HLMV) in relation to the Source SDK window.
 +
*'''fileLinkX/Y''': The File button on HLMV's toolbar.
 +
*'''openLinkX/Y''': The Open button on HLMV's File menu.
 +
*'''dialogInputX/Y''': The text input on HLMV's file select dialog.
 +
*'''fovInputX/Y''': The FoV input on HLMV's actions pane.
 +
 +
=== paints.ini ===
 +
Unwanted paints can be commented out with a hash (#).
 +
 +
Paints are stored here as follows, and will be used in the application's paint process:
  
== Initial Setup ==
+
<code>Paint Name, Decimal Color Values, HEX Color Values</code>
To use the script, make sure all the values in the autohlmv.ini file are correct. If there is only one VMT for a model, leave targetTex2 blank or comment it with a #.
 
  
You can comment out unwanted paints with a #, too.
+
Any Decimal Color Values that are labeled '''Stock RED''' or '''Stock BLU''' will be replaced with the base colors of the model's VMT files.
 +
 
 +
=== Photoshop ===
 +
 
 +
To let layer names work, you '''MUST''' set up a bind for this in Photoshop.
 +
 
 +
#Go to '''Edit -> Keyboard Shortcuts...''' or press '''Alt-Shift-Ctrl-K'''.
 +
#Click the '''Layer''' dropdown and set the keystroke for '''Layer (Group) Properties''' to '''F11'''.
 +
#Accept and save changes.
 +
 
 +
Now, when a layer is selected, pressing F11 will bring up the Layer Properties dialog. The script will use this to input HEX codes as layer names when it is running.
 +
 
 +
== Basic Usage ==
  
 
=== Window States ===
 
=== Window States ===
You '''must''':
+
 
 +
Before running the script, you '''must''':
 
*Have the Source SDK window open. HLMV will be opened by the script.
 
*Have the Source SDK window open. HLMV will be opened by the script.
 
*Have Photoshop open with no images open inside of it, so the script can find the application.
 
*Have Photoshop open with no images open inside of it, so the script can find the application.
  
== Download ==
+
Make sure both programs are not minimized prior to running the script.
[http://cbs.hopto.org/autohlmv/ Download Page]
+
 
 +
=== Running the script ===
 +
 
 +
'''Do not''' touch your PC while the script is running. Doing so may cause unwanted events to occur.
 +
 
 +
=== Trimming the result ===
 +
 
 +
With all the images now in Photoshop as layers, you can crop the majority of the screen to leave just the white area around the model. You can now proceed to delete this white area by selecting it with the Magic Wand tool (make sure Tolerance is set to '''1''') and repeat for each layer. Also, delete the Background layer at the bottom of the Layer list, you won't need it.
 +
 
 +
Now, go to '''Image -> Trim...''' and select any of the options, they will all do the same thing in this situation. Just make sure it is set to trim from all directions.
 +
 
 +
Finally, go to '''File -> Scripts -> Export Layers to Files''' and export somewhere desirable.
 +
 
 +
You now
 +
 
 +
== Troubleshooting ==
 +
If you are having issues, run AutoHLMV from the command line so the program won't close before you can check why it closed, so you can tell what the problem was. If you run into a crash, tell me everything on my [[User talk:Fiskie|talk page]], including a screenshot of what happened at the time (make sure the CMD window and the error dialog which occured are visible) and your INI configuration.
 +
 
 +
=== Running from CMD ===
 +
 
 +
If you have little experience with command line, pay close attention here.
 +
 
 +
#Hit '''Winkey+R''' and type '''cmd''' and press enter.
 +
#Use '''cd''' to navigate directories. Typing '''cd ..''' will move you up one level.
 +
#When you are in AutoHLMV's directory, type '''autohlmv''' and the program will run.
 +
#The window will not close after the program stops running, so you can see what the error is.
  
 
== To-do ==
 
== To-do ==
 +
=== 0.5 ===
 +
 +
*Focus windows if they are minimized
 +
*Supporting team models with a different extra base texture, e.g. [[Vintage Tyrolean]]
 +
 +
=== Later ===
 +
 
*3D feature
 
*3D feature
*Automating layer names
 
  
 
== Changelog ==
 
== Changelog ==
 +
'''Version 0.4'''
 +
 +
*Refined the aggressive stock color handling.
 +
*Now closes HLMV on finish.
 +
*A few tweaks to the sleep instances.
 +
*Compiled as a Release from now on.
 +
*Now properly backs up VMT files to prevent files becoming improperly stored if the program is terminated prematurely.
 +
 +
'''Version 0.3'''
 +
 +
*Added automation of layer names. '''Make sure you set this up as described.'''
 +
*Removed some useless INI variables. Will now create a regkey automatically from the model filename.
 +
*Some behind-the-scenes cleaning up.
 +
 
'''Version 0.2'''
 
'''Version 0.2'''
  
Line 44: Line 136:
 
== Bugs ==
 
== Bugs ==
 
* 3D mode has not been implemented, don't try this.
 
* 3D mode has not been implemented, don't try this.
* If you terminate AutoHLMV before it finishes, you will have to clear the $color2 variable from the VMT as it won't remove itself.
+
* May incorrectly paint if stocks are missing.

Latest revision as of 17:11, 19 March 2012

AutoHLMV is a command line utility written in C++ for the automation of screenshots of painted models inside HLMV into Photoshop, where they can simply be trimmed, given alpha and exported using the Scripts -> Export Layers as Files tool.

Current Features

  • Automated Registry editing for values
  • Automated model opening - do not have to open it beforehand
  • Automated layer naming
  • FOV Setting

Requirements

  • Source SDK
  • Preferably Photoshop CS5. CS4 and CS3 works, but due to the nature of C++'s FindWindow it's difficult to regex with, so other versions with different window titles may not work. The current titles are supported:
    • Adobe Photoshop CS5 Extended
    • Adobe Photoshop CS5.5
    • Adobe Photoshop CS5
    • Adobe Photoshop CS4 Extended
    • Adobe Photoshop CS4
    • Adobe Photoshop CS3
  • Exported the hat material files using GCFscape to their matching directory in the team fortress 2/tf/materials folder. All these files are contained inside team fortress 2 materials.gcf under tf/materials/player/items.

Download

Download Page

Pre-Configuration

autohlmv.ini

Lines that are comments can be written using a hash (#).

If there is only one VMT for a model (for example, if it doesn't have team colors), leave targetTex2 blank or comment it with a #.

  • targetModel: Path to the model, starting from the player directory, for example: player\items\spy\noblehair.mdl
  • targetTex1: Full file path to the model's default RED texture.
  • targetTex2: Full file path to the model's default BLU texture (optional).
  • targetFov: Desired Field of View to use inside HLMV. Bigger number = smaller model, and will often be used on monitors with a wide aspect ratio if the model is obscured by the window. Default value is 65.
  • targetRot, targetTrans, targetLightrot, targetLcolor: Values used for rotating and positioning the model and its lighting. Use the Rotations List.
  • targetMode: Currently the only value for this can be Paint, so leave this alone for now.
  • speed: An amount in milliseconds the program will pause for when switching windows, in case graphical problems or strange things occur. Lower number = faster, but increase it if problems happen. 200 is a safe option.

Area Variables

These variables are used for clicking the mouse button at certain events, and should be configured if it is clicking in the wrong place. This was configured under Windows 8 on a 1080p screen.

  • modelViewerX/Y: The button to the Model Viewer (HLMV) in relation to the Source SDK window.
  • fileLinkX/Y: The File button on HLMV's toolbar.
  • openLinkX/Y: The Open button on HLMV's File menu.
  • dialogInputX/Y: The text input on HLMV's file select dialog.
  • fovInputX/Y: The FoV input on HLMV's actions pane.

paints.ini

Unwanted paints can be commented out with a hash (#).

Paints are stored here as follows, and will be used in the application's paint process:

Paint Name, Decimal Color Values, HEX Color Values

Any Decimal Color Values that are labeled Stock RED or Stock BLU will be replaced with the base colors of the model's VMT files.

Photoshop

To let layer names work, you MUST set up a bind for this in Photoshop.

  1. Go to Edit -> Keyboard Shortcuts... or press Alt-Shift-Ctrl-K.
  2. Click the Layer dropdown and set the keystroke for Layer (Group) Properties to F11.
  3. Accept and save changes.

Now, when a layer is selected, pressing F11 will bring up the Layer Properties dialog. The script will use this to input HEX codes as layer names when it is running.

Basic Usage

Window States

Before running the script, you must:

  • Have the Source SDK window open. HLMV will be opened by the script.
  • Have Photoshop open with no images open inside of it, so the script can find the application.

Make sure both programs are not minimized prior to running the script.

Running the script

Do not touch your PC while the script is running. Doing so may cause unwanted events to occur.

Trimming the result

With all the images now in Photoshop as layers, you can crop the majority of the screen to leave just the white area around the model. You can now proceed to delete this white area by selecting it with the Magic Wand tool (make sure Tolerance is set to 1) and repeat for each layer. Also, delete the Background layer at the bottom of the Layer list, you won't need it.

Now, go to Image -> Trim... and select any of the options, they will all do the same thing in this situation. Just make sure it is set to trim from all directions.

Finally, go to File -> Scripts -> Export Layers to Files and export somewhere desirable.

You now

Troubleshooting

If you are having issues, run AutoHLMV from the command line so the program won't close before you can check why it closed, so you can tell what the problem was. If you run into a crash, tell me everything on my talk page, including a screenshot of what happened at the time (make sure the CMD window and the error dialog which occured are visible) and your INI configuration.

Running from CMD

If you have little experience with command line, pay close attention here.

  1. Hit Winkey+R and type cmd and press enter.
  2. Use cd to navigate directories. Typing cd .. will move you up one level.
  3. When you are in AutoHLMV's directory, type autohlmv and the program will run.
  4. The window will not close after the program stops running, so you can see what the error is.

To-do

0.5

  • Focus windows if they are minimized
  • Supporting team models with a different extra base texture, e.g. Vintage Tyrolean

Later

  • 3D feature

Changelog

Version 0.4

  • Refined the aggressive stock color handling.
  • Now closes HLMV on finish.
  • A few tweaks to the sleep instances.
  • Compiled as a Release from now on.
  • Now properly backs up VMT files to prevent files becoming improperly stored if the program is terminated prematurely.

Version 0.3

  • Added automation of layer names. Make sure you set this up as described.
  • Removed some useless INI variables. Will now create a regkey automatically from the model filename.
  • Some behind-the-scenes cleaning up.

Version 0.2

  • Added a "speed" setting to the INI.
  • Should not be taking screenshots in the wrong places anymore.

Version 0.1

  • Initial release.

Bugs

  • 3D mode has not been implemented, don't try this.
  • May incorrectly paint if stocks are missing.