Saturday, March 14, 2020

Using PBR and UVmaping

You now need to assign a PBR material to your mesh. How you assign depends on what program you use, so you will have to look that part up.
 
Trainz has only 5 material types but for roiling stock I have never used more than 3.
 
TRS19 only uses PBR all older content get converted to PBR, this takes up very little room, one common normal map, one common pbr map per old texture type, and one green and white texture used for all missing textures, this is why you get green/white mesh from FBX. Note that if you have a missing texture in your PBR it will get replaced with the green/white one (had this on last car with ARN as I missed one normal file and got numbers with a checker board look).
 
All PBR used for Trainz are metal/roughness and are ether a set of 10 or 11 data files used to color a mesh. The data is saved as 3 textures in RGB or RGBA as ether name.tga or name.png. At a power of 2, can be square or 1:8, max size is 2048x2048 aka 2K, a 4K will not give an error but will be downsized to 2K by CM.
 
Most used one. name.m.pbrmetal used for most things, metal, wood, plastic, rock and so on all on one material.
 
Name.m.pbrmetalmasked used the same as m.pbrmetal but has a Alpha channel used as a mask, has to be used to make ARN.
 
Name.m.glass used to make glass or other transparent things.
 
Name.m.pbrmetaldetail used to make finer detail, I have not used it as most of what I make dose not have finer detail, painted steel and painted wood.
 
Name.m.clutter only used to make clutter mesh, I have not used,
 
Good place to go to:http://online.ts2009.com/mediaWiki/index.php/Material_Types
 
Each texture has to have texture.txt with it, the Blender FBX exporter will make them but not right. best way to make is to copy a known working one, edit it and "save as".
what it look like:
 
File name: normalskin.tga
 
inside:
 
Primary=normalskin.tga
Tile=
 
File name: pbr.tga
 
inside:
 
Primary=pbr.tga
Alpha=pbr.tga
Tile=
 

My car has PBR textures set up just use skin.tga, normalskin.tga, and pbr.tga. This way you do not need to make the PBR textures yet, just edit them for now.
 
Next you need to make a UVmap, there are programs just for that and most 3D programs also have it built in. What it dose is flatten your mesh out, like unfolding a cardboard box so it is flat. This way you do not have the same data used for more than one pixel, very bad with PBR, did not mater in old way. Some times you can overlap where you can not see it from the out side. The size should be the same for all faces but you can be off up to about 2x.
 
What this looks like:
UVmap
 
skin.tga
 
skin with UVmap on top
 
As you can see this makes lettering a lot easer.
 
 
 
 
 
 
 
 

Wednesday, March 11, 2020

