File Formats

From LFS Manual
Revision as of 14:23, 23 June 2009 by Flame CZE (talk | contribs) (→‎LYT)
Jump to navigationJump to search

DDS

Dds.jpg

Texture files

So you want to edit LFS files that are in DDS format? Several textures in LFS are in DDS format including lights, interiors, track signage, seats, steering wheels and several other game and car components. To customise some textures in LFS You will need to edit the appropriate DDS file. DDS files can be handled by Paint Shop Pro and Photoshop after installing the DDS plugin which can be found here:
http://developer.nvidia.com/object/nv_texture_tools.html

Although these files are hosted by Nvidia, they are not GPU-specific, so you can use them with any brand card. You don't need all of the files shown on that site. You can download a DDS viewer which can enable thumbnails in windows explorer or my computer and view them easily. There are various viewers available and all seem to work well enough. Grab the plugin if you want to edit DDS with one of the programs mentioned above.

The DDS files can be found in your LFS/data/dds folder. There are a few things to be aware of before you begin:

  • Once you have changed the DDS file all of the cars of that type will show that file, the texture is used universally. For example, if you customised the interior of the XF GTi, then all XF GTi's in your sim will have the customised interior. Unlike you car skin, these files are used on every car of that type.
  • Be wary of texture size. Yes I know, you've got a fast PC and it can do anything except make your bed, but still be wary of texture size. The default textures in LFS work very well, replacing a 30KB texture with a 300KB texture will use more resources. It is very easy to overdo it so be sensible and back up your files first.
  • When you save your customised file you will probably be presented with some complicated save options. Just try the default settings, in other words: don't worry too much about all the bells and whistles. If the option to generate mip maps is not selected then select it first but it should be on by default in most cases.
  • There is a plugin that you will need and it works for Adobe Photoshop and Jasc (recently purchased by Corel) Paint Shop Pro only. Both of these programs use the same plugin file. There is a 3DS MAX plugin too, but MAX users check your version first to see if the plugin is even required.

Please note that DDS files use an alpha layer in many cases. If you don't know what that means I suggest you consult your software's documentation and try experimenting with the DDS format files.

Remember to save your files back into DDS format!

PTH

Path nodes are a series of points with direction and width that describe the track that you drive along. LFS uses it to watch your progress along the track, decides if you are driving in reverse. They provide the data for the echoes and the lightmaps, hold information about which objects you can see from that point, define the left and right boundaries for the AI drivers and are also used in yellow and blue flag systems, the position list, timing and some other things. Their length is not constant but there is approximately 0.2 seconds of time between passing one node and the next, when you are driving at a reasonable speed.

TXT

Language Files

Thanks to Eold, we have a translation utility program which makes it easier to make language packs. See the enclosed README.txt for more information.
http://www.lfs.net/file_lfs.php?name=LFSTranslator.zip

SET

Thanks to colcob for originally working this format out for v0.3H ([1]), Bob Smith for updating it for v0.5P([2]), Woz for updating the bit field values for passengers, and back to Bob Smith for updating it for v0.5X/Y.

TYPES :
== LYT ==
These are Layout files, and govern how things are set out on an AutoX track. You will notice that on some tracks you find a limit to the number of objects you can add; this is a limitation in the LFS engine. It is believed (although untested) that this has not significantly changed since S1 ([http://forum.rscnet.org/showthread.php?t=185896]).
<pre>TYPES :
=======

1) short : 16 bit signed integer
2) word  : 16 bit unsigned integer
3) char  : 8 bit signed integer
4) byte  : 8 bit unsigned integer

FILE DESCRIPTION :
==================

num   unit    offset  description
---   ----    ------  -----------

HEADER BLOCK :

6     char    0       LFSLYT              : do not read file if no match
1     byte    6       version             : do not read file if > 0
1     byte    7       revision            : do not read file if > 247
1     word    8       num added objects   : number of OBJECT BLOCKS
1     byte    10      laps                : number
1     byte    11      spare byte          : zero
......OBJECT BLOCKS

OBJECT BLOCK :

1     short   0       X                   : position (1 metre = 16)
1     short   2       Y                   : position (1 metre = 16)
1     char    4       Zchar               : approximate height (1 metre = 4) - see NOTE4 below
1     byte    5       Flags               : 0 for objects - see NOTE1 below
1     byte    6       Index               : object (see existing LYT files, NOTE3 below)
1     byte    7       HeadingByte         : see NOTE2 below

NOTE1 :
-------
Flags byte is always zero for actual objects.

For start positions or checkpoints, it is always non-zero.

The bits (0 to 7) are arranged like this (bit 0 is the lowest bit) :

bits 0 to 1 : 0 = Start position / 1 to 3 = Checkpoint index
bits 2 to 5 : Checkpoint width in metres (shifted left by 2 bits)
bit 6 : never set
bit 7 : always set (0x80)

NOTE2 :
-------
HeadingByte represents 360 degrees in 256 values.

HeadingByte = (heading + 180) * 256 / 360

128 : heading of zero
192 : heading of 90 degrees
0   : heading of 180 degrees
64  : heading of -90 degrees

NOTE3 :
-------
Objects indexes allowed by tracks.

* Autocross track :
TYRES (white)   : 0
TYRES (red)     : 1
post1           : 2
TYRES2 (white)  : 3
TYRES2 (red)    : 4
TYRES (white)   : 19
bale1           : 23
AD_banner1      : 24
Banner_AD2      : 25
Banner_AD3      : 27
CONE red        : 29
CONE red3       : 30
CONE blue       : 31
Cone yellow     : 32
Cone_pointer    : 33
CONE red2       : 34
CONE green      : 39
Barrier white   : 46
Barrier red     : 47
Barrier long    : 48
Sign keep left  : 49
Sign keep right : 58
arrow left      : 52
arrow right3    : 56
arrow left3     : 57
chalk line      : 59

* Blackwood track :
cone1           : 0
cone2           : 1
bale            : 3
tyre_white_s2   : 5
tyre_blue       : 6
railing         : 8
tyre_BLUE_L     : 14
tyre_GREEN_R    : 15
tyre_white_NEW1 : 26
tyre_BLUE_NEW   : 27
tyre_white_NEW2 : 31
tyre_BLUE_NEW2  : 32
ADBANNER_RSC    : 35
ADBANNER_cromo  : 36

* South City track :
Railing         : 4
cone1           : 17
cone2           : 18
tyre1_WHITE     : 21
tyre2_REF       : 22

* Fern Bay track :
cone1           : 0
old_tyre1       : 2
old_tyre2       : 3
old_tyre3       : 4
tyresstack1     : 10
tyresstack2     : 11
tyresstack3     : 12

NOTE4 : (from Scawen)
---------------------
ZChar is the approximate altitude, but LFS will do a collision test to position it accurately on the ground.
It can be anything from 4 metres underground to 6 metres above the ground and it will still work ok.
Why it's needed is so you can position objects under a bridge or on top of a bridge.
Because first it tests for the ground position along a line from 2 metres above the approximate height, down to
4 metres below the approximate height. If that fails then it tries a second test from 6 metres above
the approximate height, down to 4 metres below the approximate height.

LYT

These are Layout files, and govern how things are set out on an AutoX track. You will notice that on some tracks you find a limit to the number of objects you can add; this is a limitation in the LFS engine. It is believed (although untested) that this has not significantly changed since S1 ([3]).

TYPES :
=======

1) short : 16 bit signed integer
2) word  : 16 bit unsigned integer
3) char  : 8 bit signed integer
4) byte  : 8 bit unsigned integer

FILE DESCRIPTION :
==================

num   unit    offset  description
---   ----    ------  -----------

HEADER BLOCK :

6     char    0       LFSLYT              : do not read file if no match
1     byte    6       version             : do not read file if > 0
1     byte    7       revision            : do not read file if > 247
1     word    8       num added objects   : number of OBJECT BLOCKS
1     byte    10      laps                : number
1     byte    11      spare byte          : zero
......OBJECT BLOCKS

OBJECT BLOCK :

1     short   0       X                   : position (1 metre = 16)
1     short   2       Y                   : position (1 metre = 16)
1     char    4       Zchar               : approximate height (1 metre = 4) - see NOTE4 below
1     byte    5       Flags               : 0 for objects - see NOTE1 below
1     byte    6       Index               : object (see existing LYT files, NOTE3 below)
1     byte    7       HeadingByte         : see NOTE2 below

NOTE1 :
-------
Flags byte is always zero for actual objects.

For start positions or checkpoints, it is always non-zero.

The bits (0 to 7) are arranged like this (bit 0 is the lowest bit) :

bits 0 to 1 : 0 = Start position / 1 to 3 = Checkpoint index
bits 2 to 5 : Checkpoint width in metres (shifted left by 2 bits)
bit 6 : never set
bit 7 : always set (0x80)

