1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FsX MDL format description

Discussion in 'Tools programming' started by arno, 14/1/07.

  1. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    I have put a page on the Wiki that describes the FsX MDL format. It is certainly not complete yet, but it contains the parts that I understand now and which allow me to read simple scenery objects.

    Hopefully it is also useful to others and if you know things not yet on the page, please feel free to update it.
  2. scruffyduck

    scruffyduck Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    17/9/05
    Messages:
    25,565
    Country:
    wales
    Thanks Arno :)
  3. theisomizer

    theisomizer

    Joined:
    15/1/07
    Messages:
    157
    Country:
    us-texas
    Hey Arno,

    I just updated the wiki page with a bit of my knowledge. Don't expect much :D , but it beats nothing at all. I have been hacking the MDL format since FS2002 so I will try to add as much info as possible as I slowly learn the internals of the FSX format.

    Cheers,
    Sean
  4. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    THANKS ARNO!!!, it is absolutly very GOOD NEWS!, had been searching for the new FSX MDL format, because some of my programs reads the old FS9 MDLs to get information for charts,...but now that FSX came out i cannt get this information....now im seeing some LIGHT AT THE END OF THE DARK TUNNEL lol :D....step by step ...:)


    ABSOLUTLY, usefull....hehe :D...AND THANKS AGAIN, Arno


    Best Regards,

    Manuel Ambulo
  5. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    Thanks Sean. Hopefully I can do some more tests with animated objects soon, so that I can update the relevant sections as I learn more.
  6. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    Thanks for the documentation Arno !

    Concerning the differences between aircraft and scenery MDL, are we really ready to swap from one type to another ?
    In aircraft.cfg files we can use the visual_model_guid command to use a library object instead of the providen mdl. I tried some objects from the default library ...

    My first try was a total fsx crash. I think that it was because the object i used (arianne_bourget) was geo-locked.
    The second try was successful (a F-22 raptor from the library). Of course it was not really flyable, and has incorrect contact points, no moving parts etc. But nothing that cannot be solved easily.

    Another test with PPL_RussianVillain (735a6aeb-368a-4ae5-a4bc-bcb4f5b88626). No crash, but rendering is incorrect :
    [​IMG]
    Doesn't really looks like a russian :rolleyes:
    Last edited: 18/1/07
  7. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    It looks interesting indeed. I expect there are some sections of the MDL format that are only used by aircraft and not by scenery, but the fact that they seem interchangable is great news.

    Also, I think the Russian villain I found a while back looks better (see screenshot) :D. I can't remember the GUID, but it was in the PPL section.

    Attached Files:

  8. lc0277

    lc0277

    Joined:
    25/9/06
    Messages:
    156
    Country:
    france
    The problem may be elsewhere. If I copy the MDL extracted from its library BGL to the aircraft directory, then it shows correctly. visual_model_guid does not seems to work for all models.

    BTW some MDL files exists in both "aircraft" and "scenery" versions. For instance ANI_GiraffeWalk_Mature can be found in SimObjects/Animals and in scenery/global/animals.bgl. The files look barely identical, but there is a slight size difference.
    Last edited: 18/1/07
  9. theisomizer

    theisomizer

    Joined:
    15/1/07
    Messages:
    157
    Country:
    us-texas
    Sweet. I'll be doing some tests with aircraft animations this weekend. Keep you posted.

    Cheers,
    Sean
  10. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    Hi,

    I have a little question of how to draw the 3D model, ehh...for example: if i want to draw a PART, in the wiki page says it has these parameters:

    int (?)
    int (?)
    int material_index
    int scene_ref (?)
    int vertex_offset
    int vertex_count
    int index_offset
    int index_count
    int mouse_rectangle_ref (?)

    Then, i get the index_offet and divide by 3 (index_offset / 3) then that gives me (the result) the index number of the triangle that i must get from the INDE section? (im correct? or i misunderstood it?..hehe). And also the index_count is the number of triangles needed to draw that part of the 3D model?...do i need to divide the index_count by 3 too? (i dont think so...but if im wrong then correct me)...

    And another question, then the vertex_offet and vertex_count, how they are related or what role they play in the part's drawing?...(just asking if someone knows...if not...no problem..hehe)

    i would appreciate if someone could tell me if im wrong or in the good way..hehehe...thanks again...

    Best Regards,

    Manuel Ambulo

    NOTE: Sorry by my "rookie" questions...
    Last edited: 21/1/07
  11. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    Hi Manual,

    Yes, that is sort of how it works.

    The index_offset will tell you where to start in the index list. If you count each triangle as three indices you have to divide the number by three to get the triangle count. If you just count each index as an integer, you can just use the value given.

    The index count also has to be divided by three if you are counting the triangles. But if you are just counting the integers you can use the value given.

    In the index list you will find the vertex numbers used by each triangle. This is were the vertex_offset comes in, as the vertex count usually starts at zero for each part. So to get the correct vertex you need to add the vertex_offset to the vertex number from the index list. Once you know the vertices it is rather easy to draw the triangle of course.

    I don't know were the vertex_count is used. I guess you might need to know this when you want to extract the vertices from the list, but I did not use it in my code to render a MDL object.

    I hope this makes it a bit clearer :).
  12. Manuel Ambulo

    Manuel Ambulo

    Joined:
    29/9/06
    Messages:
    162
    Country:
    panama
    THANKS...MANY THANKS...arno, yes, now i see more clearly how it works...i need to do some tests to see how i can draw the model, but i still have a little question, the TRAN section which contains the matrices, are they found in scenery 3D models MDLs files?, i mean, i know that back to the old format the matrices used to be declared just before the commands used for draw a specified part of an object, i dont know if here it applies the same thing, i mean if it is needed some transformation before drawing a part (of a SCENERY 3D model), or it is something that only appears in aircraft's MDL :confused: .....and i want to know if in the TRAN section there are multiple 4x4 matrices or there is only one 4x4 matrix?....sorry by my english...i hope you got what i meant, ...i mean...if the TRAN section can be also found in 3D scenery MDLs, or if it is only reserved for aircrafts MDLs?? :confused: ...

    Best Regards,

    Manuel Ambulo
  13. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    Hi Manual,

    The simple scenery objects I looked at until now only have one transformation matrix in the TRAN section. So they are to be found in scenery objects as well. When using animations and probably also attachpoints I expect more transformation matrices to show up, but I have not yet studied those in detail.
  14. osman

    osman

    Joined:
    30/9/06
    Messages:
    73
    Country:
    germany
    Unknown section

    Hi,
    I just looked to some mdl files which I extracted from land vehicles library, I will add one to this post. It has the usual sequence of sections. Within the MDLD section you find a LODT section at offset 0x23aa2, which in turn has 4 LODE sections with several PART sections ending at offset 0x23d6e. But the MDLD section does not end at that point, instead there is a SHAM section following covering the rest of the file. In that SHAM section there are again MATE, INDE , VERB etc sections ending again with LODT. Has anyone an idea what that could be ?? The name could suggest that it has something to do with drawing the shadow.

    Attached Files:

    Last edited: 27/1/07
  15. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    Hi Winfried,

    That sounds like a vary logical explaination. In the Fs2004 format non-default shadow models are stored in a similar way. I'll try to explore the MDL file you attached a bit more.
  16. theisomizer

    theisomizer

    Joined:
    15/1/07
    Messages:
    157
    Country:
    us-texas
    There's more!

    Ok folks,

    As some of you might of guessed by now I'm a bit of a hacker... ok more than a bit (I almost became a CEH until I decided to go into the aviation industry).:D

    So last night I was digging through another MDL file when I bulb lit up in my head and I thought 'Hey, why not look through xtomdl.exe instead?' So I ran through it and made some startling discoveries. The first of which I'll share with you now:

    Attached is a list of ALL of the possible RIFF tags that can be found in a MDL file. Yes, all, No more, no less. Most of these will be unfamiliar to you so I'll try to get a description of each up on the wiki in the next few days.

    Legal note - This type of hacking is NOT illegal, or at least in the United States anyways. Reverse engineering code for the sole purpose of program interoperability is legal. And that is exactly what I did.

    Ok. please enjoy and feel free to edit/redistribute/add to it/feed it to your dog!

    Sean

    Attached Files:

    • mdl.txt
      File size:
      342 bytes
      Views:
      283
    Last edited: 31/1/07
  17. arno

    arno Administrator Staff Member FSDevConf team Resource contributor

    Joined:
    28/5/04
    Messages:
    21,302
    Country:
    netherlands
    Thanks, that is a nice starting point. There are quite a few new ones in that list indeed. Now we only have to find out what their relation is (as which one is nested in the other one) and what they actually do :).
  18. Stranger

    Stranger

    Joined:
    25/7/05
    Messages:
    120
    Hi guys,

    I've updated some parts of FSX MDL Wiki document. The text file attached contains descriptions of most MDL signatures posted by theisomizer.

    Actually I'm able to draw most of default objects although there still is a problem with static matrices in animated models. When applied, most (but not all) animated parts are positioned correctly except that they are alligned to different axis - 90 degress to non-animated as seen on attached images. Probably resolving of animation structure will bring more light on.

    I see that the last post in this thread is more than a year old. Is there any progress? Is anybody still interested?

    Attached Files:

  19. =Hollywood=

    =Hollywood=

    Joined:
    13/12/06
    Messages:
    497
    Country:
    unitedstates
    you guys just gave me an idea, thatwould likely make the guys at ACES laugh...

    how hard would it be to turn an animated animal or human into a 'pilotable' mdl, and create an online session sometime ala people walking through the scenery lol...
  20. Marginal

    Marginal

    Joined:
    25/10/06
    Messages:
    41
    Country:
    unitedkingdom
    The SCEN structure describes a hierarchy of matrices that need to be multiplied together to form the final matrix for the part. The top matrix in the hierarchy is often a matrix that converts between left and right handed co-ordinate systems. It sounds like you're just applying a single matrix, instead of following the hierarchy, and so you're missing out on that top matrix.

    Each SCEN entry consists of 4 16bit words:
    (child, peer, offset of matrix in AMAP section, unknown - bone index?)
    where child and peer point to other entries within the SCEN section. Sorry I haven't documented this on the wiki - I'm waiting to see how animations fit into this. But see the file FSXImport.py from here for example code.
    Last edited: 27/1/08

Share This Page