Monday, October 29, 2012

3DC to Railworks - Locomotive: Blueprinting Part 2

3DC to Railworks - Locomotive: Blueprinting Part 2
by Jerry "SMMDigital" Conaway


< PreviousIndexNext >


411. References to the Bogie Blueprints are input next. The first number is the metric conversion of the measurement from the center point of the locomotive to the center of the locomotive bogie. The second number is the radius of the wheel and will govern how high the wheels are off the rail. Ever see a locomotive that is floating above the rails? Fubaring this number is one of the reasons why.

412. Your driver position element will be done the same way as the couplers. Once you finish your blueprint and preview it, you will have an arrow in the preview window that your will place inside the cab to position where the poor sucker that is going to test your locomotive is going to sit.

413. Next up, create a Head-Out camera. In the asset editor, go into the folder where your Cabview blueprint is, right click on the folder, and choose Head Out Camera. Basically, you center your Y and Z values on your drivers seat, and center your X value somewhere just outside the cab. After preparation, go back and reference the new camera blueprint in your locomotive blueprint.



414. The next three fields: Script Driven Particles - No information on this at this time. Permissable speed is the top speed this locomotive can do, in kilometers. The top speed for this loco is 70mph in real numbers, so we will need to convert it - 70 x .6 = 42 + 70 = 112kph. Show derailment of course does just what it says. You do want to see Railworks spectacular 3D explosions when your unit crashes, right?


415. The next two fields under "Render Component" - Primary and Secondary Named Texture Set - is where you put in the references to your auto-numbering .bin file. Remember earlier we filled in the numbers .CSV? The fields we fill in now are for the blueprint that will call up all those dual color .ACE files we made to make them visible in the game.

416. Your Geometry ID and your Collision ID fields is where the reference to your exterior model IGS file goes. The Collision ID is the same geometry file. What this does is keep your from moving through your locomotive when you are moving the camera around in the external view. You will bounce off the locomotive or go over it.

417. The "Animation Set" fields are where the references to your EXTERNAL animation are input. Now I don't know the difference between a regular animation and an Auto Animation, but that setting was the only way I could get the wipers to work in the game. Notice that we have three animations, all placed in the Default\Engine folder that are referenced here - wipers, exterior conductor windows, and exterior driver windows.


418. Up next are the Engine Simulation and Interior Camera fields. Place the Engine Simulation file that is located in the Default\Simulation folder here, and the link to your CabView model in the Interior Interface field.

419. After filling in the Engine Simulation, we move to the interior interface file. We have to create a cab camera, which basically just tells the game where to put the driver in the cab. We'll go back to the folder where our locomotive CabView is located, right click on the folder, and create a Cab View Blueprint.

420. I used the values from an SD40 cab camera. These values can be tweaked if they are not correct once in the game. After saving this blueprint, go back and reference it in your locomotive blueprint.

421. Now we are going to be getting into our locomotive controls. Before you start doing this, it would be a good idea to use a copy of Mike Simpson's "RW_Tools" to take a look at the controls on the default locomotives in Railworks. You will gain a lot of insight into how this process works. You should also keep a copy of the RailSimulator Development Docs "Engine Blueprint" and "Cab Control Blueprints" open to use as a reference. What I'm telling you here is from my own experience, and does not supersede the RS Development Docs.


422. The first control I use is Startup. It's pretty neat to be able to click the "key" symbol in the game or click on the control breaker in the cab and watch the RPM climb and hear the loco rev up.

The Interface Element fields are where you link the animations you made to controls. As is shown in the Dev Docs, I have an Element name, and then a "Type", which is "StopGo". This refers to what type of difficulty the player will be able to experience this control in . "StopGo" is Easy Mode, with simple controls. Then there is "Intermediate", and "Expert". With "StopGo" in the field, this control can be experienced across any of the three difficulties.

The "Transform Name" is the name of the GROUP you animated part was contained in 3DC. Remember, we animated Groups, not individual part? It helps to have a copy of 3DC open when filling this part out to make sure the correct Transform name is placed here.

The Movement Type field lets you pick how this control moves. On this loco, the startup switch is a circuit-breaker type, so I use the "MoveUpDown" movement.

Sensitivity governs how easy it is to move the object.

Animation Name refers to the animation for this part that we created and placed in the Default\Cabview folder. In this case, it is enginerun.IA

"Rest in notched position" for this part is "True" - once we turn the breaker on, we want it to stay on.

Finally, this control has two positions - on and off - so it has two notches.

423. The next three controls are pretty much standard and found across all locomotives that I have looked at. They deal with the audio control system and have no interface elements.

424. This control sets up the Wheelslip light to come on when that happens on the locomotive. Again, the "Transform" field contains the Group name in the exterior model GeoPcDx file of the object to be lit up.

