So, you want to build a train for BVE4?
In part 3, I discussed the panel image
and by now you should have your
daytime panel2.bmp more or less complete. Naturally, you'll be
saving these files in the right place in the directory structure, so
you'll have a new directory in BVE4/Train for your train and a
subdirectory in it either called d3d or bve4 which, at the moment,
contains just your recently-made panel2.bmp.
In this part, I'm going to study animation. many things in BVE
can be animated: dials, lights, power and brake handles, switches and
wipers, for example. All of these things work by superimposing an
image on the background. As a simple example, we'll consider the
TPWS panel. This has 3 lights/buttons, normally one red and 2
amber/yellow, like this:

This one is in a separate box as it's a retro-fitment to an older
train. Newer trains have the TPWS build into the panel or some
have the screwed on panel shown above mounted in the panel. To
make it "light up", you superimpose a lit image of a button, like this:

The image to be superimposed, like all the other images in BVE4, must
be "power of 2" sized. The one above is 32x32 pixels. If
the item you want to overlay is not a "power of 2" size, you need to
enlarge the image canvas so that it is. in the case of the lamp
above, that's been done by selecting a bit more background than was
strictly necessaery just for the lamp itself.
As you can see, in this case, the "lit" image has a surround which
matches the unlit one. You can also have a "lit" image which just
consists of the amber, lit part. Some lights look better with a
surround, others don't, so you have to try different things to see what
looks good. If you study that "lit" image closely, you'll
see that it's not uniformly coloured:

This is to make a more realistic looking "lamp" effect - pretty nearly
any warning lamp other than a single LED has this sort of shading
effect. Beside it you can see the palette used for that
image. This is how you can get good-looking trains using 8-bit
images: although each image is 8-bit colour, they can ALL have their
own palette of up to 256 colours; as you can see, the one above only
contains about 140 distinct colours.
So that's how you do lights. In the case of the one above, I took
the unlit image, and picked out the colour from that, then
preogressively lightened and intensified it in stages, for the various
parts of the lit image. It's a good idea to pick up the unlit
colour to base the lit image on, that makes the lit one look like it's
the same lamp. The only exception to that rule is if tyou have a
lamp which changes colour when lit - like a clear-coloured button with
a red bulb in, say.
This is the point where you gain an advantage if you managed to talk to
a driver about what things light up when. If you can't find this
out, don't panic. For a start, you can use common-sense: some
things obviously light up or are universal; for example the TPWS
buttons/lights happen on everything; anything with a "door closed" or
"door interlock" on it will very likely light up, a "line volts" lamp
will light up when there are volts, and so on. Anything else,
take a guess - if you get it wrong, someone will soon tell you!
OK, so that's lights dealt with. Next, we'll move on to
switches. These come in various types, some are simple toggles,
some are pushbuttons that latch in or out, some are knobs that
rotate. All are handled pretty much the same to animate them in
BVE, by having a small image to superimpose over the panel image, just
like that lit button image, but of course, showing a switch. In
the case of a simple 2-position switch, you only need a single image of
the switch in the "on" position - the "off" position can be shown on
the panel image. To obtain the switch image, you need to go back
to your original photos, and find the one you took where the switch in
question is "on" (you did take that one, didn't you...). Cut out
a section immediately around the switch, large enough to overlap the
"off" position of the switch. Paste that into a new image
file. A typical switch image is either 32x32 or sometimes
32x64 or thereabouts, depending on how much of the panel image you need
to cover. Now, remember back in page 3 I said you should note the
resizing and any brightness adjustments you made to the panel image?
This is where you need that information. The image you just cut
out of your original photo needs to match the panel2 image that you
were editing, both for size and colour. Now, of course, you wrote
those down... - so now all you need to do is apply the same resize and,
if
required, the same brightness/contrast adjust to the bit you just cut
and pasted. If you did that correctly, then the bit of panel
around the switch should blend seamlessly with the panel image.
The other kind of switch is the sort with several positions.
Wiper switches, combined head/marker lamp switches, reverser lever,
power levers and brake handles all are likely to come into this
category. To do these you need a multiple image, showing the
relevant control in all its positions. There are 2 ways of doing
this.
1) remove the lever or switch image from the panel image (as has been
done for the power lever on the class 66 image shown on page 3).
In this case, you'll assemble a set of images which contain just the
control itself, in the various positions, with all the background
"blued-out"; in other words, painted with our old friend, #0000ff, like
the cab windows. Below is an example of such an image set:

