Trainz/AM&C/PEVtools

< Trainz‎ | AM&C
logo
Trainz Asset Maintenance and Creation
TOC | BeginningsFun | AM&C | Creation | InBook Refs ORP Refs:  • Index • Containers • Kinds • Tags | Appendixes  • Vers
 Glossary
 HKeys-CM
 HKeys-DVR
 HKeys-SUR
 HKeys-WIN
 Mouse use
 Notations

PEVtools and Fixing Assets edit

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—TS2012 thru TRS19. These install under the manufacturer 'PEVSoft', and are quite safe—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 PEV's Trainz Tools giving some bare bones how-to in using these as well as download links, and more information on ShaneTurner's resource site, which also offers tutorials and other utilities of interest to Trainz users.
  • Four PEVtools are essential to repair and update older assets:
  1. Images2TGA,
  2. PM2IM,
  3. QuickShadows, and especially
  4. 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—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—normally by the same author— it is best to open the group using CTRL+E 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 edit

 
PEVs tools in a power-users C:\Downloads folder (Yours will likely be somewhere else).

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 his help site here.

  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.)
    1. 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.)
    2. 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).
    3. 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.)
  4. 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...
    1. Right Click-Hold (RMBHd) 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.
    1. 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.
    2. 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— 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.
    3. 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 edit

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 edit

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 edit

A program to uncompress N3V's filename.texture files as they are internally packed and stored during the processing by Content Manager when committing the asset. This exposes the various raw image files and makes them and their 'texture.txt files 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 dxt compressed textures and allows conversion of these images to other formats. The trawl feature can be used to convert textures to TGAs.

  • This program supersedes the two older generation of PEVtools Texture Viewer 2.exe and Texture2TGA.exe. The last release of this tool was in 2010, and can be downloaded here, along with a PDF file tutorial.
  • In updating and repairing over 2800 different (archive copied) faulty assets, the author had found need for exactly two texture related problems where Texture2TGA did a task not handled by Images2TGA.exe.

 

PM2IM edit

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 RMBHd drop down menu.  

Trainz Mesh Viewer 2 edit

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.
  • CTRL+arrow keys allow the asset's origin to be offset so one can zoom in on a particular area of interest. SHFT+arrow keys 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 bogeys container, 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 trainz-build 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.

 

Editor's note: If you're going to patch up a V1.3 to V1.5 asset so it works with validation and commitment with TS09 and up, the changes needed are generally to add a mesh-table container, thumbnails container, and for traincars, add a bogeys container. Excepting the thumbnails, that's the cookbook for a V2.0 asset, the thumbnails added in V2.5, TRS2006-SP0, so may as well upgrade the trainz-build! The asset certainly won't work anymore in Trainz 1.3!

 

  • 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 edit

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[note 1] 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.

Editor's note: Smart betting money says the programmer's will still be generating a fault message when a traincar lacks a shadow mesh even for TANE.

  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 asset-filename 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 edit

How to associate, for example one of several paint, photo processing, displaying or graphics creation programs might all or most such be associated with BMP, JPG, PNG, and TGA files so the best application can be used as quickly as possible when needed to manipulate said file--Windows normally defaults the first three with it's Photo and Fax Viewer which can't show TARGA formatted files.
  • 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 edit

@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 edit

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%