425. These two controls govern the movement of the air system gauge needles on the console. They are set up as Interior Levers, with a Left-to-Right movement. It should be noted that these are tied into the Engine Simulation Blueprint as well, and if that blueprint does not have values governing these controls, they will not be active in the game.

426. These are the Brake Pipe Flow (non-working) and Ammeter gauge needles.

427. The Engine Stop button controller. This is a Push-Button type control that is available for use only in the Intermediate and Expert modes. Transform name is the Group name in the Geo file.

428. Another air gauge needle.

429. On this locomotive, the Horn controller is set up as an interior notched lever that can be pulled towards you, thus the Up-Down motion control.

430. Controls for the "Make-It-Go" handle, or Regulator. This control is Intermediate, meaning you will not be able to use the handle in Simple mode, and will only be able to access this control through the HUD or keyboard. Once again, the transform name ("throttle") is the name of the Group in the Geo file, the handle will move from left-to-right, and the Animation Name links the control to the animated objects for the handle. This handle has nine possible positions, or notches, from Idle to Run 8.


431. The Reverser is also an Intermediate mode controller. Notice that the Default position is zero, which will be neutral in the game. The minimum value of -1 will be Reverse, the Maximum value of 1 will be forward. The number of Notch positions logically will be three.

432. The Simple Change Direction uses the same Transforms and Animations as the Reverser, but will only be available in Stop/Go (Simple) mode. The same is also true for the Simple Throttle


433. There are three parts to the Engine Brake, or Loco Brake. The first is the controller identifier, then come the interface values, then you have sections on Notch data - Release and Applied, or Direct.

434. The Train Brake also has three sections and notch data to represent the five positions of the brake handle: Release, Graduated Self Lap, Suppression, Continuous Service, and Emergency.

435. These Dynamic Brake values were taken from the Dash 9, so we know that they are not correct. You should research your own locomotive to find the correct values.

436. The speedometer is setup almost the same as the previous needle gauges we have done. It's movement will be controlled mostly by the Engine Simulation file.

437. For the windshield wipers, you have to connect a couple of different geometries through the blueprint in order to get them to work. The first section is the controller, and there are three parts to the Interior Interface section. The first is the Exterior Animation field. Make up an Element name, followed by the Difficulty type. The name that goes in the Animation ID field should be the same, casewise and all, as the Animation ID you entered earlier in the blueprint in the Animation Set fields.

The Interior Geometry Slave Output will be your wiper animations that you made for the cab.

The last section will specify the control surface inside the cab that you want to use to turn on the wipers. In this case, it's a DPDT toggle switch.

438. The Sander is an interior lever.

439. The bell is set up as a Push Button control, but it is actually a pull-switch that stays on until you push it back in.

440. The headlights are set up to come on by turning a knob-type switch that has three positions - Off, 1 (front headlights), and 2 (rear headlights).

441. Front and Rear Ditch Lights. The front and rear ditch light animations are set up separately and in the same way. On the prototype, the ditch lights are in a steady "on" state until the horn is triggered. It would be easy to set them up this way, but would have to have some sort of scripting to make them stay on for a pre-determined time after the horn lever is released. I know next to nothing about scripting, so the way I have done it here is to set up a push button control that can be accessed by the Engineer as necessary. You will already have your front or rear lights on, and when you are ready for them to flash, you push the button in, when you are ready to turn them off, you push them again.


442. The cab windows are set up separately. The way they are set up here is to use the windows themselves as the control surface, so all you have to do is grab one of the windows in the game and push it open or pull it shut. These are only for the interior view. You can slave the outside window animation to these, but it makes the interior windows do some funny stuff, so I'll have to find another way for those.

For those of you who are making doors that open on your cab or your locomotive, the animations for those parts should be similar to this, using the door part itself as the lever that controls the animation.


443. The mechanical aspect of the interior cab lights is a simple switch that is set up as a push button. It is linked to an animation that "turns on" two Tex'd light surfaces. Now this light does not cast any beams or ambience about, so I will have to come back and add that later.

For now, our control setup is finished.

444. Circling back to Texturing and Shape Building, now we have come to part where we install the glass and textures that will enable raindrops on the windshield. It's a neat effect that brings added realism to locomotive operation, but it's sort of a pain to implement.

We will start by opening the TrainGlass texture that we made in the "Paint Your Wagon" tutorial in our imaging program. So you don't mess up your original texture file, go ahead and save the texture file as a different texture called "windiff_nm". You do not need to make any changes to the diffuse texture. However, you need to zero the white out of the Alpha channel - in other words the channel should be totally transparent, or black. Save the file in it's native format, then as a TGA and ACE file. Be sure to save any file that has an Alpha Channel as a 32-bit file or it won't function properly in the game.


445. Now we need to make a map for the Normal Slot in 3DC. We will not need to use the Normal Map filter. Open up your "windiff_nm" texture, and on the diffuse texture, draw opaque Blue over the windows that are on the front and back of the cab. Draw an opaque Pink color over the side windows. Don't ask me why these colors were used in the source material for this, they just were. You can't see the textures in the example, as I've already colored them in, but the side windows were on the left, the front and back glasses were on the side.


