The online racing simulator
.COL Color components
(5 posts, started )
.COL Color components
I did a quick pass through the .COL file and came up with this:


S2 .COL file specification.
---------------------------

TYPES :
=======
char: 1-byte ascii character
byte: 1-byte integer
int: 4-byte int

offset type number description
------ ---- ------ -----------
0 char 6 LFSCFG
6 byte 1 0
7 byte 1 Version byte (0.5P is 250)
8 char 15 filename (part between <CAR>_ and .JPG
23 byte 1 0
24 int 4 First Body ARGB color value
28 int 4 Second Body ARGB color value (only some cars)
32 int 4 Third Body ARGB color value (only UF GTR)
36 int 4 Fourth Body ARGB color value? (unused)
40 int 4 First Wheel ARGB color value
44 int 4 Second Wheel ARGB color value
48 int 4 Third Wheel ARGB color value? (unused)
52 int 4 Fourth Wheel ARGB color value? (unused)

Except that I seem have been a bit too fast on the trigger on the color values. I figured, since they were already 3 bytes followed by a 0 byte that just smelled a whole lot like ARGB ints. But when i load them up as ints and convert them to ARGB, the colors are all wrong. The values seem to just go from 0A (components at 0) to A0 (components maxed out).

Did a search here and RSC and couldn't really find anyone else having dug through this. anyone got a suggestion?

ether
Yeah, looking at it, they seem to just be individual R G and B bytes with values from 10-160 in decimal, with a zero byte to keep the file tidy.

I cant for the life of me think why he doesnt use the full 0-256 range of each byte, but I guess there must be a reason. For conversion purposes I guess you just need to scale your rgb value to be within that range.

Oh, and its not quite clear from the way you've written it, but the filename section is the filename of the skin, not of the col file. I'm sure you know that, but others might not realise.
Hrm... Ok, that's a strange arrangement for the color, but i'll go with that for now.. Here's the revised (and a lot wordier) file spec:


offset type number description
------ ---- ------ -----------
0 char 6 LFSCFG
6 byte 1 0
7 byte 1 Version byte (0.5P is 250)
8 char 15 filename of the skin associated to
the .COL file (part between <CAR>_ and .JPG
23 byte 1 0
24 byte 1 First Body Red Component (10-160)
25 byte 1 First Body Green Component (10-160)
26 byte 1 First Body Blue Component (10-160)
27 byte 1 0
28 byte 1 Second Body Red Component (10-160)
29 byte 1 Second Body Green Component (10-160)
30 byte 1 Second Body Blue Component (10-160)
31 byte 1 0
32 byte 1 Third Body Red Component (10-160) (only UFR)
33 byte 1 Third Body Green Component (10-160) (only UFR)
34 byte 1 Third Body Blue Component (10-160) (only UFR)
35 byte 1 0
36 byte 1 Unused Body Red Component (10-160) (only UFR)
37 byte 1 Unused Body Green Component (10-160) (only UFR)
38 byte 1 Unused Body Blue Component (10-160) (only UFR)
39 byte 1 0
40 byte 1 First Wheel Red Component (10-160)
41 byte 1 First Wheel Green Component (10-160)
42 byte 1 First Wheel Blue Component (10-160)
43 byte 1 0
44 byte 1 First Wheel Red Component (10-160)
45 byte 1 First Wheel Green Component (10-160)
46 byte 1 First Wheel Blue Component (10-160)
47 byte 1 0
48 byte 1 Unused Wheel Red Component (10-160)
49 byte 1 Unused Wheel Green Component (10-160)
50 byte 1 Unused Wheel Blue Component (10-160)
51 byte 1 0
52 byte 1 Unused Wheel Red Component (10-160)
53 byte 1 Unused Wheel Green Component (10-160)
54 byte 1 Unused Wheel Blue Component (10-160)
55 byte 1 0

Would be nice to be able to give the left wheels a different collor from the right wheels. Maybe that is the reason for the addition, unused bits?
We did have a quick debate on IRC, or it might have been the RSC forums, a little while ago. The general concensus was that the format was RGBA, with A being Alpha, but since LFS didnt/doesnt support it for certain items, it wasnt used.

It seems to be roughly the same format as S1. Sometime ago I was creating a little app (similar to AndyLec's), to edit col files externally - but he beat me to it. Heres the struct's I was using, if it will save anyone 10 seconds:
#define BYTE unsigned char

/* Original Struct - obselete, but here for historic reasons
struct lfs_cols_format
{
char lfscfg_text[8]; //LFSCFG gameversion gamerevision
char skin_name[16]; //prefixed with vehicle type, if default skin this is CAR_skin (.e.g RB4_skin)
BYTE body_red; //colours lower limit appears to be 10 and upper limit 180 (when typecasted to int).
BYTE body_green;
BYTE body_blue;
char wtf_one; //no idea what this is
BYTE hood_red;
BYTE hood_green;
BYTE hood_blue;
char wtf_two[9]; //no idea what this is either
BYTE wheelbody_red;
BYTE wheelbody_green;
BYTE wheelbody_blue;
char wtf_three; //no fscking idea
BYTE wheelrim_red;
BYTE wheelrim_green;
BYTE wheelrim_blue;
//NOTE: wtf_four and wtf_five are guesses, they could be combined, but that would give char of 9 bytes, which is an odd size..
char wtf_four; //no clue
char wtf_five[8]; //you've got me
};
*/

struct rgb_format
{
BYTE red;
BYTE green;
BYTE blue;
BYTE dummy; //probably alpha, but unused for LFS S1
};

struct lfs_cols_format
{
char lfscfg_text[8]; //LFSCFG gameversion gamerevision
char skin_name[16]; //prefixed with vehicle type, if default skin this is CAR_skin (.e.g RB4_skin)
rgb_format body;
rgb_format hood;
rgb_format wheel;
rgb_format wheelrim;
//unknown one and two appear to be unused for S1
rgb_format unknownone; //appears to be an unused colour
rgb_format unknowntwo; //also appears to be an unused colour
};


.COL Color components
(5 posts, started )
FGED GREDG RDFGDR GSFDG