Short engine modding tutorial

Creating and Editing Rollingstock
User avatar
bombardiere
Dispatcher
Posts: 425
Joined: Tue Nov 14, 2006 9:07 am
Location: Turku, Finland

Short engine modding tutorial Unread post

This is a short and quick (and rough) guide to how to create new engines. This deals only what is needed to do to make a new engine. I will not talk about unpacking or repacking PK4 or what is possible to do with the skin files.

Disclaimer! English is not my first language (actually not even second), and thus I make a lot of mistakes and sometimes even forgot words from the sentences. If this makes the document hard or confusing to read, I can only humbly request that please ask additional questions. Also I will not deal with the Hexediting issue as I hope that someone more familiar with hexedit than me could elaborate these.

NOTE! Please study Pjay’s data files, as this document expects you to be familiar with his work. Also I suggest that when you test new engines, open the game in windowed mode. This way eventual crashes are recoverable and you get an error message, which may give hints on what went wrong.

Essentially three things are needed to make a new locomotive. 1. Hexediting .lco and .car files. 2. Acquiring and renaming .3dp files 3. Skin texture and beauty shot and profile files.

1. So that the game would recognise new loco 3D and skin files, it is needed to edit .lco and .car files. (These can be find in EngineTypes subfolder) It is possible to create separate ids (names) for Engine files, 3D files and skin files, but it is not really needed and a single common id is enough. (causes less confusion) Poptop uses letter L to signify files belonging to locomotive and letter T with files associated with tender. After the final L or T letter there must be a 00 in byte form (not as a text string). This way program knows that the name ends. NOTE! Double 0 must be after all text strings, otherwise funny things happen.

For example, if one wants to make a TGV model, a good id would be TGVL, and it would be ok to name new files as TGVL.lco, TGVL.car and TGVT.car (if needed).

.lco files are easier to edit as only one string is needed to change. It is line 004 and a text string. This id is needed to be same than 3D file name (.3dp), but if you are using universal id, there will be no problems.

.car carries more information. Line 012 is the name, which appears in the game. Thus it can be longer and more complicated than the id. Line 072 is id for .lco and .car file name. Thus it must be same than the newly named .lco and .car files. Line 132 is id for 3D files (.3dp) and line 162 (left out from Pjay’s list) is id for skin files. (As mentioned above these ids could be different, but using same one for all doesn’t hurt.) (I will talk about the profile id at the end)

For example, line 012 could be something like “Train de Gran Vitesse” and lines 072, 132 and 162 could be TGVL.

If a tender (or a second engine) is required, then a tender .car file is needed too. The same principle than above is used, with a new id. (For example TGVT) The game (probably) skips most of the lines, so for tender only lines 072, 132, 162 and 268 (tender weight) are needed to be filled.

