Auran Web Link
Ianz Trainz

 
line

Home Page
Site Map
About
Downloads
Projects
Tutorials
Tutorial Introduction Transparent Windows Tutorials Making Art Files Scenery Backdrops Vehicle Modeling Stereo Pictures Settings in Gmax Animated Windmill Mapping Textures Shadows on Scenery Models Next Button Links
email

Tutorial 1: Creating Transparent Windows

Creating Transparent Windows

I must assume you have some knowledge of using GMax for modelling, and the following is one way to make transparent windows, particularly for buildings. Transparent windows can be used for many objects such as the Liebherr crane cab:

Liebherr Crane Cab

The tutorial will guide you through the full process of producing simple transparent windows for a building.

Tips

In GMax:

  • Save often without overwriting the previous file, in case you make a mistake, or GMax crashes
  • Name the parts as you go (window1 etc) so you can easily recognise and select them in a complex structure
  • Keep a record of the things that have been done to each file as you go, particularly dimensions that will be useful later
  • Fully texture an object (window say) and clone it to make others, to save repetition
  • Delete any polygons that will not be seen and try to keep the polycount of objects down, without reducing quality too much.

In Paint Shop Pro:

  • Use layers to do different parts of the drawing. These can then be edited or deleted without affecting the main drawing.
  • Make sure you are on the correct layer.

Principles

Firstly, transparency can be a problem in Trainz. If you have made a building and texture a wall with a see through (transparent) window included in the wall texture, the result is see through and vanishing walls in Trainz. This means that the actual transparent window texture must be separate from the main wall texture. Using a large texture file for the building then making the same size opacity map with only a few windows on it also makes for large wasteful files. The large file size and a large polygon count for the object both impact on Trainz performance.

The technique is to cut holes in a building wall where each window goes, then to make a plane to exactly fill the opening. Only the window texture and the opacity map (texture) is applied to this plane, a completely separate texture and plane from the walls.

Making Window Texture Files

We need two files the same size, one for the glass color and window frame texture (window.tga say), and one for the opacity file (window.bmp say). Do not use jpg files, Trainz has to unpack a jpg file, adding to the load time. Using a tga file with the opacity map as the embedded Alpha channel is more efficient than using the separate bmp file.

I use Paint Shop Pro 7 for creating the graphics, and I assume you have some experience with graphic programs. The size of texture files must be multiples of 32, for example, 64x32, 64x64, 128x64 or Trainz will not recognise them. You should be able to make a satisfactory window using a maximum texture file size of 64x64. Make a new file in Paint Shop this size.

File size selection box

I like the windows to have a green tint, but you might like a grey. Choose the flood fill tool (tipping paint can) and click on the color box on the top right of the screen. From the palette box, choose the light green (192,255,192). It might look too green but we will see. Now fill the new image with the green.

colour palette

If you want a window frame, choose the line draw tool (Pencil third from the bottom on the left hand Tool menu). Now choose a color for the frame as before from the color palette. Go to the Tools menu and set the line width (suggest 1 or 2 pixels only).

Draw tool and line size selection

Hold down the shift key (to draw lines vertically or horizontally) and draw a frame all around the edge of the picture. If you want to break up the glass into smaller panes, draw other lines on the glass. Remember the undo key - very useful. You could also use a picture of a window instead of creating your own.

windows.tga file

Save the picture as window.psp. We are going to make another layer and the psp format will preserve the separate layers, and the quality. Every time you save in jpg format you lose more picture quality.

Go to the Layers menu and make a new raster layer (you can do it from the drop down Layer rollup as well). Give it the title "opaque" to distinguish the layers - you could call the first layer "window", where the glass is. I generally move the opaque layer below the window layer, in the Layer rollup, just click and drag the layers up or down to re-arrange.

It is very important to make sure you are on the correct layer from now on. Click on the name of a layer in the Layer Palette, a selected layer is dark blue. You can also turn off the layers by clicking the glasses symbol in the Layer Palette.

Layer manipulation

Click on the window layer name to select it and using the magic wand tool, select the green panes of glass. Hold down the Shift key and click on all green parts. Now we are going to make this area black on the opaque layer. The darkness of the color determines how transparent the window will be.

Choose the flood fill tool, go to the color palette and choose black or a shade of black: If you use black 0,0,0 the glass will be transparent, if you choose 64,64,64, it will be translucent and show a green tinge in the final window. Use the greyer 64,64,64 color and go to the opaque layer (click on the bar for that layer in the Layer Palette until it turns dark blue) and fill the dotted areas where the green glass was. It is best to turn off the window layer as explained before if the opaque layer is under it so you can see what is going on.

Opaque 64,64,64 colour selection

The previously selected area should still be showing as dotted lines. If not, you can click on all the newly created black area. Go to the Selections menu and choose Invert.

Invert Option

This changes the dotted selected area to cover the window frames you drew. Use the Flood fill tool, choose white, 255,255,255, and fill this area. This means the frame will be opaque, wherever the opaque layer is white.

windows.bmp file

The original Trainz supported opacity maps of two colors, black and white. Since TRS2004, these colors have been interpreted differently. Unless you add at least one extra pixel of a color other than black and white in the opacity map, fine details like catenary, railings and ropes in models will fade out and flicker at a short viewing distance from the model. It is usual to add one or more pixels of a dark grey in the black area to correct this issue.

Now choose the window layer and save it as window.tga, to your GMax scene directory for the building (or whatever you are using). Make sure you have the correct layer showing. What you see will be what the file saves. Paint shop defaults to compressed tga files when initially installed. When saving the tga file, check the options box does not show compressed (Trainz can not handle compressed tga files).

Saving window.tga file

Now choose the opaque layer and save it as window.bmp. Make sure you also save the file as a psp file to preserve the layers for future modification.

There are other ways to use an opacity layer but as a first attempt, this method is simple. You can, however, use the transparency (alpha layer) associated with the tga file. This is saved with the tga file and then does not require a separate bmp map. Paint Shop pro and Photoshop will create alpha channels. Photoshop is the easier program to use. You can also use the program TGATools2 to generate and embed the layer in the tga file, see the Art file tutorial. Using the embedded Alpha channel saves on load time but requires a few more steps to implement.

GMax: Cutting Holes and Placing Windows

Assume you have a building (a simple box) and have textured the walls. That texture might show where a window is to go, or be just a plain brick wall. We are going to use a box that penetrates the wall, to cut the hole. Make the box the exact cross section of the window, and a depth of 4 or so metres. Now move the box so it passes through the wall where the window is to be cut. If you wanted a window in a matching position in the opposite wall, make the box penetrate through both walls.

Box through building

Select the main building by clicking on it. Go to the Create Menu, and you will see a box showing Standard Primitives and a small down arrow. Choose the down arrow to display the selections, and choose Compound Objects.

Compound Objects choice

The drop down menu has a selection Boolean - click on this. A little further down you will now see Pick Operand B. Click on this then click on the box you have drawn through the wall.

Boolean selection

The box should vanish and a hole appears for the window.

Hole cut in wall

When you have cut a hole, with the building selected, on the Modifier menu, right click on the Boolean label and choose Editable Mesh.

Editable mesh change

Go back to the Create menu and change the compound objects back to Standard Primitives, or you won't be able to choose a shape to draw later. Sometimes you end up with new surfaces inside the building from the box (you can see that in the picture above). Choose the building, go to the Modifier menu, click on the + sign next to Editable Mesh and choose Polygon.

Polygon deletion

Now click on each of the unwanted polygons inside the building and delete them. It is helpful use wire frame mode, when choosing the polygons to delete. Toggle the F3 key to show which surfaces are selected (they will be red).

Polygon wireframe view

Making the Window Method 1

We need to make a plane the same size as the window hole and place it in the hole. If you had made the cutting box so it penetrated only one wall, there may be an end plane of the cutting box inside the building which will be the exact window size and lined up with it. When deleting the box surfaces as above, leave this plane. It is circled in red in the diagram above.

Window plane remaining

This plane is still part of the main building and it should be detached as a separate object. Click on the building, open the modifier menu and choose Polygon as before. Now choose the plane itself. Because it was a back plane of the cutting box the normals may be facing away from you and it may be difficult to select. Rotate the box, and sight through the hole, or come from the back of the box. When selected, go further down the modifier menu to find Detach. Detach it as an object and give it the name window as you do so.

