Gmax
Rolling Stock Tutorial
In this
tutorial you will learn how to create a box and texture it, add the
required attachment points, export it and then create the config.txt
file. The methods used to create the flatcar can be adapted to any Trainz
rolling stock item.
Note. To
complete this tutorial you will need to download the sample texture
here.
To assist in
the presentation of this tutorial I have changed the viewport settings
to shade selected faces. This is done by selecting the text in the
top left corner of the viewport and selecting "Configure..." and
then selecting the "Shade selected faces" checkbox.
|
To complete these
tutorials with the dimensions listed herein you will need the following
setup
1. Open the "Preference Settings" from the "Customize"
menu. Under the "General" tab set the system unit scale to
1.0 units = 1m
2 Open the "Units Setup.." form the "Customize" menu
and set the units setup to Metric Meters.
|
| 1.
Create a box.
The
first thing you need
to do is create a box. At this point the size of the box does not matter.
|

Figure
1 Box tool

Figure 2 Box
|
| 2.
Resize the box
Once you have
created the box we need to resize it. You will need to select the box
and then switch to the "Modify" panel.
|

Figure 3 Modify
menu with the box selected
|
| For
the box you will need to enter the following dimensions
| Parameter
|
Box1(MainBody) |
| Length
|
12 |
| Width |
3 |
| Height
|
0.2 |
| Length
Segments |
1 |
| Width
Segments |
1 |
| Height
Segments |
1 |
|

Figure 4 Results
after resizing
|
4. Converting to mesh (Optional)
The
next step is to convert the body to an editable mesh object we do
this by selecting
the object and right clicking which then opens a context menu as shown
in figure 5. Select the "Convert to Editable Mesh" entry.
This is not required to complete the tutorial but if the box requires
further editing or reshaping then you will need to convert the object
to an editable mesh.
|

Figure
5 Converting to Editable Mesh
|
5.
Relocating
Select
the main body (Box1) and then select
the move tool from the main tool button menu and type the following
dimensions
into the co-ordinate boxes. These boxes are located at the bottom of
the gmax window. You can also right click the "Move tool" and type
them in the "Absolute World" section of the "Transform Type-in"
window.
|

Figure
6 Move tool

Figure
7 Co-ordinate boxes
|
| 6.
Applying Textures
We
can now apply the textures to the main body. To do this we need
to open the "Material Editor". Select
the Material editor icon and the "Material Editor" will appear.
Select "New" and then in the "New Material" dialog
box select the "Standard" entry. Expand the "Maps" menu.
Find the entry "Diffuse Color" click on the corresponding "None" item.
A new window will open called the "gmax Material Navigator"..
You will see a list of items with a green parallelogram icon Double
click the "Bitmap" entry. This will open a "Select Bitmap
Image File" dialog box. You will need to find and select the "Tutorial.tga" file.
(You may need to change the file type to view tga files).
|

Figure
8 Material Editor Icon

Figure
9 Material Editor with no textures

Figure
10 Material Editor showing Material #1

Figure
11 Material Editor showing the globe

Figure
12 gmax Material Navigator with all textures loaded

Figure
13 Blue and white cube
|
When
you have completed the texture loading select the globe at the
top of the material editor as shown in figure 11 and drag
it to the main body. In order for the textures to show up in the window
select the blue and white cube in the "Material Editor".
If you have more than one texture in the scene you can use the "gmax
Material Navigator" to switch between them.
|
7.
Adding an "Unwrap UVW" modifier
Now
that we have applied the texture to the main body we need to map
the texture to the correct location. To do this we need to add an "Unwrap
UVW" modifier to the main body. To add the modifier you need to
select the main body and then go to the modify list in the modify menu.
You may
have to scroll down to find the "Unwrap UVW" modifier
|

Figure
14 Applying the Unwrap UVW
modifier

Figure
15 Effect after adding the
Unwrap UVW modifier
|
After
you have applied the modifier expand the "Unwrap UVW" in
the
"Modifier List" and select the "Select Face" entry.
Then select the top face of the main body and click on "Edit"
in the "Parameters" section of the "Unwrap UVW".
A new window will appear called the "Edit UVW"
|

Figure
16 Select face

Figure
17 Planar map

Figure
18 Face selected ready for mapping.
|
Now that we have
a face selected and the "Edit UVW" window open you will
see the screen in Figure 19. If the texture in the background is
wrong then
you will need to change the map. To do this select the correct map from
the drop down box on the top tool button bar.
|

Figure 19 Face
map ready for aligning
|
While the top face
of the main body is still selected we need to create a planar map.
To do this select the "Planar Map" from the "Unwrap
UVW" parameters.
Before proceeding
any further we need to make sure the "Move" icon is selected.
Place the cursor over the selected map and move it to one side. Then
select the rest of the mapping and move it to one side. You can also
use the "Filter Selected Faces" icon to hide the other
mapping but I prefer to leave all maps visible that way you don't
apply the same texture area to two different mesh areas. Now we need
to adjust the mapping to suit the texture. To resize the map click
on the corner of the map and the corner box should turn red. You
can now drag the corner of the map down or up to the correct size.
Place the texture as shown in figure 21. Continue selecting faces
in the viewport, selecting "Planar Map" and moving resizing
maps until you are happy with the locations and you have a result
similar
to
figure
22.
NOTE The texture
map outlines may be a different color in your version of Gmax and may
not include both diagonal lines
|

Figure
20 Filter selected faces.

Figure
21 Adjusting and relocating maps