446. Go to the Alpha Channel and opposite of what was done in the Diffuse texture, make it totally white. Save this texture as "winnorm_nm" in your native format, TGA, and ACE.

447. For the last texture that we will need, open your original TrainGlass file in it's native format and create a new layer above the diffuse layer.

448. On this new layer, create a "wiped" pattern on your windshield textures. I used yellow, but you could probably use any other color since this will not show up in the game. After you have finished, insert another layer between the background and the Wiped layer and fill it totally white.


449. On the Alpha Channel for this texture, everything should be totally white except the areas where you wiped. Starting with the side that the wiper blade will start from, the Alpha should be given a black-to-white gradient. Consult your particular program's help file in order to find out how best to do this. When you are finished, compress all the layers and save this file as "winwmotion_nm" in TGA and ACE formats.

Transfer all of the .ACE files you just created to the CabView textures folder in your locomotive's Railworks source folder.


450. Back in 3DC, go inside of your Cab View model and select the inside face ("3", click) of each window individually. Set your duplicate options so that the window pane you are about to duplicate will be in the exact same spot as the original.

451. On each duplicate, use the naming convention "weatherglass_1" for both the part and the Group that contains it. Any other glass after that should be named consecutively "_2", "_3" and so on. I have already done the fixed windows on this cab, numbered 1-6, and placed their individual Groups and Parts in the main Engine group. Here, I am placing each Group and Part as a sub-group of the respective side window they belong to. The reason I am doing this is because the windows are animated, and I want the weather-affected part to move with them.


452. Open up the Material Editor and find each weatherglass part in your cab model. Check each part in the hierarchy view that you want to affect, then place each texture in the slots as shown. In the Field Value box, place the "magic smoke maker" - TrainGlassWeatherEffects.fx. Apply the setting and close the Material Manager. Save your CabView file, export it as an IGS, and move it to the Railworks source folder for your locomotive.


453. In the Engine blueprint, navigate down to just below the "Control Values" section to where it says "Wiper Pairs". In the "A" and "B" fields, input the name of the wiper animation that you placed in the "Animation Set" fields earlier in the Blueprint. In this case, mine is "wipers". This is case sensitive, so make sure you reference it right. In the last two fields go the name of the Motion map and the Normal Map.

Now that you have these fields filled in and your controls set up, you should be able to export the locomotive. We still have some things to fill in, so it will only operate at about 70% capacity, but it should be enough to pull cars. Click on the Export button and you will see the Compiler take off and create your locomotive in the Railworks\Assets\YourProvider folder.

454. There is one small problem though that we will have to fix before our locomotive is ready for TrainGlassWeather. Certain versions of 3DC will not properly export the TrainGlassWeather files to the GeoPcDx model. We can fix this though using Mike Simpson's RW_Tools. Open RW_Tools and navigate to the Asset\YourProvider\YourLocomotive folder and find your CabView model GeoPcDx file. Open that file and in the Search Box, type "TrainGlassWeatherEffects.fx" in the field, then click "Find". This will take you to the parameters for the TrainGlass that you just made. The problem is with the "Name" meta-tag. If it says anything other than "weatherglass_1", then the glass will not display properly in the game. Change it. When you are finished, click on "Find Next" in the Search box to find any other references to this Shader, and change the name to "weatherglass_1" if it's not already there. Save the file.



455. You also need to make sure that there are four Meta-Tag parameters under the MipLodBias box.

If you've done your work right, this is what you see, along with wipers that clear out the droplets, when your locomotive operates in the rain.


456. If you can put your locomotive in the game for a visual test, that's good, but in order to get the locomotive on the track and partially functional in the Asset Editor, there are three more small things we need to do. Back in the Locomotive Blueprint, skip over the next section called "Children". The Children are very important, but not necessary to basic locomotive function. We will be coming back to fill this section out in the next chapter. For now, go to the field called "Script Component". We need to create a .LUA file to put in this spot.


457. As I said earlier, I know almost nothing about Scripting, but I do know that this LUA script enables some features of the locomotive, such as keyboard controls, and make it active in the game. So, I'm going to copy over the LUA script from the default ES44 just so all locomotive controls are available in the game. You could use the LUA from any locomotive, even the simple one from the default SD40. To do this, you can either copy the script altogether and rename it, or you can put an alias reference to it. If you put an alias reference to the file, you will need to move that file to an identical Kuju source folder to get it to export properly.


458. The final two fields that we are going to fill in before doing a test export of our locomotive are the Cargo designations. Expand the fields and fill them in to load your locomotive with fuel and other bulk fluids.



< PreviousIndexNext >


Published with permission from Jerry Conaway, 2012

1 comment: