Home > Tutorials > TRS2006 3d Studio Max Coal Load Tutorial

3D Studio Max Coal Load Tutorial

In this tutorial you will learn how to create a coal load for use in the industry setup in TRS2004


Gondola/Hopper will be referred to as gondola.

Mesh screenshots are from 3d Studio Max

 

 

1. Create a load.

To show the appearance of a load you need to create a plane that is the size of the gondola. For my six axle gondola I used a plane that is 10 length segments by 4 width segments. The more segments you use the more the performance hit that will be required to show the load. Once you have created the plane, convert it to editable mesh and move some of the vertexes up or down to simulate an uneven load. Add a texture to the load and then create two dummies for the animation. Name 1 b.r.main and the other b.r.load01.

 

Figure 1 Plane resized and located correctly

 

Figure 2 Finished load mesh

2. Animation

For the animation you will need to link the dummies and the load as shown in figure 3. Once you have done this rescale the time to 120. The higher the number of frames the longer the animation will run and the lower the number of frames the shorter the animation will run. 120 frames gives a good loading speed. To hide the load when the gondola is empty I moved the b.r.load01 1000 metres or 1 kilometre below ground. Moving the load this far down should allow the gondola to pass over any bridge without the load showing. Once you have moved the b.r.load01 and the linked Load01 below ground then you need to create an animation key for this location.

 

Figure 3 Directory structure

Select the b.r.load01 and click on the "Set Key" and then the "Key" button. This will set a key at the current location of the b.r.load01. Move the animation slider to the next key (key1) and then move the b.r.load01 into location at the bottom of the gondola. Now create a key for the b.r.load01 in this location. Once you have set the key move the animation slider to the last key and move the b.r.load01 to the full position in the gondola and create another key in this location. Once you have all the keys created press the play button to preview the animation. You will not notice the load disappearing below ground as it happens too fast.

 

Figure 4 Empty mesh location

Now that you have all the animations done you need to export the load mesh and its associated animation. You can either delete or hide the gondola body. If you have a gondola or hopper that has sloped ends then you will need to create a dual animation whereby one piece slides under the other as the load decreases.

3. Exporting

Export the mesh as a .im file. I named mine load.im. You can name the mesh anything you like as long as the correct reference is made to the mesh in the config.txt file. Figure 5 show the directory structure that I exported the load mesh to.

 

Figure 5 Directory structure

 

4. Config.txt file entries

Once you have successfully exported the mesh into the correct location then you need to setup the config.txt file to show the location and the name of the load mesh. Assuming you already have the asset set up and working in TRS2006 then to enable the load animation you need to add the following containers and tags to the config.txt file using CCP. In the following table the required containers and tags are listed. The location refers to the tree view area.

Location Type Name Value
traincar tag script Hopper
traincar tag class Hopper
traincar container soundscript  
soundscript container door_close  
door_close tag trigger door_close
door_close tag nostartdelay 1
door_close tag repeat-delay 1
door_close tag distance 5, 170
door_close
container sound  
sound tag 0 coupling_1.wav
mesh-table container load  
load tag mesh Gondola_body/Load/Load.im
load tag anim Gondola_body/Load/Load.kin
load tag auto-create 1
load tag use-parent-bounds 1
load container effects  
effects container product-texture  
product-texture tag kind texture-replacement
product-texture tag texture load.texture

traincar

container queues  
queues container load0  
load0 tag size 101819
load0 tag initial-count 0
load0 tag animated-mesh load

load0

tag product-kuid Coal
load0 container allowed-categories  
allowed-categories tag 0 Bulk Load
traincar container smoke0  
smoke0 tag attachment a.unload_pfx0
smoke0 tag mode time
smoke0 tag color 0,0,0,250
smoke0 tag rate 8
smoke0 tag velocity 2
smoke0 tag lifetime 2
smoke0 tag minsize 1
smoke0 tag maxsize 4
smoke0 tag enabled 0
traincar container smoke1  
smoke1 tag attachment a.unload_pfx1
smoke1 tag mode time
smoke1 tag color 0,0,0,250
smoke1 tag rate 8
smoke1 tag velocity 2
smoke1 tag lifetime 2
smoke1 tag minsize 1
smoke1 tag maxsize 4
smoke1
tag enabled 0

 

If you are unable to follow the above table then you can open the config.txt file in a text editor and add the following items in the left hand column. Items that should already be present are in red.

script "Hopper" This tells TRS the name of the script file
class "Hopper" This tells TRS the class referenced by the script.

soundscript {
  door_close {
    trigger door_close
    nostartdelay 1
    repeat-delay 1
    distance 5, 170
    sound {
      coupling_1.wav
    }
  }
}

