Special Aircraft Service

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2 3 4 ... 50   Go Down

Author Topic: msh Binary format  (Read 110215 times)

0 Members and 1 Guest are viewing this topic.

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1536
msh Binary format
« on: March 17, 2014, 08:15:45 PM »

{Edit}

Putting download link here to match the format of the site.

http://stainlessbeer.weebly.com/downloads.html

Help file here.

http://stainlessbeer.weebly.com/uploads/3/2/9/6/3296541/help.7z

{/Edit}

Hi Guys,

Does anyone know the format of binary MSH files.

I want to write some more tools including a proper renderer for modders. I have easily worked out the text format, but the binary file is a bit obfuscated.

I tried using the latest MshConverter, but it crashes when I try to save as text.
Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1536
Re: msh Binary format
« Reply #1 on: March 22, 2014, 02:21:20 AM »

Making reasonable progress, but really need to know the binary format.

I can reverse engineer it if I have to, but it would be a lot quicker if anyone has already figured it out.




Logged

Epervier

  • 4.09 Guardian Angel !
  • SAS Team
  • member
  • Offline Offline
  • Posts: 9544
  • I'm French and Rebel_409! Nobody is perfect!
    • Some tinkering here
Re: msh Binary format
« Reply #2 on: March 22, 2014, 05:07:19 AM »

Does anyone know the format of binary MSH files.
:-[

I tried using the latest MshConverter, but it crashes when I try to save as text.
If you give same name of existed file... is normal !  ;)

If you manage to make a utility that converts a text-mesh in binary-mesh format... I build you a statue... statuette... wooden statuette... keychain...  :D  ;)
Logged
If your results do not live up to your expectations, tell yourself that the great oak was once an acorn too. - Lao Zi -

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1536
Re: msh Binary format
« Reply #3 on: March 22, 2014, 05:47:50 AM »

Okay, I guess I'll have to do it myself. No biggie.

Need some feed back, Have I overdone the glass shader ?

Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1536
Re: msh Binary format
« Reply #4 on: March 23, 2014, 07:31:00 AM »

It's been brought to my attention that other people have tried to reverse engineer the binary format in the past.

I'm making a lot of progress, so I thought I'd better record what I have found out so far in case it is of use to other people.

Some of this is probably already known, but I can't find any records, so I'll put it for posterity.





Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1536
Re: msh Binary format
« Reply #5 on: March 23, 2014, 07:32:40 AM »

File structure.


  • Header
  • Section List
  • Table 1
  • Table 2
  • Table 3
  • Data
Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1536
Re: msh Binary format
« Reply #6 on: March 23, 2014, 07:33:21 AM »

Header Structure

Code: [Select]
typedef struct Header
{
    Int32 Magicnumber;
    Int32 FileSize;
    Int32 NumberOfSections;
    Int32 Unknown;
    Int32 Table1Start;
    Int32 Table2Start;
    Int32 Table3Start;
};
Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1536
Re: msh Binary format
« Reply #7 on: March 23, 2014, 07:34:00 AM »

The section list is a list of strings. Each string is stored with a leading byte which is the number of characters in the string.

Table 1 is used to work out how many entries there are in each section. It is an array of structures. I have figured out most of it, but with a couple of issues.

Code: [Select]
typedef struct Table1Entry
{
    Int32 Offset;
    Int32 StartRecord;
    Int16 NumberOfRecords;
    Int16 Type;
};
Offset should start at 0, but it seems to start at 0x1c. It may be some kind of size instead.

Type seems to work this way.

Code: [Select]
0x0000   == String (or string plus value)
0x0002   == Accumulated short (used for lod distance table)
0x0101   == Bytes (used for face groups and face lists)
0x0004   == Vertex plus normal
0x0003   == Floats (shadow verts and UV coordinates)

I have no idea what table 2 is for yet

Table 3 starts with the file offset of the actual data.
Each Int32  after that is the size of the corresponding sub record.