Window plane remaining

Now select the window end plane and move it so it fits into the window opening. You could use the align tool, by choosing the new window plane, then the align tool and selecting which maximum or minimum face of the building you need to align with.

AligningAligning

Making the Window Method 2

If there are no planes left over from the cutting process, you need to draw a plane to fit. You should have noted the window size from the box you made - Use the Create - Plane option and set the Segments options to 1x1, and make the plane the size of the cross section of the cutting box.

Drawing a Plane

Now move it into the window hole. You can turn on the vertices of the building or the window plane to check exact co-ordinates of the hole etc (Modifier menu, click on the + sign next to editable mesh and choose vertex). Now choose a vertex and read the co-ordinates at the bottom of the screen. You can move the individual window vertices if needed, to fit the exact window opening. This is useful where the wall is an irregular shape, say a window in a cylinder.

Making the Window Method 3

This is the easiest method. Select the building and in the modify menu under Editable Mesh, select the Polygon option. The building will show small points on each of the vertices including the hole corners. Select the create option, then click on one of the red vertices of the window hole, then going in an anticlockwise direction click on the second vertex, then double click on the third vertex. This will now close back to the first point, and make the window plane.

Note that when you are exactly over the vertices, the cursor will change to a white cross. As soon as you have constructed the plane, click on the Create button to turn the mode off. If you click elsewhere in the viewport, you will make unwanted points in the scene. You must undo these mistakes. The diagram above is shown in Wireframe mode.

Make other holes and planes in a similar manner. The window plane made in this way will be part of the main building. You could detach the plane separately from the building, but you may see flashing dotted lines around the window opening in Trainz, if the window is not "welded" to the building. As long as the texture is separate from the one applied to the rest of the building, there should be not transparency problems.

Texturing the Windows

Open the material Editor and choose New - Standard for the material.

New Material

Type a name of "window" in the slot to identify the window texture. The Material editor should show the following screen. If the Maps screen is open, close it by clicking the - symbol.

Material Editor

Make sure you tick the check box for double sided or you won't see the window from the other side of the building.

You need to lock the ambient and diffuse. Double click the small square to the left of the Ambient label and answer yes. Click the small square to the left of the Diffuse label and answer yes.

Now click the dark grey square to the right of the Diffuse label to open the Material Navigator.

Material Navigator

Double click in the black bitmap square to open the file load dialogue box, go to where you have stored the texture files and load the window.tga file.

File Loading

Now go back to the Material Navigator screen and double click the parent material (you could click the small up arrow in the Material Editor) so you can get to the Map screen

Opening Map screen

If the Map screen in the Material Editor is not open, click the + symbol on the Map label line to open it. Go down to the Opacity check box and click it. Now click on the None to the right of this box, and the Material Navigator opens for you to choose a file, as before. Double click the black bitmap square and go through the process, as before, to now load the window.bmp file. However, if you have made the opacity layer as an Alpha channel of the main texture, choose the window.tga file for the opacity slot.

Map screen

You should now show the following in the Material Navigator screen.

Material Navigator display

Double click on the main window parent material box to set up the Material Editor to apply the texture to the window.

Choose the window plane, and click Apply in the Material Editor to apply the texture, also clicking the checkered cube to display the texture on the window plane.

Applying the material

Choose the Modifier menu, Modifier List, UVW map to place the texture. Because you made the texture the full size of the window pane, just choose Planar or Box in the UVW Mapping menu, and it will be mapped to fill the window plane.

Sometimes the texture may appear turned 90 degrees from the vertical. You can fix it two ways:

  • By rotating the texture in Paint Shop and re-saving, remembering to reload it into the Material Editor, or
  • By turning the mapping co-ordinates 90 degrees in gmax using the gizmo tool.

The placement depends on the direction of drawing of the plane and which face it is on. To rotate the co-ordinates you need to use the Gizmo tool in the UVW mapping title drop down selection, and rotate, move or scale the gizmo. I will not cover these options here.

When finished placing the texture, don't forget to right click on the UVW mapping title words and collapse all. This sets the mapping co-ordinates for the texture to be placed and displayed correctly.

