Trainz/AM&C/PEVtools

PEVtools and Fixing Assets
Long time Trainz user and retired electrical engineer PEV (Peter Villaume) has written some tools for fixing content, applicable to several Trainz generations, useful for maintenance and modification of assets in running TS2009&mdash;TS2012 thru TRS19. These install under the manufacturer 'PEVSoft', and are quite safe&mdash;since as a private individual PEV isn't going to pay an annual certification fee, just ignore warnings by Windows or other security software. Since they operate on Trainz data-primitives (Meshes and texture files), there actually is no Trainz release where they are inapplicable, with a little basic knowledge of how to adapt Windows to work with them. Some, like TrainCar Viewer2.exe will baulk, if an asset antedates TS2009 (actually TBV's less than 2.9); Both TRS2006 and TANE, are known to clear out and delete local batch files installed in it's respective ..\editing folder if there is an software update or database rebuild (by command request). Rewriting the batch utilities for a slightly different folder launch point (or to just be an archive from which to re-copy the deleted ones back where you want them) is all that is needed to keep the toolbox in play!
 * There is a N3V Wiki page at giving some bare bones how-to in using these as well as download links, and more information on, which also offers tutorials and other utilities of interest to Trainz users.
 * Four PEVtools are essential to repair and update older assets:
 * Images2TGA,
 * PM2IM,
 * QuickShadows, and especially
 * Mesh Viewer2.


 * The first and last are the only thing needed and used in updating or repairing 99.9% of asset issues encountered in newly acquired content software when Content Manager complains. TS09&mdash;T12 incorporated an 'Open With' external App launcher through which one normally opened any asset to repair with Images2TGA.bat. If the error message complained of an outdated PM mesh, one used PM2IM.bat or a combo batch utility pm2IM+IMGS2TGA.bat, to do both at once.
 * If, as frequently happens, you encounter a group of assets with the same faults&mdash;normally by the same author&mdash; it is best to open the group using then run the utility batch file on the whole editing folder at once.  PEVtools have a Trawl feature that will process a whole directory and all of its subfolders.

Acquiring and Installing PEVs tools
PEV's tools will be maintained by the community on one website or another as they are invaluable. Peter V. is a real programmer situated on the opposite (or Sydney) side of Australia from N3V/Auran's small town location on the Gold Coast near Brisbane, but ceased hosting his tools on his own website in mid-2013 when the task was taken over by Trainz fan Shane Turner on.


 * 1) Locate PEVs tools on Shane's site and their accompanying manuals where these are given.
 * 2) Download the tools (zip files), and quit out of any Trainz versions you may be running.
 * 3) Do not install PEVtools until you have installed all versions of Trainz you intend to run. (The PEVtools installers will need to know where those Trainz sub-directories are located, and they must be present first.)
 * 4) As always when quitting Trainz, Hit [CTRL][SHFT][ESC] to bring up file manager to watch until the TADdaemon module exits before doing anything else. (This is much faster after TS12-SP1+hf3, but an ongoing problem in earlier installations such as TS2009 and TS2010.)
 * 5) Once the TADdaemon closes it is safe to reboot or otherwise mess with Trainz directories (backup the folder, duplicate the local folder, or other maintenance such as adding PEVtools).
 * 6) Set a system Restore point, label it as Pre-PEVtools installation then reboot. (This ensures all of Trainz is off, and the cache is free.)
 * 7) Open your downloads folder, in VISTA and newer Windows versions in succession. Many of us maintain a Trainz tools directory, in which case, drag the installers into that folder. Then...
 * 8) Right Click-Hold  to Launch,(RUN AS ADMINISTRATOR dropdown) each of PEVs tools in succession.


 * 1) Once your tools are initialized in each of the TRAINZ versions you have installed, you will see under'' 'the Version-path root folder' '..\bin' sub-directory the pathspec ..\bin\CMPData\tools\OpenWith which will now contain PEVtools batch files that were installed in each initialized version of Trainz.
 * 2) This means if you run several versions of Trainz releases (with several SPs and hotix combos like some of us), to install PEV tools in each, you must copy the batch files to the off-version and hand-edit the pathspecs within for that installation.
 * 3) The same batch files can sometimes be used more fully and conveniently outside Trainz CM by copying these launchers into the local '..\UserData\editing' folder&mdash; again with a little hand editting needed for the subdirectory path. In this location one can open the asset for editing, 'then drag and drop' the assets folder onto the PEVsoft tool batch file icon.
 * 4) Even better the clever Trainzer can edit said batch files and create a composite file that enables a single drag and drop to run all the tools. This  'All-in-order' batch file can also be placed into the ...\tools folder in the \bin directory.