(Using tender files, it is possible to create a modern double-headed engine. Only thing needed is a double set of the 3D and skin files, and also that the second unit (tender) has hex 004 to set byte number 03. (set it as a tender)

2. To create new engines individual .3dp files are needed. These are included in packed game data files and needed to be unpacked before to be accessible. The required engine data files are in Data folder. Rt3_3DPF.PK4 has the original engine files and rt3_Expansion.PK4 includes coast-to-coast engines. A modern diesel engine could have only about half-dozen .3dp files, but a steam engine could have over 20 separate files.

For a new engine, the required files are copied and renamed. (same as .car file line 132 id) For example, making a TGV, only thing is needed is renaming EurostarL.3dp files as TGVL.3dp.

It is possible leave out some .3dp files and mix files from other engines. The easiest and perhaps most useful is to introduce a new type of tender from another engine. Also it is possible to take away some lights or introduced new types of wheel. (setting the texture file for foreign wheels is complicate and I will not deal it in this document. However, Pjay’s has files, which give all the needed information) NOTE! If some lights (or wheel etc.) are removed, those remaining must be renumbered so that there aren’t any gaps on the numbering. (If there is a gap, the game will stop looking for additional files.)

3. Finally new skin texture files are needed. While the game uses .dds picture file type, it is possible to use .tga picture files. .dds uses less memory and it is possible to use Coast-to-coast expansion pack’s skin converter to create these dds files. This requires unpack PK4 trainskin file and picking up needed files. (I personally don’t like the dds compression and I use tga files)

To save memory the game uses a number of smaller skin pictures. So if you don’t convert skin files to dds, you must make 50% smaller copies of tga picture and name these as xxx_A.tga, xxx_B.tga etc. (Five is usually enough) The name id must match with .car file line 162. For example, TGV would have from TGVL_A.tga … to TGVL_E.tga.

It is possible to alter loco’s look, by making areas transparent using the Alpha channel. The Alpha channel is also used making the window and light’s nighttime glow.

The profile view is created using C2C Trainskin conventor. When converted PK4 file is unpacked, files XXX_Profile.imb and XXX_Profile_A.dds are needed. Imb file can be used as it is and this name is to be written in .car file line 192. (As it is, XXX_Profile.imb). For example, TGV_Profile.imb. No changes are needed to dds file.

The beauty shot can be created with same conversion. Needed files are XXX_BeautyShot.imb, and XXX_BeautyShot_A.dds etc. The difference is that the name id is not written in .car file. The .imb file name is changed to XXX_NE.imb (XXX is line 132 in .car file/universal id) For example, TGVL_NE.imb. Dds file are not needed to be changed, anything came from the conversion is useful as it is already written in .imb file.

(It is possible to use original profile and beautyshot files. Profiles are included in three large pictures and .car file line 252 id number is used to identify right profile. (This is not needed when making new separate profiles) Beautyshot are needed to be renamed same way than converted pictures.)

I probably left out or forgot a lot, but using this guideline a new engine should be able to be created. Please comment if something is missing or is confusing. There is still so much that I don’t know myself. In principle the same process can be used to create new buildings, industries, cargoes and wagons.
User avatar
Hawk
The Big Dawg
Posts: 6503
Joined: Fri Nov 10, 2006 10:28 am
Location: North Georgia - USA

Unread post

I think this tutorial is on it's way to becoming a part of the RRT3 Extras page. :wink:
What say ye Bombar? A little minor editing and away we go. :D
Hawk
User avatar
pure al
Dispatcher
Posts: 306
Joined: Sat Dec 23, 2006 11:38 am
Location: British Rail Class 450

Unread post

:shock: Excellent, totally excellent.

I can't thank you enough. Anybody who wants to create a new loco doesn't have to keep asking questions about every tiny little thing. Thanks for sharing your secrets bombardiere!
For example, if one wants to make a TGV model...
:D I am that one.

Edit - Helpful info

I’m very new but here’s just a little bit more info to help those that are completely new:

Pjay’s website is here: http://studwww.ugent.be/~pbusscha/rt3/
It’s the one mentioned above with lots of useful info including the PK4unpack program needed to make brand new locos.

Also another important piece of information for the beginner is how to pack the pk4 files. Here’s the discovery by Wolverine@MSU quoted from railroadtycooninfo:
After a little tinkering I figured out how to pack files into a PK4 file by using the "PACK4.EXE" program that comes with the skinning tools. You need to make a text file with the names of the files you want to pack, then at the MSDOS prompt, type "pack4 <filename>" where <filename> is the name of the text file you just made with the file names to pack. you have to have the pack4.exe program in the same directory with the files and the list file. It packs them up into a file with the same name as the list file, but with a .PK4 extension. I havent tried it with TGA files yet, only some DDS files from the Demo. Can't wait to get home and try modding some buildings.
Quite easy to understand from that quote, I hope. There are also a lot of hex editor tutorials around the web that are very helpful (use a search engine to find those).
User avatar
bombardiere
Dispatcher
Posts: 425
Joined: Tue Nov 14, 2006 9:07 am
Location: Turku, Finland

Unread post

I think this tutorial is on it's way to becoming a part of the RRT3 Extras page. Wink
What say ye Bombar? A little minor editing and away we go.
Yup Hawk. Perhaps other similar stuff (such as packing unpacking PK4s) could be collected to create tutorial series.

I leave this for awhile to see if people have comments on it.
User avatar
Hawk
The Big Dawg
Posts: 6503
Joined: Fri Nov 10, 2006 10:28 am
Location: North Georgia - USA

Unread post

Perhaps other similar stuff (such as packing unpacking PK4s) could be collected to create tutorial series.
I'm all for it. :D
Since you guys and gals are the knowledgeable ones, I'll make you a deal.
You collect the info and put it together and I'll add it to the Extras page.
I'll start work on the above tutorial today. I might be able to do some minor editing on it. :wink:
Hawk
User avatar
canis39
Brakeman
Posts: 153
Joined: Sat Nov 11, 2006 5:02 pm
Location: Reston, VA

Unread post

Just my two cents: tutorials are a very cool idea!
User avatar
pure al
Dispatcher
Posts: 306
Joined: Sat Dec 23, 2006 11:38 am
Location: British Rail Class 450

Unread post

tutorials are a very cool idea!
They sure are. Maybe adding some visuals would add to their coolness. Texturing tutorial anybody?
RayofSunshine
CEO
Posts: 1288
Joined: Sat Nov 11, 2006 12:04 pm
Location: Colorado Springs, CO

Re: Short engine modding tutorial Unread post

That certainly is a mouthful Bombardiere,

and in plain English as well. I don't scan a lot of these threads, but pull up one here and there to see what is happening. And I don't know the 1st thing about trying to edit, whether it is for scenarios, maps, or skins. But I think this is a wonderful tool for people who are interested in trying some new and within their capabilities. It helps to make the program more interesting to everyone, and especially to us 'dummies', or persons who just like to 'play' engineer, dispatcher, stock management, and tycoon.

Thanks to all creators. :salute: !!clap!!

!$th_u$! Ray of Sunshine
User avatar
Settebello
Hobo
Posts: 25
Joined: Mon Mar 24, 2008 10:00 am
Location: Italy (central)

Some questions about engine modding Unread post

Good moning all; I am very interested in modding locos, and in improving existing ones.

Bombardiere's tutorial is the only document I could find on the net, since PJay's web site is not more available.

Despite Bombardiere's modesty about his english language, I could grasp some important concepts and tips, but many questions are currently open. I'll try to explain them enough clearly, in the hope to receive accurate answer and to give some contribution.

:arrow: On the "Xtras" page we can download the 1.06 patch containing a new version of the GP7 double in silver & orange; the patch works good, but if we add the previous GP7 double also available in blue & orange, in the train list during the game it is not possible to choose the one or the other: only the silver & orange appears; I have to notice that the .pk4 file lenghts are quite different, and the larger original .dds loco image have different values. More, during the night vision, the silver & orange version presents a light glow around the side hatchways. The same happens if we install both GP7double engines in the 1.05 official version. For this reason, I erased the silver & orange version, restoring the blue & orange one; previously, I managed to modify the lenght of the profile, so that the engine appears correctly on the train list. I did it modifying directly the .PK4 file, because I do not own a PK4 pack utility, and this consideration introduces my 2nd question:

:arrow: Engine modding would be very simple if we could use a good PK4 unpack/pack utility; what I've been using until now is the Java one i could find somewhere months ago, but only the unpack feature is available, it is a little bit rough in its use, even if very fast. More information would be very appreciated about file specifications. E.g.: I can't understand if we can modify directly .dds files; the AMD ATI Compressonator utility allows us to read & transform .DDS files imbedded in .PK4 archives, but those files do not own the information about transparency masks, so I can't explain myself if that is the correct way to operate ... I didn't try.

That's all ....... at the moment. Who is going to help?

!$th_u$! - Settebello
Settebello
User avatar
WPandP
Engineer
Posts: 762
Joined: Tue Sep 11, 2007 5:16 pm
Location: Cincinnati, Ohio
Contact:

Re: Some questions about engine modding Unread post

Settebello wrote: :arrow: Engine modding would be very simple if we could use a good PK4 unpack/pack utility; what I've been using until now is the Java one i could find somewhere months ago, but only the unpack feature is available, it is a little bit rough in its use, even if very fast. More information would be very appreciated about file specifications. E.g.: I can't understand if we can modify directly .dds files; the AMD ATI Compressonator utility allows us to read & transform .DDS files imbedded in .PK4 archives, but those files do not own the information about transparency masks, so I can't explain myself if that is the correct way to operate ... I didn't try.

That's all ....... at the moment. Who is going to help?

!$th_u$! - Settebello
First of all, welcome to the forum!

Secondly, I haven't done much in the way of engine modding yet, though I've taken in what Bombardiere has explained and think I understand it well enough now. I at least know which tools I have been using to create mods, and you are right, in that it is tedious to use so many inefficient programs to do all the different tasks required.

For modifying DDS files, I have resorted to converting them from DDS into TGA or PSD, then using my favorite image editor to manipulate them. The game can read TGA files rather than DDS (in most but not all cases), but they must be saved without compression. The 2D interface graphics, it seems, simply have to be DDS; this includes the engine's profile view and the beauty shot.

For unpacking PK4 files, I am using the same thing you mention, I think, which is Watto Studios Game Extractor. For my purposes, I just went ahead and unpacked all the PK4 files I thought I might need, and put the contents of these in a designated "backup" folder. When I want to use the trucks from one car together with the body of another, I can just copy the files out of here, rather than unpack a PK4 file again.

For writing PK4 files, I just recently discovered that there is a "Pack4.exe" utility that comes with the User Skinning Tools installed by the Coast to Coast expansion. This is a DOS (command line) application which works via command line modifiers, so again, making use of it is not straightforward. Before I found out about this, I just released mod content without Packing it; the game doesn't require things to be in a PK4 file, and certainly while you are still developing a work-in-progress you don't want it to be Packed up. But, for the better enjoyment of others who will use your mod(s), it is good practice to put things into PK4 format.

I think all of this would be better served by another thread that is dedicated to mod tools, so I think what I will do is go now and start such a thread (in the "Letters to the Editor" section).
=Winchester, Paston & Portsmouth=
====== We Provide Pride! ======
User avatar
Settebello
Hobo
Posts: 25
Joined: Mon Mar 24, 2008 10:00 am
Location: Italy (central)

Re: Some questions about engine modding Unread post

When a doubt is solved, 2 more appear at my trainskinner's horizont.

Both Bombardiere & WPandP talk about using indifferently .dds and .tga images to modify engines or invent new ones.
WPandP wrote: The game can read TGA files rather than DDS (in most but not all cases), but they must be saved without compression.
It is surely unuseful to write that file compression normally involves loss of information, and we can easily notice what happens if we try to create new engines using the trainskinner program included with the game; the same engine profile looks like shown through a noisy fog, colours are not the same as the original.
The proof I tryed this morning replicating the GP7 engine with the help of your explainations gave me those results.

So, I would like to comprehend better how to "tell" the game to use .tga files instead of .dds, and where to locate them.

Thank you again for your attentions.
Settebello
User avatar
WPandP
Engineer
Posts: 762
Joined: Tue Sep 11, 2007 5:16 pm
Location: Cincinnati, Ohio
Contact:

Re: Short engine modding tutorial Unread post

There isn't any way to tell the game to prefer to use a TGA instead of a DDS file; it simply tries to load the appropriately-named DDS file first, and if none exists, then it looks for a TGA file. Thus, if you are attempting to replace the skins that come in the game by default, such as a Passenger Car skin, the game will load its version of "PassA_a.DDS" which is locked up inside its PK4 files, unless you deposit a similarly-named DDS file in your UserExtraContent. If you place a TGA there, rather than DDS, then it won't get loaded; the original DDS takes priority.

The workaround is to hex-edit the .CAR files such that they refer to different filenames. Thus, my passenger car skins are along the lines of "CoachA_a.TGA", and the .CAR file tells it to look for "CoachA" assets rather than "PassA" assets. There are no "CoachA" DDS files anywhere in the game's default PK4 files, and thus nothing to conflict with my new content.
=Winchester, Paston & Portsmouth=
====== We Provide Pride! ======
User avatar
Settebello
Hobo
Posts: 25
Joined: Mon Mar 24, 2008 10:00 am
Location: Italy (central)

Engine modding Unread post

I begin to think that engine modding & coach modding are quite different; I completed every kind of trial to produce new engine skins using tga images, but none of them was successful; contrariwise, no difficulties encountered unpacking, modifying and packing again existing ones or starting from the rainskin utility included with the game.

The main matter I would like to solve is the loss of definition when converting tga images in dds ones, and the light glows troubling some nice engine skins.
Settebello
User avatar
WPandP
Engineer
Posts: 762
Joined: Tue Sep 11, 2007 5:16 pm
Location: Cincinnati, Ohio
Contact:

Re: Short engine modding tutorial Unread post

Engines and cars are skinned in the same way, and in fact it is possible to use car bodies as engines and vice-versa; Bombardiere has created a commuter electric engine by using two passenger car bodies together, with an appropriate skin, and I am considering using a tender body as a particular freight car. They are all somewhat interchangeable, since they are all 3DP files that have skins with corresponding names... if you wanted to, you could make an operating engine out of a House model, I bet!

The trick is in the file format for the skin. If you are using a TGA, then it must be saved without compression and without the origin at bottom left; my image editor of choice (GIMP 2.4) gives me both of these options when I Save As... TGA. The game expects the origin (pixel 0,0) to be at the top left.

As mentioned before, if two files exist, both with the same name but one is a DDS and the other is TGA, then the game will load the DDS. The engines that come in the game have all of their associated skins as DDS files, tucked away in the PK4 file(s) that it installs. If you don't do anything to either remove those DDS files or hex-edit the engine's .CAR file such that it points to a different filename, then you will have to place a DDS file in your UserExtraContent that has the exact same name as the packed one, in order to supersede the default skin.

If all you want to do is create an alternate skin for the given locomotives, I suggest using the TrainSkin utility. If you wish to create a stand-alone engine that gets listed separately in the game, then it does take a little more work, mostly with a hex editor.

As for the glowing edges at night, that is caused by the alpha channel in the TGA/DDS files; any pixel that has a "grey" alpha value (somewhere between fully opaque and fully transparent) will glow at night. These soft silhouette edges are created when the skin gets resized - the game uses an "A" version of the skin at highest resolution when you are zoomed in, but then substitutes a "B" version as you zoom out, and that B version is half as wide and tall as the A; then there is a "C" version, half as big as B, and so on, down to E or F versions. The TrainSkin utility creates all these versions for you, but if you want to control the alpha masking to reduce/eliminate the glow, then you have to create all those reductions yourself, and do what it takes to get a clean alpha channel silhouette.
=Winchester, Paston & Portsmouth=
====== We Provide Pride! ======
coruscate
Dispatcher
Posts: 398
Joined: Wed Sep 24, 2008 1:10 pm

Re: Short engine modding tutorial Unread post

Okay, I went through this document and PJay's stuff and I cam get the game to recognize my loco.

There's just one problem.

It's an updated GP7 that appears in 2010 as a bio-diesel engine, a cheap, not so fast one basically as opposed to all the "uber" engines that the game makes.

When I add it into the game, the game registers two copies of the GP7 under the new name. If I remove the files, the GP7 goes back to normal, I double checked all the documents and my only clue is I think it was spot 252 in the car file?

http://healthyinsanity.com/railroad/

It's just under the top if anyone wants to try and slap it in. I haven't PK4ed the skin but there's a "sample" of it there. Nothing fancy, just a green hue and a bio-diesel logo. No 3dp files needed, I'm trying to run off the GP7 as is.
User avatar
WPandP
Engineer
Posts: 762
Joined: Tue Sep 11, 2007 5:16 pm
Location: Cincinnati, Ohio
Contact:

Re: Short engine modding tutorial Unread post

When I make a new engine, building, or car, I go ahead and create a full set of assets for it, all with the same unique name. While it is theoretically possible to share assets, like two engines using the same _body.3dp but with different skins, and it is definitely more data-economical to do so, it can be hard to get the asset-sharing right. Plus, it makes it harder to sort out conflicts between multiple mods that make use of the same shared assets.

In this case, I notice that your beauty shot and profile are still named "GP7_". Thus, when the game presents the original GP7 to you, you see your new green paint job. My preference is to copy the files pertaining to the GP7, then name them all "c7bio_", and change all references to GP7 in the .CAR and .LCO files to the new engine's prefix. This way, you avoid overlap, plus you can go in there and edit to your heart's content without messing up the original GP7 (including .3DP edits). That's generally my first step, actually: collect all the files needed, rename them, then edit the .CAR and .LCO files. Launch the game and see if your new asset loads properly. Only when it does so do I start the skin editing and such. You can use proxy images for the profile and beauty shots; I use ones created for earlier mods. It looks odd to see, in the train list, a maroon mail car serving as the engine for the train in the train list, but the fact that it is there tells me that the game is actually loading my assets properly.

Incidentally, I discovered the hard way that the "beauty shot" isn't actually called that, in order for the game to load it. Instead it is called "EngineName_NE_A.tga", with B and C versions at reduced resolutions. If you unpack one of my engine PK4's you'll see this.
=Winchester, Paston & Portsmouth=
====== We Provide Pride! ======
coruscate
Dispatcher
Posts: 398
Joined: Wed Sep 24, 2008 1:10 pm

Re: Short engine modding tutorial Unread post

That's all fine and stuff, the file names were pulled right out of the engine skinning utility, I used it to insert it into the game as a GP7 skin. I do like you're talking with my buildings but I wanted to get the "programming" right first and that's my issue right now, the game is confusing the two somehow.
zzc
Watchman
Posts: 65
Joined: Sat May 23, 2020 9:17 pm

Re: Short engine modding tutorial Unread post

I made a clone of the orca, by unpacking the pk4 and renaming all the related files to fit the new engine. It just cannot load the beauty shot, but otherwise appears to work fine.
User avatar
Gumboots
CEO
Posts: 4813
Joined: Mon Aug 13, 2012 4:32 am
Location: Australia

Re: Short engine modding tutorial Unread post

It'll be a naming problem with that file. Check the contents of ******L_NE.imb to fix it (where ****** is your loco name, of course).
zzc
Watchman
Posts: 65
Joined: Sat May 23, 2020 9:17 pm

Re: Short engine modding tutorial Unread post

The default orca doesnt seem to have an imb file? it does have ne.dds files, a to c. Is there any tool to convert the format? In the car file the default orca has carview2.imb, so I left it the same.
Post Reply