Railworks - tips and tricks

Here are some things I decided to write down because I've already forgotten them too often.

To debug lua scripts:
Make a shortcut to RailWorks.exe, and in its properties append this to the target:
-LogMate -SetLogFilters="All" -lua-debug-messages

Note: -SetLogFilters="Script Manager" DOES NOT WORK!

Start Railworks from that shortcut. Then go to the Settings tab and tick the boxes for LogMate and LuaDebugMessages. Untick "Full Screen" (so you can watch the log and railworks at the same time).

To get a shiny, smooth metal effect in 3DC:
Material Palette
> General > Diffuse 40 / Ambient 1 / Specular 10 / Translucent 0
> Primary Texture - .ace texture file, RGB/8 bits per channel, with alpha channel (approx. 90% black)
> Bump Map - empty
> Specular Map - same as Primary Texture
> Environment map - .ace texture file, RGB/8 bits per channel, no alpha channel, colour 129,129,129
> Custom Fields > Rail Sim > TrainSpecEnvMask.fx

To get a shiny, bumpy metal effect in 3DC:
Material Palette
> General > Diffuse 40 / Ambient 1 / Specular 10 / Translucent 0
> Primary Texture - .ace texture file, RGB/8 bits per channel, with alpha channel (approx. 90% black)
> Bump Map - a suitable bump mapped texture. It can be made using Crazybump.
> Specular Map - same as Primary Texture
> Environment map - .ace texture file, RGB/8 bits per channel, no alpha channel, colour 129,129,129
> Custom Fields > Rail Sim > TrainBumpSpecEnvMask.fx

To avoid a grid of spots appearing on the textured surface, or "colour banding", suffix the .tga and .ace texture filenames with "_NM" (meaning No Mipmaps) so that it won't get compressed.

To get a tinted, transparent (like glass) effect in 3DC:
Material Palette
> General > Diffuse 35 / Ambient 5 / Specular 0 / Translucent 1
> Primary Texture - .ace texture file (xxxx_nm.ace), RGB/8 bits per channel, with alpha channel (approx. 27%). The blacker the alpha channel, the more transparent the window.
> Environment map - .ace texture file, 64x64 pixels, RGB/8 bits per channel, no alpha, with a gradient going (from bottom to top) evenly from black to white
> Custom Fields > Rail Sim > TrainGlass.fx
                       > Tx Alpha > Transparency

To get a single-axled bogie to work.
I discovered that RW can't cope with single-axle bogies, such as the leading truck on the 2-8-0 consolidation. If you create a bogie with only one axle, you won't be able to place the vehicle on the track. I suspected it was because RW had no way to know how the bogie should be aligned. The solution that worked for me was to add a second axle, made of a single small cube placed directly ahead of the real axle, painted with a 100% transparent texture (TrainGlass.fx using a texture with a 100% black alpha channel). Put the cube into the model as an axle in the hierarchy (e.g. call the object 1_2000_bo01wh02 and put it in the group bo01wh02 below the parent node bo01).

Why does my animation work fine in 3DC but goes haywire in RW?
That happened to me because of a group hierarchy in 3DC where the parent group had no objects of its own, i.e. it had only child groups. It looked fine when animated in 3DC, but when exported to RW, the parts were going all over the place. When I got rid of the parent group, the animation in 3DC was then the same as in RW. So when I then corrected it in 3DC, it fixed it in RW too.

Why are there "bumps" in my animation even when I've checked that the steps are correctly positioned?
It happens if you use the red dots instead of blue dots in the animation timeline. The blue dots are ordinary key frames, and 3DC smoothes the transitions between key frames. A red dot is for the start of a new subpath, and the transition from the previous key frame won't be smoothed, resulting in a "bump". Use the red dots only when you really do want to mark the start of a new path in the timeline.