Tutorials for PEV's Tools
John King's Trainz Resources NewsLetter published a series of tutorials on PEV's Trainz Tools. They covered:

Images2TGA for manipulating all image types used in Trainz

PM2IM for conversions of Progressive Meshes to Indexed Meshes

QuickShadows for creating simple shadows where needed

AttachmentMaker add attachments to assets in minutes

Reprints of these are available from Shane's downloads page.

Attachment Maker
A program to add attachment points to existing assets by creating an invisible mesh with those points. Very simple and quick to use; add attachments in minutes.

Images2TGA
A program to uncompress N3V's  files as they are internally packed and stored during the processing by Content Manager when. This exposes the various raw image files and makes them and their 's available to manipulation and adjustments. Images2TGA enables unpacking and viewing of all image types used in Trainz through TS2012. TANE and TRS19 have expanded the list of allowable texture source files, and the utility probably won't work with .PGA files. The TGA on the title is merely a reflection of those being the original preferred image format for texture files.

The program can also convert any image to another format, as well as add and manipulate alpha images. You can attach your favorite image editor to allow opening of images for edit from within Images2TGA. The program handles the latest compressed textures and allows conversion of these images to other formats. The trawl feature can be used to convert textures to TGAs.

PM2IM

 * A tool program to convert the really outdated Auran progressive meshes (PM) to indexed meshes (IM). An option is provided to alter specular values that can cause unwanted shine on object surfaces.


 * This program can also be used to remove unsupported (texture stripping) texture types from IM meshes, when run in direct mode, so install a launcher shortcut in your editing folder or associate the im file type with the tool as in the below Tip and Trick.

Note: many texture faults can be fixed by re-extracting the .im file with PEV's PM2IM program, use it standalone from inside Windows (Open to point it to the asset folder) or can be put in a batch in ..\editing or launched (first) from inside CM's drop down menu.