This is the sound effects that are played when the unloading sequence is played.
mesh-table {
  default {
    mesh Gondola_body/Gondola_body.lm
    auto-create 1
  }
This tells TRS2004 where to find the main body mesh. NOTE In this example this entry points to a level of detail file.
  shadow {
    mesh Gondola_shadow/Gondola_shadow.im
  }
This tells TRS2004 where to find the shadow file.

  load {
    mesh Gondola_body/Load/Load.im
    anim Gondola_body/Load/Load.kin
    auto-create 1
    use-parent-bounds 1

This is where you type in the location of the load.im mesh file that you just created. It is critical that you type in the path name and the file name exactly. TRS2004 is case sensitive so you must type in any capitals that you have in the path or filename.

Auto-create means that the mesh is created as soon as the main body is created.

use -parent-bounds is a JET workaround.

    effects {
      product-texture {
        kind texture-replacement
        texture "load.texture"
      }
    }
  }
}

The effects section allows for extra effects to be added to the mesh.

Product-texture allows the coal texture to be replaced by a woodchip or other type of load texture when an industry that supports it is accessed. This requires the next section to reference the types of load the gondola will accept.

queues {
  load0 {
    size 101819
    initial-count 0
    animated-mesh load
    product-kuid <KUID:44179:60013>
    allowed-categories {
      0 <KUID:-3:10040>
    }
  }
}

This is the section where you need to tell TRS2004 the size of the gondola in liters and also the default product-kuid the gondola will accept. In this case it is setup to accept coal as the default load. In the allowed-categories section you need to add all the types of load that the gondola will accept. In this case it is set to accept Bulk Load which is basically any type of loose load.i.e Sand, woodchip, gravel, coal,etc
smoke0 {
  attachment a.unload_pfx0
  mode time
  color 0,0,0,250
  rate 8
  velocity 2
  lifetime 2
  minsize 1
  maxsize 4
  enabled 0
}
smoke1 {
  attachment a.unload_pfx1
  mode time
  color 0,0,0,250
  rate 8
  velocity 2
  lifetime 2
  minsize 1
  maxsize 4
  enabled 0
}
In this section you need to add the effects displayed when the gondola is unloaded. Make sure you specify the attachment point for the particle effects. Also the attachment points must begin with a. and end with _pfx0 (index the 0 for each additional attachment point).


Once you have the config.txt file setup properly then you need to create a script file with the following information included.

include "vehicle.gs"
class Hopper isclass Vehicle
{

This is required information that tells TRS2004 the name of the script file referenced and also the class of the script.

float BeginLoad(LoadingReport report)
{
Asset meAsset = GetAsset();
World.PlaySound(meAsset, "coal_load1.wav", 1000.0f, 20.0f, 1000.0f, me, "");
return 0.0;
}
This is the loading sequence. This will play a sound when the loading begins.

float BeginUnload(LoadingReport report)
{
SendMessage(me, "pfx", "+0+1");
Asset meAsset = GetAsset();
World.PlaySound(meAsset, "coal_dump1.wav", 1000.0f, 20.0f, 1000.0f, me, "");
return 1.0;
}
This is the begin unloading sequence. In this section you can play sounds and also specify an animation event to occur such as the opening of the doors. It also tells TRS2004 to begin the creation of particle effects. This is where the name of the attachment point is required. The pfx in this section references the pfx in the attachment name and the +0+1 references the number on the end of the attachment name. You can also specify other things to happen here such as texture replacement.

float EndUnload(LoadingReport report)
{
Sleep(1.0);
SendMessage(me, "pfx", "-0-1");
return 1.0;
}
};
This is the end unloading sequence. In this section you can play sounds and also specify an animation event to occur such as the closing of the doors. Attachment points see previous section.

There are many different methods for the creation of the load and you should use whatever method suits your situation the best. There are also different methods to hide the load mesh. The above method works best for a gondola with straight ends. If you have a hopper that tapers as it empties then you will need to break the plane up into smaller pieces and animate them so that as the load empties the pieces move together so that they overlap otherwise as the hopper empties the load will be visible outside of the hopper.

NOTE If copying and pasting from this tutorial please make sure that the correct quotes are copied. Using the wrong type of quotes such as those used in Word will cause errors.

 

Was this tutorial helpful? Not enough or too much detail? Points not explained properly? Suggest any improvements? Please use the Tutorial Enquiry Form

 

 

Trainz and Trainz Railroad Simulator are trademarks of Auran

Best viewed at 1024 x 768 or higher

Pages best viewed with Cooper and Cooper Black font installed.

Copyright © 2007 P. Campbell. All rights reserved. Revised: June 13, 2007