Wednesday, May 14, 2008

Making the Steam Engine Go









Written 5 May, 2008


Making the Steam Engine Go

I had a mostly nonfunctional steam engine.

The logs in the firebox danced and crackled merrily and the door to the firebox opened with a squeak and closed with a satisfying thud, and smoke poured merrily from the smokestack, but the flywheels and governor were still and the whistle didn’t sound.

I added simple rotation and texture rotation scripts to set the belts and flywheels and governor in motion and added a great free steam whistle sound and a nice teakettle sound and a chuffing steam engine sound.

Now I could make the engine whistle upon touch, and the components turned merrily. I wanted more.

So I added two buttons, one labeled Steam Engine ON and the other Steam Engine OFF. Then I set out to make scripts that would make the engine gradually start and stop.

Using channel 9, I set the ON and OFF buttons to talk to the various animation, sound, and smoke scripts. Eventually I succeeded: The engine now starts and stops gradually, just like a real steam engine.

Here’s the sequence:

The start button is pushed
The smokestack’s cover moves to open position
The fire lights with a whoosh
Liquid begins to bubble through the translucent pipe
Smoke begins to rise from the chimney
After a few seconds the flywheels and governor start to turn
Teakettle and huffing sounds grow gradually in intensity
The flywheels and governor gradually achieve full speed
The Kaboom bird starts moving
The whistle blows

Shut-down does the same, in reverse:

The whistle blows
The fire goes out
Liquid stops moving through the translucent pipe
Teakettle and huffing sounds die away gradually
The flywheels and governor slow and eventually come to a stop
The smoke clears
The smokestack cover moves back into place with a squeak

Time to rez-faux this build, I think

--

The scripting for the steam engine might sound complicated, but it wasn’t, particularly. I used a half dozen simple scripts, most of which listen or respond to touch and perform one or perhaps two functions. I modified free and widely-available scripts. I think I’ll leave the scripts full-perm when I put the steam engine on the market.