Trainz Mesh Viewer 2
This program is able to display complete traincars and textured meshes, allowing viewing of the partial or total asset.
 * Current version is 2.25, released on the 18th November 2013.
 * It allows one to take usable screenshots of the assembly, examine attachment points, get poly counts of the meshes, see those in several modes including wireframe and with or without axis scaled in meters or feet and inches.
 * Such modes all allow rotation, zooming and tilting so an aspect of the asset can be examined in detail with a bit of practice.
 * allow the asset's origin to be offset so one can zoom in on a particular area of interest. allow one to shift the centering so zooming is on target and relevant when the asset is large and the beginning reference co-ordinate axis is off center. (Both manipulation types could use improvement, but with a little patience and enough keystrokes they tell one what one needs to know to patch or decide what else needs be done.
 * Bump mapped meshes can be viewed.
 * attachments can be viewed separately, as can Traincar parts such as bogeys, horns, and other components with separate meshes. All can be oriented then imaged to create necessary thumbnails for Trainz asset repairs.
 * Completed traincars are displayed on length of track and a simple textured groundplane. The backdrop coloring can be customized for examination or screenshots. This alteration is particularly helpful for some screenshot needs.
 * Note: Bogeys on some traincars using a single bogey type may not display properly with one legal configuration of the, but do for the alternative (simple version). When you see a single wheel centered in a two wheel bogey, you'll be observing this first hand.


 * The tool can be used with older assets (v1.3-v2.4) after converting PM2IM, if one merely temporarily changes the code value to v2.5 or above, then saves (and uses the tool to view and snoop... before reverting the change, or not!
 * The texture view feature allows one to eliminate faults caused by inclusion of an extra texture file, somewhat common in older assets, where an unused texture.txt (with or without the matching .tga file) is in a asset folder, but not used by the mesh file at all.


 * And best of all, the texture view feature allows one to ascertain where and how a missing texture's (by name or filename) is mapped, so one can generate or find a replacement from other assets.

QuickShadows
PEV has also written a tool for creating asset shadow meshes and with embedded texture fixes (updates of older assets), called QuickShadows for Traincars, bridges, and the few other asset types which require such from TRS2004 when the feature began for such assets through TS12. Quickshadows will take any Trainz mesh and create a shadow mesh based on the input it gets fed. TANE make's dynamic shadows for everything, supposedly so at this writing we infer adding such to assets will be more for the sake of completing compatibility with older versions than of actual necessity. Quickshadows has several modes for making traincar shadow meshes, which should be experimented with to find a proper minimal polygon shadow for the asset. Clicking the Low Poly shadows option should resorted to only for a complex traincar, such as locomotives. For most rolling stock and buildings, the simple shadow click box settings do fine.
 * PEV's installing software will add the '-close' switch to the commandline inside the batch file unless the Mesh Viewer2 or other Mesh Viewer is found during initialization of quickshadows, so that ought to be initialized first.
 * However, the ini file is a editable text file allowing revisiting such choices without uninstalling and reinstalling the utility. There is a binary value that can be set to zero, 'CloseOnDone=0' that will allow launching quickshadows from the Run dialog, the exe folder, or a suitable batch file allowing revisiting the settings menus should the program insist on shutting itself down.
 * Like most of PEV's utilities, Peter has included a Windows Help file ('quickshadows.chm') in the quickshadows folder with term search capability detailing how to use the program.
 * In the historic UTC data model structures which introduced them, the shadow mesh was normally was placed in a subfolder named by combining the  tag value with '_shadow'. PEV's tool will create the shadow mesh in the same folder where it trawls for mesh files, which is determined by the batch file when not directly invoked.

Adding association options

 * Like any executable under Windows, one can associate a file type with one or a list of files that might then thereafter optionally open that sort of file extension. The steps for this when you want right clicking a data file type to give you a choice is straightforward for a single application, but repetitive for several like the graphics/paint programs mentioned above.

@echo on REM File: ..\UserData\editing\$$_All-but-viewer.bat "F:\PEVSoft\Images2TGA\Images2TGA.exe" -trawl -close -fixcolour %1% "F:\PEVSoft\pm2im\PM2IM.exe" -trawl -close %1% "F:\PEVSoft\quickshadows\QuickShadows.exe" -trawl -close %1% "F:\Progs\fnr.exe" --cl --dir %1% --fileMask "*.txt" --excludeFileMask "*.dll, *.exe"  --includeSubDirectories --find ".pm" --replace ".im"
 * On $$_All-but-viewer.bat For PM2IM post-processing, the only hiccup I've seen fixing hundreds of assets is that it generates a errorcode (as good software does) when it doesn't find a .PM extension to change. This also manifests in when the batch is run from inside CM. (I have a local copy (down under ..\bin) with PEVs other tools, as I do for it's Traincar partner. It beats running each in succession.

$$_All-In-Sequence.bat
@echo off REM File: ..\UserData\editing\$$_All-In-Sequence.bat "F:\Progs\PEVSoft\Images2TGA\Images2TGA.exe" -trawl -close -fixcolour %1% "F:\Progs\PEVSoft\pm2im\PM2IM.exe" -trawl -close %1% "F:\Progs\PEVSoft\quickshadows\QuickShadows.exe" -trawl -close %1% "F:\Progs\fnr.exe" --cl --dir %1% --fileMask "*.txt" --excludeFileMask "*.dll, *.exe"  --includeSubDirectories --find ".pm" --replace ".im" REM pause Press any key to view mesh and finish "C:\Progs\PEVSoft\Mesh Viewer2\Mesh_Viewer.exe" -trawl -close %1%
 * On $$_All-In-Sequence.bat For PM2IM post-processing, the only hiccup I've seen fixing hundreds of assets is that it generates a errorcode (as good software does) when it doesn't find a Traincar asset. PEVs coding skills are top notch, and the call to the Mesh Viewer creates no problems when the asset is not a traincar. This, IIRC, also manifests an errorcode return value to CM when the batch is run from inside CM. This and the above utility will report via a standard Task Complete API Window in CM, with only a note that the error code was returned. (I have a local copy of this (down under ..\bin) with PEVs other tools, as I do for it's Traincar partner. It beats running each in succession one by one by drag and drop.

Alternative local PM2IM.bat
If you want to see what is happening despite fast modern computer executions, you can trick out a batch file with some status messages and 'wait-for-keypress' delays such as this file incorporates: @echo off REM File: F:\TS12\UserData\editing\$$_PM2IM.bat "F:\PEVSoft\pm2im\PM2IM.exe" -trawl -close %1% echo PM2IM done, ready to patch file extensions (*.pm to *.im) pause echo patching file extensions (*.pm to *.im) "F:\Progs\fnr.exe" --cl --dir %1% --fileMask "*.txt" --excludeFileMask "*.dll, *.exe"  --includeSubDirectories --find ".pm" --replace ".im" Note the presence of FNR.exe in the above, and a different root directory for PEVtools on 'that' computer install.


 * Compare that with the PEV installed file: (with added full pathspec REM line as a ID-header.)

@echo off REM File: F:\TS12\bin\CMPData\tools\OpenWith\PM2IM.bat "F:\PEVSoft\pm2im\PM2IM.exe" -trawl -close %1%