Making the Mesh

 
Some basic things about Trainz meshes.
Scale: Trainz uses a scale of 1:1, that's 1ft.=1ft.
3D space: +Z is up and -Y is the front and the "ground" base board is at Z=0 (note that no mater what shape the base board has it is always Z=0, this is why you can place a box on a hill side and have a gap at the bottom.
 
First thing that you need to make are some attachment points. All kind "traincar" have to have 5 attachment points, 4 of them you make and 1 is a default that you do not make, it's X=0,Y=0,Z=0, Trainz will use it as a fallback for some things others must have the right name.
So in order you must make  and name a.limfront, a.bog0, a.bog1, and a.limback. If the order is wrong you will get an Error it use to be a derail.
 
The two a.lim ones are the coupling bounding boxes that Trainz adds and the two a.bog are the bogeys and how the car/loco fallows the track. You can have any number of bogeys but the body will turn and fallow a,bog0 and a.bog1. (a.bog3, a.bog0, a.bog1, a.bog4) is good and (a.bog3, a.bog1, a.bog0, a.bog4) is not.
 
In Blender you add an Empty for FBX and name it.
 
Here are the names and xyz in feet/inches:
 
a.limfront  X=0, Y=-21'11", Z=2'9.6"
 
a.bog0      X=0, Y=-15'4", Z=1'4"
 
a.bog1      X=0, Y=15'4", Z=1'4"
 
a.limback X=0, Y=21'11", Z=2'9.6"
 
Note that all have X=0 as in Trainz the trains only "see" the center line of the track and the bogeys fallow that. My bogeys are set up so that the center of the wheels is at Z=0 so the attachment point is one half the diameter of the wheel, 33"/2=16.5" rounded off to 16".

Next make a box, size about 10'x10'x40' centered at X=0, Y=0 and the bottom at Z=3'4.94".
You can now export the box and the 4 attachments as FBX into your work folder saved as 40ft_boxcar_body.fbx. You can then import into CM, "submit edit" and it should be a working boxcar, the top will be green and white.
 
 

Monday, March 9, 2020

Setup
 
I am going to show how to simplify the config and the work file.
 
Blue is what was done in last post, RED is to be deleted.
 
 
username                                "40ft PRR X31b boxcar"
kind                                    "traincar"
mass                                    20657
engine                                  0
enginespec                              <kuid:-1:42004201>
category-class                          "XB"
description                             " 40ft 50ton boxcar as used by Pennsylvania RR, Class X31b, built 1939.This car has seaeon snow."
author                                  "Whitepass"
contact-email                           "
whitepasstrainz@gmail.com"
license                                 "n/a"
category-region                         "CA;US"
category-era                            "1930s;1940s;1950s;1960s"
trainz-build                            4.6
fonts                                   1
fonts-path                              "car"

use-coupler-sounds                      1
mesh-table-lod-transition-distances 

season-selector
{
  season-range                          0.25,0.75
 
  branch-true
  {
    season-range                        0.25,0.5
   
    branch-true
    {
      output-season                     0
    }
   
    branch-false
    {
      output-season                     1
    }
  }
 
  branch-false
  {
    output-season                       0
  }
}
vehicle-running-numbers
{
  running-numbers                       "61100-62770"
}
thumbnails
{
  0
  {
    image                               "boxcarprr.jpg"
    width                               240
    height                              180
  }
 
  1
  {
    image                               "40ft_boxcar_art/40ft_boxcar_art_icon.tga"
    width                               128
    height                              64
  }
}
mesh-table
{
  default
  {
    mesh                                "40ft_boxcar_body/40ft_boxcar_body.lm"
    auto-create                         1
  }
 
  fram
  {
    mesh-asset                          <kuid:58422:100060>
    mesh                                "frame.lm"
    auto-create                         1
  }
 
  winter
  {
    mesh                                "winter/snow.lm"
    auto-create                         1
    mesh-season                         1
  }
 

}
queues
{
  load
  {
    size                                7
    initial-count                       0
    product-kuid                        <kuid:-3:10013>
   
    allowed-products
    {
      0                                 <kuid:-3:10013>                                              
      1                                  <kuid2:30671:9040500:1>
      2                                 <kuid2:30671:9040690:1>
      3                                 <kuid2:30671:9080810:1>
      4                                 <kuid2:30671:9080510:1>
      5                                 <kuid2:30671:98702901:1>
      6                                 <kuid2:30671:94805601:1>
    }
  }
}
bogeys
{
  0
  {
    bogey                               <kuid:58422:100464>
    reversed                            0
  }
}

kuid-table
{
  0                                     <kuid:58422:100464>
  1                                     <kuid2:30671:9040500:1>
  2                                     <kuid2:30671:9040690:1>
  3                                     <kuid2:30671:9080810:1>
  4                                     <kuid2:30671:9080510:1>
  5                                     <kuid2:30671:98702901:1>
  6                                     <kuid2:30671:94805601:1>
  7                                     <kuid:-1:42004201>
  8                                     <kuid:-3:10013>
 
  9                                     <kuid:58422:100060>
}
kuid                                    <kuid:58422:100463>
 
 
We will be putting most of this back, why you made a backup.
 
What your work folder should look like:
 
Delete the folder "car_alpha_numbers".
 
Open the folder named "40ft_boxcar_body" shown below and delete all red files.


Next open the file "40ft_boxcar_body.lm.txt" see below.

version 1.0
offset=0.01;
calcPoint=center;
multiplier=1.0;
animationCutOff=0.00;
renderCutOff=0.00;
attachmentCutOff=0.1;

mesh("0.01")
{
name="xx_boxcar_body.trainzmesh";
}
mesh("0.4")
{
name="low40ft_boxcar_body.trainzmesh";
}

mesh("0.8")
{
name="med40ft_boxcar_body.trainzmesh";
}

mesh("1.0")
{
name="40ft_boxcar_body.trainzmesh";
}
 
Delete the red and save.
Last thing is to rename the mesh file "40ft_boxcar_body.trainzmesh" to "40ft_boxcar_body.fbx"
Windows will give you warning about changing file type that is what you are doing.
DO NOT TRY TO IMPORT to CM at this time, you need to make two FBX mesh's first.
 


Sunday, March 8, 2020

Replacing the bogeys.

 
The PRR boxcar has odd bogeys so we will replace with  KUID2:58422:1025:7 the most common kind.
Trainz bogeys are setup two ways, wheel center at Y=0 (what you should do) or Y=-diameter of wheel(rail head), both work the same.
 
All you need to do is edit the config.txt.
 
Old config.txt at the bottom:

bogeys
{
  0
  {
    bogey                               <kuid:58422:100464>
    reversed                            0
  }
}

kuid-table
{
  0                                     <kuid:58422:100464>
  1                                     <kuid2:30671:9040500:1>
  2                                     <kuid2:30671:9040690:1>
  3                                     <kuid2:30671:9080810:1>
  4                                     <kuid2:30671:9080510:1>
  5                                     <kuid2:30671:98702901:1>
  6                                     <kuid2:30671:94805601:1>
  7                                     <kuid:-1:42004201>
  8                                     <kuid:-3:10013>
  9                                      <kuid:58422:100060>
}

Just replace the RED text with <kuid2:58422:1025:7>

To edit you can start CM find the car and do an "Open/ Edit Config File Text". Then do a "Submit Edit". If you do not have that bogey installed CM will download it as it is on the DLS, you get two files.

Every thing in the kuid-table is what the car needs to work and all can be replaced by things on the DLS or Built-in, do not use payware as if you do only ones who can use your content are the ones who have the same payware. Using content from the internet bad as finding it can be a pain and it could end up unavailable. If you plan to us the DLS all content must be on it or Built-in.



Saturday, March 7, 2020

How to make a US 40ft car

Using FBX and PBR
should work with most 3D and Paint programs.
 
 
You will need TRS19 or newer, a 3D program that can export FBX and any paint type program that has layers and channels.
 
 
First thing is to download this: kuid:58422:100463 (this is the newest boxcar I have made)
 
You can use this as a template for a 40ft car, it can be a box, stock, reefer, flat or gondola. This car was made with the under frame as a mesh library so you can use it and only need to make the body so you can make just a test box and see it as a railroad car.
 
 
Next make a folder for all your work, I used "New trainz to be made". I have subfolders for each type car or loco where I keep all drawings, photos, mesh and paint saves, and copy's of the file that will go into Trainz.
 
Next in Trainz CM find kuid:58422:100463:
 
 
Next you Clone my car:
This gives you a copy of my car with your KUID number. It will not show yet as it is open for edit.
Now you do first edit of config.txt.
 
This will open the config.txt for editing. change the fallowing that are in red:
 
username                                "40ft PRR X31b boxcar"
 
author                                  "Whitepass"
contact-email                       "whitepasstrainz@gmail.com"
 
Save and close then do a "Submit edits" and you then have a new username, author, and email(yours). Your new content will show up in CM under "Today". Next is to copy to your hard drive by "Open"/"Open in Explorer" (do not know what for Mac). You go up one level in Explorer so you see the new content, it will have the new KUID number in front of the new username. Copy this file to your hard drive into the work folder you made. Then add it one more time, Windows will add a -copy2 to the end, this is a backup copy you will be using.