You should now have a window that will show a faint green tinge in Trainz. If you wanted grey, choose that glass color instead of green.

Tiling Windows

Suppose you had a row of windows, all the same, say 1 metre high and 5 metres long, with 8 window frames in the 5 metres. You would make the texture for only one of the window frames, and when you do the UVW map choice, use the U Tile or V tile box (depends on which way you drew the original window plane) and type in 8 in one of them. You should see 8 window frames spread across the width of the window. If it goes the wrong way, type 8 in the other option box. If you had 3 windows frames high, one box would show 3, and the other 8. Don't forget to collapse the modifier when finished.

Applying the material

Copying Windows

It saves time if you complete a window and copy it for others of the same size. Lets say we had cut the hole through both opposite sides of the building. Make one window. Now choose it, go to the edit menu clone, make sure the copy box is ticked in the box that opens, then click OK. It should have incremented the name by 1.

The two windows will be on top of each other, and this is why you name things so you can choose by name from the menu at the top of the screen. Choose the copy, note the coordinates may show x = 4 metres, and if you change it to x = -4 metres, the copy will go to the opposite wall. Make sure you chose the correct x or y axis to change. This all assumes the box was centered on the 0,0,0 axis.

If however, you constructed the window plane using method 3 above, by joining the vertices of the window hole, you need to use the Editable Mesh menu, choose polygon and select the window plane. Use the Detach option to separate the window from the building. Now you can copy windows, and can rejoin them to the building later, selecting the building, then the Attach button, then click on the window plane.

You can copy and rotate windows, and if you have the vertex option in the Editable Mesh on, you can drag the vertices to make windows of different sizes, rotating and positioning in window openings. A better way is to use the mirror option, it will copy the window with the normals facing the opposite way.

One issue is that when you create a window plane, the normals face a certain way. This effects the shading in Trainz. If a window looks dark in a well lit wall, the normals may be facing opposite to the wall normals. If you constructed the window in this tutorial from the end plane of the Boolean box, you will almost certainly have to flip the normals.

A window may have normals facing out of the building and the normals for the copy on the opposite wall will face inwards.

You can go to top view and rotate the copy 180 degrees to fix it, or choose the copy, go to modifier menu, choose polygon, choose the face of the window, tick the show normals box in the modifier menu. Be aware that you will have to push the menus up and down to display these options.

Show Normals selection

Blue lines should appear on the face showing the direction of the normals. If they are wrong, go to the bottom of the menu and click Flip to change direction.

Flip Normals selection

Comments

This is not really a difficult project when you become a little familiar with the GMax interface and menus, however, there are many sidetracks that you can get lost in, so always save as you go. I have tried to cover as many problem areas as possible, and it has made for a long tutorial.

Please persist and you will be rewarded with success. I know there are a number of ways of doing things in GMax, and I hope this will help you. Below is the screenshot from Trainz. A lighter window frame color would show up better.

Trainz Screenshot


Ian Manion (Vulcan) September 2005

Amendment Notes and Comments

9/01/03 The layer palette diagram (page5) showing the top layer as "draw" has been amended to show the name "window". References in the text to the layer by the name "draw" have been changed to "window" for consistency.

When saving layers, by choosing the layer I mean make it visible, as what you see is what you will save. Choosing the opaque layer, but having the window layer visible will result in the window layer being saved. Turn off layers that get in the way. If you had a top layer with dirt or grime color sprayed on it, you can turn it on or off to make different weathered textures. The text has been amended to make this clearer.

When cutting window holes, you can make a copy of the boolean box (edit-clone-copy) and move it out of the way but in line with the hole. Cut the hole and delete all the boolean surfaces in the building. Choose a surface of your box copy that will have the normals facing the correct direction, delete all other surfaces, and use this remaining surface as the window plane - no remembering dimensions, and if it is lined up with the hole, slide it in. Thanks to David Taylor for the suggestion.

15/01/03 When loading the map or texture in the Material Editor I mentioned the box to click as being to the right of the Ambient grey box. It should be to the right of the Diffuse grey box, and has been changed. Thanks to Nilsson for the correction.

7/09/05 Updated to reflect new information on opacity layers and options to make the window plane.