LM.txt file

From TrainzOnline
Jump to: navigation, search

LM.txt files are ASCII text format files describing a single model with multiple levels of detail. LM.txt files have a ".LM.txt" name extension, however when a LM.txt file is specified within a config.txt file or similar, the ".txt" must be omitted, leaving the ".LM" extension.


Contents

Usage

Level of Detail (or 'LOD') is a technique used for asset mesh reduction. Trainz uses a different mesh dependant on the viewing distance. For objects further away a simpler, less detailed mesh is used. LM.txt files provide one LOD technique, which is commonly used for KIND Traincar and KIND Bogey assets. For other asset types, other LOD techniques are generally more suitable.

In the example of the PB15 loco below there are four meshes, the closest being a highly detailed normal mapped model of the loco body, and the farthest being a simple mesh of the shape with the texture and, in this case, with very simple low poly representations of the bogeys. (more on this below)

Do not use separate textures for each LOD mesh; the same texture can be used for all because textures have their own built-in LOD reduction.


Assets with LOD reduction must be made with IM files or trainzmesh files only (exported from Autodesk 3DS Max, Blender, etc.)

Trainz locates these mesh files through paths specified in the .lm.txt (LOD mesh file) which is in turn referenced via the asset's config.txt file.


The following images show the four meshes used for the PB15 loco.

Note: Only Figure 4, the hi-res version, is normal-mapped.


Figure 1 Lod1 PB15.jpg PB_15_body_lowest.im (600 polys) bogey attachments flagged ':Cull', bogeys represented in mesh (see below)


Figure 2 Lod2 PB15.jpg PB_15_body_low.im (1947 polys)


Figure 3 Lod3 PB15.jpg PB_15_body_med.im (5066 polys)


Figure 4 Lod4 PB15.jpg PB_15_body.im (10578 polys, and normal-mapped)



File Format

The user-editable *.lm.txt files are ASCII text formatted . Please note that this format is not the same (despite some similarities) as other text-based formats used by Trainz. Please be aware of the filename character restrictions when naming LM.txt files and IM files.


Use only non-formated text to create the .lm.txt file i.e. Use a simple text editor such as notepad.

The use of upper and lower case letters, and semi colons in the file data is important, please follow the example.



An LM.TXT Example


LOD Mesh File (PB_15_body.lm.txt) Auran's steam loco:

version 1.0
offset = 0.01; calcpoint = center; multiplier = 1.0; animationCutOff = 0.00; renderCutOff = 0.00; attachmentCutOff = 0.06; mesh("0.07") { name="PB_15_body_lowest.im"; } mesh("0.30") { name="PB_15_body_low.im"; } mesh("0.52") { name="PB_15_body_med.im"; } mesh("1.0") { name="PB_15_body.im"; }

Breakdown of LOD Mesh File

version 1.0              must be included but for internal use only;leave value as 1.0
                             
offset = 0.01;           The offset that prevents "popping" between two levels of of detail repeatedly
         
calcPoint = center;      The position where the level of detail is calculated from (center,near,far)
          
multiplier = 1.0;        A level of detail multiplier (leave as 1.0)
             
animationCutOff = 0.0;   The level of detail where animation stops
                         (to screen width) 1.00 = full width,
                         0.5 = half screen, 0.00 = never stop animation
       
renderCutOff = 0.0;      The level (to screen width) where rendering stops (no longer visible)
       
attachmentCutOff = 0.06; The level where Cull flagged attachments are dropped (to screen width) *See note below
          
                          Note: Meshes referenced within a LOD file must be in ascending width order.
        
mesh("0.07")
{
name="PB_15_body_lowest.im";
}
                         When the mesh is displayed at 0.07 of the screen, the mesh "PB_15_body_lowest.im" is displayed. 
                         Note the figure is just bigger than the attachment cut off figure above.  This ensures the 
                         modeled bogeys in this LOD mesh are rendered before the actual bogeys are culled.
     
mesh("0.30")
{
name ="PB_15_body_low.im";
}
                         mesh "PB_15_body_low.im" is displayed when the mesh is at 0.3 of screen width.
  
mesh("0.52")
{
name = "PB_15_body_med.im";
}
   
mesh("1.0")
{
name = "PB_15_body.im";
}
      

Note:
attachmentCutOff = 0.1; Attachment cutoff specifies the level where attachments with the flag ":Cull" are dropped. ie To stop drawing the bogeys of the trains at a specific level of detail, append ":Cull" to the bogey attachment point name in 3DSMax, or Blender. (ie "a.bog0:Cull" ). This can apply to any attachment eg passenger or driver attachments.

Where the above applies (bogeys culled) the body mesh will need a low poly representation of the bogeys, as in Figure 1 above

Attachment culling cannot be made to work by modifying the config.txt file; you must modify the model's attachment names.

Note:
As of build 4.1 an alternative to the use of the ":Cull" appendage to the attachment point name is to simply omit the attachment point from the lower-detail mesh. If the attachment point does not exist in the mesh then no attempt is made to render an attachment when the mesh is rendered. It is possible to use the cull method and the missing attachment point method in the same asset, which might be relevant when creating a new low-detail mesh for an existing asset.

        • in trying this method on trainz2019 all attachments present in the first lod remain "active" in all other lod levels regardless of rather or not they are present in later levels. i.e. If you have a mesh attached to attachment "a.door" in Lod0 and you omit attachment "a.door" from the lower level lods the attached mesh will still appear at that attachment in those levels as if the attachment is still there... may be a bug********

Note:
The LM.txt files, .im meshes, and textures must be located within the same directory.


The LOD Mesh file is referenced from the config.txt file as follows.

Config.txt file extract
kuid <KUID:-3:10024>
kuid-table
{
}
obsolete-table
{
}
mesh-table
{
default
{
  mesh "PB_15_body/PB_15_body.lm"          <---- Note the "lm" file extension here (lowercase of "LM")
  auto-create 1
}
shadow
{
  mesh "PB_15_shadow/PB_15_shadow.im"
}
reverser
{
  mesh "PB_15_body/reverser/reverser.im"
  anim "PB_15_body/reverser/reverser.kin"
  auto-create 1
  att a.bog2
  att-parent default
}

.txt file extension

LM.txt files have a ".LM.txt" name extension, however when a model file is specified within a config.txt file or similar, the ".txt" must be omitted, leaving the ".LM" extension. For example, a model file named box.LM.txt is specified in a KIND Traincar config file using the syntax mesh "box.lm".

Personal tools