Figure
22 Final mapping results.
|
8.
Adding the attachment points
Now
that the body of the flatcar is created and textured we need to add
the attachment points
for the bogeys and to show Trainz where each end of the flatcar is. When
adding the attachment points it is recommended to switch to the "Top" view.
To add a "Point" item in gmax you need to go to the "Create" tab
and then to the "Helpers" tab. You will need to add four attachment
points. Name them and move them as follows. Use the co-ordinate type
in boxes at the bottom of the gmax window to move the point as shown
in figure23 and rename the points using the "Name and Color" box as
shown in figure 25
| Name |
X |
Y |
Z |
| a.limback |
0 |
6.5 |
0.89 |
| a.bog1 |
0 |
4.5 |
0.45 |
| a.bog0 |
0 |
-4.5 |
0.45 |
| a.limfront |
0 |
-6.5 |
0.89 |
The naming of these attachment points
is critical and all of them must be included on the model.
|

Figure
23 XYZ co-ordinate boxes

Figure
24 Top view

Figure
25 Naming the point

Figure
26 Point menu item

Figure
27 Finished flatcar with attachment
points
|
| 10.
Exporting
Once you have completed
the mesh then we need to export it to the Trainz format. Deselect everything
and select "Export" from the file menu. Type in a name with the .im
extension. Then select the "Trainz format [*.IM,*.KIN,*.PM]" entry
from the file type drop box and click "Save".
|

Figure 28
File name dialog box
|
11.
Config.txt creation
Once
you have the flatcar exported and the directory created in the custom
folder* we need to create the config.txt file and enter the following
text
|
| Config.txt entry |
Description |
| kuid <KUID2:86105:15000:0> |
This is the kuid number. Replace the "86105" with
your user number and replace the15000 with a suitable number for
your item. The recommended range for a rolling stock freight car
is 15000 to 19999. The last number represent the version number
for the item. |
| name Flatcar Tutorial |
This is the name that will show up in Driver. Give the flatcar
a meaningful title but keep it short as possible. This should be
kept the same as the "Username" |
| company Santa Fe |
This is a company name for the item. |
| origin USA |
The original country the rolling stock was used or created in. |
| bogey <KUID:86105:50001> |
This is the kuid number of the bogey file that will be used on
the flatcar. I have used one of my own bogey numbers you can change
the number to the bogey you want to use. |
kuid-table {
0 <KUID:86105:50001>
} |
This tells the download station what items are required to use
the flatcar. |
| engine 0 |
This tells Trainz that the item is rolling stock and not a locomotive. |
| mass 50000 |
This is the mass of the flatcar in kgs |
| kind traincar |
This tells Trainz that the kind is a Traincar and not a scenery
or track item. |
| category-class XFM |
This will allow the content to be sorted by the category class.
XFM is a general service flatcar. |
| category-region-0 US |
This is the region the flatcar was used in. If there is more
than one country required then you can add category-region-1 on
the next line. |
| category-era-0 2000 |
This is the years that the item is used in. As with the region
category you can have more than one. |
| enginespec <KUID:-1:42004201> |
This is a dummy engine spec file. This file is included with
Trainz. |
| description "Tutorial on how to create a simple
Flatcar" |
This is a description about the flatcar. It can be brief or very
detailed. |
| asset-filename Tutorial |
This is the folder that the meshes and the textures are contained
in. |
| username Flatcar Tutorial |
This should be the same as the "Name" category. |
mesh-table
{
default
{
mesh Tutorial_body/Tutorial_body.lm
auto-create 1
}
shadow
{
mesh Tutorial_shadow/Tutorial_shadow.im
}
}
|
This is the mesh table. In this table you can reference items
such as animation and other attachments. Animated items can also
be controlled via the use of a script.
You will notice that the main body mesh does not point to
the actual im mesh but to a lm file. This file is the level
of detail file (see below).
|
12. Tutorial.lm.txt creation
Now
that you have created a config file for the flatcar you will now
need to create a level of detail file for the flatcar.
| Version 1.0 |
|
| offset = 0.01; |
This prevents popping between two level of details repeatedly |
| calcPoint = center; |
The position where the level of detail is calculated from. |
| multiplier = 1.0; |
Level of detail multiplier. |
| animationCutOff = 0.00; |
This is the level where the animation stops 1.00 = full width, 0.5
= half screen width and 0.00 = never stop animation. |
| renderCutOff = 0.00; |
The level (to screen width) where rendering stops. |
| attachmentCutOff = 0.06; |
The level where :Cull flagged attachments are dropped. To make
use of this feature the attachment points must be renamed with
the :Cull at the end of the name ie. a.bog0:Cull |
mesh ("0.07")
{
name="Tutorial_body_lowest.im";
}
mesh ("0.30")
{
name="Tutorial_body_low.im";
}
mesh ("0.52")
{
name="Tutorial_body_med.im";
}
mesh ("1.0")
{
name="Tutorial_body.im";
}
|
This is the table that tells TRS2004 to display different
meshes at different screen sizes. For example the first entry
will display the lowest detail mesh when the loco requires 0.07
of the screen. For this tutorial you will only need the last
entry. But when you are making a complex object such as a locomotive
then you will need all the files which are the same locomotive
at varying degrees of detail and texture size. For example with
the SD70MAC the textures for the original are 1024 x 1024 and
the polycount is around the 22000 mark but for the lowest detail
mesh the texture size is dropped to 128 x 128 and the polycount
is 8000.
mesh ("1.0")
{
name="Tutorial_body.im";
}
|
|
The next step is to see if the flatcar shows up in Trainz. If you
have created the folders correctly and entered the correct entries into
the config.txt file and the level of detail file then the flatcar should
show up in driver.
NOTE: If you are copying and pasting from this tutorial then please
make sure the quotes are correctly formatted.
|
*See the Rolling Stock File Folder Tutorial
Was this tutorial helpful?
Not enough or too much detail? Points not explained properly? Suggest
any improvements? Please let me know what you think here.
Download
this tutorial here as a PDF document. |