Another cause of bumps in the exported animation is when a part is in a sub-group of a parent group that follows a circular motion. This happened when I was animating the main rod, where one end is joined to the fly/eccentric crank, which in turn is connected to the main driving wheel. The other end of the main rod goes to the cylinder crosshead which follows a horizontal back and forth motion. At first, I put the main rod into a subgroup of the group containing the crank and wheel,  so that the crank end followed the crank automatically and I only had to manually position, at each animation step, the end joined to the crosshead. That caused a bump in each revolution. By taking the main rod out of the wheel's group, and positioning both ends manually, the animation became as smooth as silk.

Well, almost! There was still a bit of bumpiness for an entirely different reason. What I discovered is that sometimes when trying to position the animation step for something long, such as a siderod, the end of the rod just wouldn't stay where I put it. It happened when the rod was meant to be very close to, but not completely, horizontal. As soon as I let go of the mouse button, it would move by itself until the rod was fully horizontal (and not where it was intended to be). I am absolutely certain that it's a problem of rounding of floating point numbers in some calculations done by 3DC. The solution turned out to be quite simple (but took me months to stumble across). When I have something long to animate, like siderods, I now shift the object within its own group until there is a large angle (close to 45 degrees) between the group axis and the longitudinal axis of the rod. You can see this when you click on the group (rather than the part) and see the group's bounding box. When the group axis is aligned with the part's own axis, the bounding box is very narrow, and that's what causes the problem. Shift the part in the group, to get that 45 degree angle, and the bounding box will be much fatter, which solves the problem.

How to correct an "out of memory" error when running a 32-bit program like 3DCrafter on a 64-bit machine with lots of memory.
I have a 64-bit Windows 7 PC with 12GB of RAM. The model of the Consolidation got so big that I kept getting an "out of memory" error when trying to export it to an .igs file. It seemed to happen when the memory used by 3DC reached about 1.5GB. I fixed this by installing the "Explorer Suite" from NTCore (http://www.ntcore.com/4gb_patch.php) and then using its "CFF Explorer VII" tool, following the instructions given here to ensure that the executable of 3DC can handle more than 2GB of memory: http://www.talkgraphics.com/showthread.php?42418-32-bit-memory-limit-removal-utility&s=618af0a0b6a13771159d3ad990d3ee70


How best to animate a multi-part mechanism that doesn't sit horizontally, such as an American steam locomotive's regulator.
First of all, model it perfectly aligned with the horizontal and do the animations in the horizontal plane. Don't try to tilt it first and then animate it, because that's very difficult to get right.

After you've got it all animated nicely, in the horizontal (and vertical for that matter), you now need to tilt it. If the boiler back face isn't truly vertical (they are usually at an angle of around 80 degrees, not 90), it will have to be tilted down (so the engineer can reach the handle) and backwards (so that the fulcrum base is flat against the boiler back face).

Before tilting anything, make sure that the outermost group in the model that contains the parts that you're going to tilt does also contain at least one object. This is really important! If it doesn't, then when you tilt the parts (after selecting them all together), it might look as if they've all stayed together in one
piece, but the outermost group centre will NOT have moved at all!! Since all the movements of the child parts, when running the animation, are relative to the POSITION AND ORIENTATION of the outermost group's centre, which hasn't been tilted, the animations will go haywire.

The way to do it is to put a dummy object (like a cube) into that outermost group BEFORE you move anything else. As long as you select that dummy part together with the genuine parts, it will make the outermost group's centre move too, when you move all the other parts.

You can delete the dummy part AFTER you've finished positioning the animated multi-part mechanism (deleting it won't mess up the animations, but if you ever need to reposition again, put another dummy part in).

Whatever you do, DO NOT USE THE "SHIFT TOOL" to move parts after you've animated them. It will ruin the animation because the relative positions will be changed when you shift things within a group.

Another important thing to remember: if you're repositioning an animated group (e.g. to align it with the boiler face) but that movement isn't part of the animation, don't forget to switch to modelling mode first!! (if you do forget, you might wonder why your animated parts suddenly fly off somewhere).