LM.txt file

From TrainzOnline
(Difference between revisions)
Jump to: navigation, search
(LM.txt details from CCGTC, with amendments, added)
m (Breakdown of LOD Mesh File)
 
(25 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[LM.txt file]]s are ASCII text format files describing a single model with multiple levels of detail. [[LM.txt file]]s 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.
+
'''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.
  
  
 
==Usage==
 
==Usage==
''(taken from CCGTC with amendments by PEV)''
 
  
 +
[[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 file]]s provide one LOD technique, which is commonly used for [[KIND Traincar]] and [[KIND Bogey]] assets. For other asset types, other [[Level of Detail|LOD techniques]] are generally more suitable.
  
'''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.
+
In the example of the PB15 loco below there are four meshes, the closest being a highly detailed [[normal map]]ped 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)'' 
  
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.
  
For TS2009, do not have 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 file]]s only (exported from [[Autodesk 3DS Max]], Blender, etc.)
  
LM.txt files should be used for rolling stock models.  Other items like scenery (building and trees) using mesh stitching will work better with the lod-model specified in the config.txt.  ''TBD: LM vs lod-model''
+
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.
 
+
Assets with LOD reduction must be made with 'indexed meshes' or .im files only (exported from GMax, 3dsMax or Blender). No .pm files are used in LOD.
+
 
+
Trainz looks for these .im files through an .lm.txt (LOD mesh file) which is referenced via the asset's config.txt file.
+
  
  
 
The following images show the four meshes used for the PB15 loco.
 
The following images show the four meshes used for the PB15 loco.
  
Note: Only Figure 4 the hi-res version is bump-mapped.
+
Note: Only Figure 4, the hi-res version, is normal-mapped.
''Bump mapping will be ignored if the graphics card does not support it.''
+
  
  
Line 47: Line 42:
 
[[Image:Lod4_PB15.jpg]]
 
[[Image:Lod4_PB15.jpg]]
 
PB_15_body.im
 
PB_15_body.im
(10578 polys, and bump-mapped)
+
(10578 polys, and normal-mapped)
  
  
Line 53: Line 48:
  
 
==File Format==
 
==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 file]]s and [[IM files]].  Only English apha-numeric characters (A to Z, a to z, and 0 to 9) plus dash and underscore should be used.
+
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 file]]s and [[IM files]].
  
  
Line 65: Line 60:
 
==An LM.TXT Example==
 
==An LM.TXT Example==
 
<br>
 
<br>
===LOD Mesh File (PB_15_body.lm.txt) Auran's steam loco:===
+
'''LOD Mesh File (PB_15_body.lm.txt) Auran's steam loco:'''
 
  version 1.0<br>
 
  version 1.0<br>
 
  offset = 0.01;
 
  offset = 0.01;
Line 108: Line 103:
 
  attachmentCutOff = 0.06; ''The level where Cull flagged attachments are dropped (to screen width) *See note below''
 
  attachmentCutOff = 0.06; ''The level where Cull flagged attachments are dropped (to screen width) *See note below''
 
            
 
            
  ''                        Note:'' Meshes are referenced within a LOD file must be in ascending width order.
+
  ''                        ''' Note:''' Meshes referenced within a LOD file must be in ascending width order.''
 
          
 
          
 
  mesh("0.07")
 
  mesh("0.07")
 
  {
 
  {
 
  name="PB_15_body_lowest.im";
 
  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.''  
 
  ''                        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 ''
 
  ''                        Note the figure is just bigger than the attachment cut off figure above.  This ensures the ''
Line 134: Line 130:
 
        
 
        
 
'''''Note:'''''<br>
 
'''''Note:'''''<br>
'''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 GMax, 3dsMax,  or Blender. (ie "a.bog0:Cull" ).  This can apply to any attachment eg passenger or driver attachments.
+
'''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
 
Where the above applies (bogeys culled) the body mesh will need a low poly representation of the bogeys, as in '''Figure 1''' above
Line 140: Line 136:
 
Attachment culling cannot be made to work by modifying the config.txt file; you must modify the model's attachment names.  
 
Attachment culling cannot be made to work by modifying the config.txt file; you must modify the model's attachment names.  
  
 +
'''''Note:'''''<br>
 +
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.
  
Keep in mind all LOD files, .im meshes, and textures must be located within the same directory. In the case of a locomotive or rolling stock item, it should be in the *_body directory (if using TRS2004 conventions).
+
**** 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:'''''<br>
 +
The [[LM.txt file]]s, .im meshes, and textures must be located within the same directory.
  
  
Line 149: Line 150:
  
 
  kuid <KUID:-3:10024>
 
  kuid <KUID:-3:10024>
  kuid-table {
+
  kuid-table
            }
+
{
  obsolete-table {
+
}
      }
+
  obsolete-table
 +
{
 +
}
 
  mesh-table
 
  mesh-table
 
  {
 
  {
 
  default
 
  default
 
  {
 
  {
   mesh PB_15_body/PB_15_body.lm          <---- ''Note the "lm" file extension here''
+
   mesh "PB_15_body/PB_15_body.lm"         <---- ''Note the "lm" file extension here (lowercase of "LM")''
 
   auto-create 1
 
   auto-create 1
 
  }
 
  }
 
  shadow
 
  shadow
 
  {
 
  {
   mesh PB_15_shadow/PB_15_shadow.im
+
   mesh "PB_15_shadow/PB_15_shadow.im"
 
  }
 
  }
 
  reverser
 
  reverser
 
  {
 
  {
   mesh PB_15_body/reverser/reverser.im
+
   mesh "PB_15_body/reverser/reverser.im"
   anim PB_15_body/reverser/reverser.kin
+
   anim "PB_15_body/reverser/reverser.kin"
 
   auto-create 1
 
   auto-create 1
 
   att a.bog2
 
   att a.bog2
   att-parent default       }
+
   att-parent default
 
  }
 
  }
  
 
+
==.txt file extension==
 
+
=.txt file extension=
+
 
[[LM.txt file]]s 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"''.  
 
[[LM.txt file]]s 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"''.  
  
''TBD: LM vs lod-model''
+
[[Category:File formats]]
 
+
[[Category:Modeling]]
[[Category: File formats]]
+

Latest revision as of 11:20, 19 March 2022

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

[edit] 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)



[edit] 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.



[edit] 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"; }

[edit] 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
}

[edit] .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