So for the first record you look up it's name from the section list, you look at table 1 and you know it has 3 sub records. You look at table 3 and find the sizes of each of the sub records.

So an example look up.

Code: [Select]
Section[0] = "[Common]"
Table1[0]  = 0x001C,0x0000,0x0003,0x0000
Table3[0]  = 0x000C,0x0012,0x000D
Data
0x09,"NumBones",0x0000
0x0B,"FramesType",0x07,"Single"
0x0A,"NumFrames",0x0001

Everything matches up nicely except I don't know how the code can tell between a string and a string plus value. It might be hardcoded.

The LOD distance table is defined as an accumulation of shorts, doing the same exercise for the LOD table gives me

Code: [Select]
Section[1]="[LOD]"
Table[1] = 0x0026,0x0003,0x0004,0x0002
Table[3] = 0x0002,0x0002,0x0002,0x0002
Data
0x0028,0x0078,0x00FA,0x0258

Converting this to text gives you

Code: [Select]
[Common]
NumBones 0
 FramesType Single
 NumFrames 1

[LOD]
40
160
410
1010

Hope this helps
Logged

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1536
Re: msh Binary format
« Reply #8 on: March 25, 2014, 06:04:28 AM »

The face group is stored as an accumulation of bytes.

For example this table

Code: [Select]
27 20
0 0 27 0 20 0

will be stored as
Code: [Select]
27,-7
-20 0 27 -27 20 -20
Logged

Epervier

  • 4.09 Guardian Angel !
  • SAS Team
  • member
  • Offline Offline
  • Posts: 9544
  • I'm French and Rebel_409! Nobody is perfect!
    • Some tinkering here
Re: msh Binary format
« Reply #9 on: March 25, 2014, 06:53:47 AM »

Congratulations! I admire your perseverance!
Unfortunately I can not help you, I do not understand!
Good luck!
Logged
If your results do not live up to your expectations, tell yourself that the great oak was once an acorn too. - Lao Zi -

Stainless

  • Modder
  • member
  • Offline Offline
  • Posts: 1536
Re: msh Binary format
« Reply #10 on: March 28, 2014, 04:38:02 AM »

I have a couple of problems that I could do with some help with .

1) In the attached image you can see the propeller is not rendering correctly.

This is because it has tfNoWriteZ set, which is correct as it is transparent. So it doesn't write to the zbuffer. The engine behind it is drawn later. Since the propeller didn't write to the z buffer, the engine appears to be in front of the propeller.

Does this happen in the game? Or is it an error in the mod? I may have to detect the propellers and add code for that.




2) I have noticed a couple of sub objects that appear to be in the wrong place. You can see one in the image below. Is this my code or the mod?




Logged

just champi

  • Modder
  • member
  • Offline Offline
  • Posts: 608
Re: msh Binary format
« Reply #11 on: March 29, 2014, 03:50:35 AM »

HI Stainless, I find what you are doing very interesting, and I'd like to be able to helping you regarding your questions about binary .msh format, but I'm afraid that I lack the necessary knowledge. Regarding your other questions:

Quote
the engine appears to be in front of the propeller.

Does this happen in the game?

No this doesn't happen in the game. Propeller shows correctly in front of engine. Also rotating propeller shows different that in your images, as they are almost fully transparent and only the hint of the blurred blades is shown in the propeller disc.
Regarding the first issue, transparent materials always have the flag tfShouldSort activated, so maybe this has to do with the propeller being rendered in front of the engine. (just a wild guess)

Quote
I have noticed a couple of sub objects that appear to be in the wrong place. You can see one in the image below. Is this my code or the mod?

I can't tell for sure, but the black part in your images look like bits from a damaged part, also the left engine nacelle is showing a damaged texture, maybe it has to do with the plane being a bit of a franken, but haven't examined the model to be sure, maybe they are some leftover. Sorry to not be of more help, thanks for your work, and I hope you keep with it as it seems very well done.
Logged
Pages: [1] 2 3 4 ... 50   Go Up
 

Page created in 0.049 seconds with 28 queries.