This image, in the original, is 256x1024. Note that the bottom
part is not used; there's room for more images but they're not needed
for this control. The extra image space is to make the file size
conform to the "power of 2" rule.
2) leave the control in question on the panel image, in "off" position
- if it's a brake lever, for example it can be in the "released"
position. In this case, the composite image will incorporate the
background image, so make sure that you process it correctly so that it
matches, like the brake control below:

Note that in this case, the image could be partly blued-out, since the
bit on the right doesn't change - this applies to all animations -
anything that doesn't change can be on the base panel image and not on
the animation, as can be seen here, in the rear light switch and
tell-tale from the class 158 DMU:

The switch is on the left and has off and on positions, although in
fact, this could be done more simply with an image half as big, by
having the "off" condition as part of the panel image and superimposing
the "on condition, including the 2 red tell-tales. The tell-tales
are part of a block including white ones for the front lights, which
are activated by the headlamp switch.
In the case of the brake handle above, rather than blue-ing out, the
image file could instead be half the width and thus half the size in
memory, which is important for lower-spec machines. In creating a
train you should consider all possible users, some may not have such
impressive equipement as you!
Regarless of the way you choose to implement this kind of control,
there are 2 golden rules:
1) The control must always appear in the same relative position (x-y),
or it
will appear to move around the screen when operated.
2) The repeat of the image must be the same all the way down. If
the second image is exactly 231 pixels under the first, then that
interval has to run all the way down the image, so the first one is at
line 0, the next starts at 231 from the top, the third at 462, the
second at 693 and so on - if the switch is positioned at x:40, y=67 on
the first repeat, say, then in the second one it needs to be at x=40,
y=(231+67), i.e. 298. Any variation will be immediately
obvious when the control is operated in BVE, so make sure you get this
right.
Once you've done all the lights and switches and levers that you want
to animate, there are 2 more things you need to do to complete the
animation, and that's needles and wipers. These are fairly easy,
you just need a needle image, and it doesn't matter which way up it
is. Most people make them vertical. There are some needles
made available by developers for free use; or you can draw your own,
here are some example needles from various trains, all at 100%
zoom. The needle size in BVE is adjusted in the config files, so
there's no merit in making them too small. Most of these are 32
or 64 pixels wide.

Notice that the one in the middle is longer: that's because the needle
is more than 256 pixels long, so it's in a 64x512 image, to comform to
the "power of 2" rule. You'll also have noted that the second
image form the left has no "centre". That's because that needle
is designed to work on a gauge where the centre has a black or grey
cover. Some gauges are like this, others aren't and the centre of
the needle is in view. On the subject of those "covers", they're
normally just a circle the same colour as the gauge background.
If you go back and look at the class 66 speedo image, you can see
one. You need to make these if your speedo or brake gauge has
such a cover. The simplest thing to do is to select a suitable
sized circle out of the middle of the gauge, then paste it into a new
image. They're normally about 28 pxiels or so. Make the
background blue and the image 32x32.
The last thing is also a "needle" in BVE's eyes, and that's the
wiper. Your cab images should have a wiper in them. How you
deal with it depends on the type of wiper. A simple arm with a
blade on it like most car wipers just needs cutting out form the image
and pasting into a suitable-sized image of its own, then blue out all
except the wiper itself, like these:

If it's the kind which is on a pantograph, so that the blade stays
vertical all the time, then there's a bit more to it: The pantograph
arms and the blade are in 2 parts, like these from the class 170 DMU:

Although in fact you can make them from 3 pieces - the one above is a
slight "cheat" as the small pivoting part on top of the arm shoudl
technically be on the blade part, and the 2 pantograph arms can be 2
separate arms. This is, of course, even more complicated to
implement, it just depends on how much hassle you want and just how far
you want to take the realism bit - the one above looks quite good
enough in action!
That's about it for the amimation files. By now, your d3d (or
bve4) directory should have about half the images in it. In part 5, we'll discuss the creation of the
other half of the images, which are the "night" images.