NOTE2 :
-------
HeadingByte represents 360 degrees in 256 values.

HeadingByte = (heading + 180) * 256 / 360

128 : heading of zero
192 : heading of 90 degrees
0   : heading of 180 degrees
64  : heading of -90 degrees

NOTE3 :
-------
Objects indexes allowed by tracks.

* Autocross track :
TYRES (white)   : 0
TYRES (red)     : 1
post1           : 2
TYRES2 (white)  : 3
TYRES2 (red)    : 4
TYRES (white)   : 19
bale1           : 23
AD_banner1      : 24
Banner_AD2      : 25
Banner_AD3      : 27
CONE red        : 29
CONE red3       : 30
CONE blue       : 31
Cone yellow     : 32
Cone_pointer    : 33
CONE red2       : 34
CONE green      : 39
Barrier white   : 46
Barrier red     : 47
Barrier long    : 48
Sign keep left  : 49
Sign keep right : 58
arrow left      : 52
arrow right3    : 56
arrow left3     : 57
chalk line      : 59

* Blackwood track :
cone1           : 0
cone2           : 1
bale            : 3
tyre_white_s2   : 5
tyre_blue       : 6
railing         : 8
tyre_BLUE_L     : 14
tyre_GREEN_R    : 15
tyre_white_NEW1 : 26
tyre_BLUE_NEW   : 27
tyre_white_NEW2 : 31
tyre_BLUE_NEW2  : 32
ADBANNER_RSC    : 35
ADBANNER_cromo  : 36

* South City track :
Railing         : 4
cone1           : 17
cone2           : 18
tyre1_WHITE     : 21
tyre2_REF       : 22

* Fern Bay track :
cone1           : 0
old_tyre1       : 2
old_tyre2       : 3
old_tyre3       : 4
tyresstack1     : 10
tyresstack2     : 11
tyresstack3     : 12

NOTE4 : (from Scawen)
---------------------
ZChar is the approximate altitude, but LFS will do a collision test to position it accurately on the ground.
It can be anything from 4 metres underground to 6 metres above the ground and it will still work ok.
Why it's needed is so you can position objects under a bridge or on top of a bridge.
Because first it tests for the ground position along a line from 2 metres above the approximate height, down to 4 metres below the approximate height.
If that fails then it tries a second test from 6 metres above the approximate height, down to 4 metres below the approximate height.

DRV

These files contain the data on the AI drivers. This format was "discovered" around 0.3G, and it is unknown if they have been changed recently ([4]).

TYPES :
=======

char : 1-byte ascii character
byte : 1-byte integer
word : 2-byte integer
int  : 4-byte integer, lowest byte first

FILE DESCRIPTION :
==================

num     unit    offset      description
---     ----    ------      -----------
6       char         0      SRAINM              : do not read file if no match
1       byte         6      unknown		: 0x00 ?
1       byte         7      unknown             : 0xF6 Version?
1       byte         8      num AIs             : Number of AI Names in that file?
3       byte         9      unknown             : 3 bytes unknown

AI Data: Repeat (num AIs) times.

24      char         0      Name                : AI's playername (Fill with 0x00)
8       char        24      Plate               : Numberplate label (Fill with 0x00)
1       byte        32      Gender              : 0x00 == Male, 0x01 == Female
3      	byte        33      unknown             : 3 bytes unknown

BANS

The file format of the bans file ([5]).

Notes :

The 64 bit "Time" values are obtained from GetSystemTimeAsFileTime.
Meaning : number of 100-nanosecond intervals since January 1, 1601.
One hour (HOUR_TIME) = 36000000000

Demo ban expiry : time - ban->Time > 12 * HOUR_TIME
Name ban expiry : time - ban->Time > ban->BanHours * HOUR_TIME

The bans are loaded into memory when :
- the program starts up.

The bans are saved to disk when :
- bans are cleared
- a new ban is added
- the program exits

file format
-----------
6 chars     LFSBAN
1 byte      0
1 byte      version (246 - do not read file if increased)
1 integer   num_demo_bans
[demo ban * num_demo_bans]
1 integer   num_name_bans
[name ban * num_name_bans]

demo_ban
--------
in_addr     IP address
__int64     Time

name_ban
--------
24 chars    user name
__int64     Time
integer     BanHours


Basic Setup Guide | Advanced Setup Guide | Technical Reference | League Racing Guide | Skin Tutorial | Autocross Editor | LFS Editor Guides | Hosting | File Formats | LFS Programming | Movie Tutorial | Scripting