Results 1 to 6 of 6

Thread: Unpack KINGDOMS mesh files so you can convert them to ms3d using GOAT

  1. #1

    Default Unpack KINGDOMS mesh files so you can convert them to ms3d using GOAT

    This tutorial describes how you can unpack KINGDOMS.mesh files (especially units) in order to convert them into ms3d files using GOAT.

    That’s right; NOT the m2tw vanilla mesh files that we have no problem converting. Some of you are able to convert some kingdoms mesh files using GOAT, alas, many of us could not for one reason or another.

    Firstly I’d like to thank Damphair for asking the question.
    Especially I’ll thank Arganontio who has spent about a week working with me to iron out the issues that we discovered in this process.

    Be under no illusions, this is a challenging process to get to grips with, hence the depth of the tutorial, with a little perseverance and patience you’ll be unpacking and converting those files to your hearts content.
    When you’ve done it a couple of times it’ll take you about 5 minutes or less per file.

    Section 1. Manual Unpack of Mesh Files.
    Part A. Winhex
    Spoiler Alert, click show to read: 

    You will need a hexadecimal program, I use ‘winhex’. You’ll also need the attached UUP file (courtesy of Argantonio).
    Two optional attachments are; i) 'mesh.txt' which you can use to fill in necessary information as you progress through the tutorial and ii) 'calculator' which will calculate values for you to save you some time.

    Set up the ‘winhex’ program so that it matches what I'm using in the following way:

    Go to general options.
    24 bytes per line
    group 4 bytes
    Go to options -- data interpreter
    select 8bit,16bit,24bit,32bit unsigned and Float
    Go to View
    text only display - unselect
    hex only display - unselect
    show .... data interpreter - select.

    Part B. Data pack file
    Spoiler Alert, click show to read: 

    I will use ‘gotland_footmen_lod0.mesh’ as my example so you can follow what we are doing.

    Copy and paste the data.pack file from Britannia campaign (found in Medieval II Totalwar/mods/Britania/packs folder) to a suitable location from which you can store lots of files to work on.

    Part C. Unit data
    Spoiler Alert, click show to read: 

    i) Open the data.pack file using ‘winhex’ and you’ll see something similar to the following (image 1):
    image 1

    The small box to the bottom left of the screen, ‘Data Interpreter’ is very important so take note of it we’ll be using it soon.

    ii) Go to ‘search’ and select ‘Find Text’, we want to find ‘gotland_footmen_lod0.mesh’ so enter that into the text bar (image 2).
    image 2

    You’ll get something like this (image 3)

    image 3

    iii) You’ll need to highlight all the hexadecimal values that correspond to the gotland_footmen_lod0.mesh, just like I did above (hold shift and arrow key or click and drag). The hex values are grouped into blocks of 4 pairs.
    Pay special attention to which hexadecimal values are due to the gotland_footmen_lod0.mesh (see image below), remember they are in groups of four pairs and if I select too many hex values, the surrounding mesh files are being included, we don’t want that at all (image 4).
    image 4

    Get used to selecting the correct hex data as this is vital for unpacking your units.

    iv) The first four hex blocks of this text will need to be noted (use the attached text file or your own method), and the corresponding decimal information gathered (image 5).
    image 5

    So for our gotland_footmen_lod0.mesh we should have noted:

    14297B10 6B210000 922B0300 01520100

    Yours might be different but that doesn’t matter (different packs can have different hex data!), just bear with it.

    To gather the decimal information you must use the little ‘Data Interpreter’ box to the bottom left of the screen. The decimal is read from the hex by selecting the four pairs to be read from right to left (image 6).
    image 6

    In the box; you want the number in the 32 Bit (+): box i.e. 276506900.
    Gather this information for the first four hex values, one block of 4 pairs at a time to get;
    276506900, 8555, 207762, 86529. Make a note these numbers.

    The block of hex containing the packed file information is found by adding the first and last of these decimal numbers.

    276506900 + 86529 = 276593429

    The location of the hex information is therefore from ‘offset 276506900’ to ‘offset 276593429’.

    v) An easy way of highlighting this block of data is to go to ‘edit’, ‘define block’ and input the information into the ‘beginning’ and ‘end’ boxes respectively (image 7).
    image 7

    Copy this block of code using ‘ctrl + c’ or ‘edit, copy block normally’.

    Open the UUPfile using ‘winhex’, it’ll open in a different folder (see top left of winhex main screen).
    Paste the copied block of hex into the packed file at the end of the UUP hex data i.e. at offset 3511 (image 8).
    image 8

    Part D. Interruptions
    Spoiler Alert, click show to read: 

    Next we need to locate the data file ‘interruptions’ for our unit so we can put the locations of the interruptions into the UUP file.
    If you are going to make a mistake, this is where you are likely to make it so take care.

    The number of interruptions for the packed file can be found by taking the second decimal number from our unit, 8555 (see above) and working out the difference between this and the next unit in the data file 6F210000 (8559 in decimal).
    8559 – 8555 = 4 interruptions which are therefore 8555, 8556, 8557, 8558 (image 9)
    image 9

    There are four interruptions and we must find out their locations in order to input this info into the UUP file.
    The first interruption hex can be located using data from offset 8 to 19. For our file this is 79100000, 6C590600 and 5A3E0000 (image 10).
    image 10

    Their corresponding decimal values are 4217, 416108 and 15962.
    The first decimal value is required to calculate the locations in the following way:
    x = (a + 5)4
    where x is the interruption position and a is the first decimal value. For our example:
    x = (4217 + 5)4
    x = 16888 make a note of this.

    We also need the decimal info from earlier, remember iv)?
    276506900, 8555, 207762, 86529

    The second decimal info is required i.e. 8555.
    Multiply this number by 4.
    8555 x 4 = 34220 make a note of this.

    We can now find the interruption locations.
    In ‘winhex’ click ‘position’, ‘go to offset’.
    Enter the first offset position of 16888.

    Again click ‘position’, ‘go to offset’.
    Enter the next offset position of 34220 but this time check the relative to…current position’ (image 12).
    image 12

    The interruption locations for our example are here, remember there are four interruptions so we need the 4 hex values from this position.

    E7A70000, E63C0000, 15590000, 1F140000.
    42983, 15590, 22805, 5151.
    A check to make sure you’ve done all of the above correctly is to add these together, their total should match the forth decimal from Part B, iv) above.

    42983 + 15590 + 22805 + 5151 = 86529 Yes! It matches.
    So E7A70000, E63C0000, 15590000, 1F140000 are the four interruption locations, make a note of these.

    Part E. UUP file
    Spoiler Alert, click show to read: 

    In your UUP file go to offset 872. Here we’ll delete the required number of hex values so we can copy in the interruption hex data. Delete the hex data at 872 and the three before it (4 interruptions so 4 hex values deleted, 16 bytes worth) (image 13).
    image 13

    Paste in the values E7A70000, E63C0000, 15590000, 1F140000 (image 14).
    image 14

    Next we must update the file size information (image 15).
    image 15

    Replace the hex values shown above (near offset 3511) with the 922B0300 01520100 data from Part B iv) (image 16).
    image 16

    The value ‘A5’ needs to be altered to reflect the number of interruptions. A5 represents 1 interruption, A4 is 2 interruptions and so on.
    We will change it to A2 for 4 interruptions.

    Part F. Unpack mesh
    Spoiler Alert, click show to read: 

    i) Save the new UUP pack file in a suitable location, keep a copy of the original UUP file for other future unpacks. Make sure the file is named UUP.pack otherwise it will not unpack.
    ii) Copy the new UUP file into the packs folder of M2TW
    iii) Open your tools folder/unpacker and run list_contents.
    iv) In pack_contents.txt appears data/unppackedfile/fileunppack.bin
    v) Run unpack_certain_files
    vi) Open file; data/unppackedfile/, your file ‘unppack’ is there, open it in winhex and save it with the name of the file changed to gotland_footmen_lod0.mesh note the ‘.mesh’ on the end of the name, this must be included!

    Alternatively point v) can be completed in the following way:
    v) Move the data files found in the packs folder to a backup folder and then paste in the UUP file. Run unpack_all. Part vi) is the same.

    Congratulations, some of you have successfully created your gotland_footmen_lod0.mesh, which can be converted using GOAT into a handy ms3d file.

    For the rest of us, this file has been altered by the unpack process in such a way as to make it incompatible with GOAT! Never fear, there is a solution to this too.

    Part 2. Fixing the Unpack.

    Spoiler Alert, click show to read: 

    Open the unpacked, renamed gotland_footmen_lod0.mesh file using winhex.

    Go to 0ffset 35. It probably reads 00, change to 01
    Go to 0ffset 39 it reads 01, change to 00
    Go to 0ffset 43 it reads 00, change to 01
    Go to 0ffset 49 it reads 00, change to 01
    Go to 0ffset 59 it reads 01, change to 02
    Go to 0ffset 75 it reads 02, change to 03
    Copy 00 00 00 00 from some other offset in the file and paste it at 0ffset 44, this adds another 4 bytes to the file.

    Done. File will now convert using GOAT.

    I hope you have found the tutorial helpful and if you need extra help, post your reply or PM me. I am here to help you even if I can't reply immediately.
    Last edited by colesy606; May 12, 2010 at 10:47 AM.
    "A dark age indeed, no plumbing! No electricity! No nothing! Oh, hang it all." Merlin.

  2. #2

    Default Re: Unpack KINGDOMS mesh files so you can convert them to ms3d using GOAT

    Thank you. This is very much needed.

  3. #3

    Default Re: Unpack KINGDOMS mesh files so you can convert them to ms3d using GOAT

    Indeed! Many thanks for turning this step-by-step.
    Images are quite helpful too! Thanks!
    Last edited by Caba'drin; May 14, 2010 at 10:16 AM. Reason: Images work now.

  4. #4

    Default Re: Unpack KINGDOMS mesh files so you can convert them to ms3d using GOAT

    Foolish Mr Cole!
    The album was checked as private!
    Try them now.
    "A dark age indeed, no plumbing! No electricity! No nothing! Oh, hang it all." Merlin.

  5. #5
    Gorrrrrn's Avatar Citizen
    Join Date
    Jan 2007

    Default Re: Unpack KINGDOMS mesh files so you can convert them to ms3d using GOAT

    re-checked - working fine.
    no idea why they didn't show first time.
    Last edited by Gorrrrrn; May 14, 2010 at 04:59 PM.

  6. #6
    Join Date
    Feb 2005
    New York, USA

    Default Re: Unpack KINGDOMS mesh files so you can convert them to ms3d using GOAT

    Mods -- can this thread be stickied, or somehow included in two places:

    1) the GrumpyOldMan's Converter thread/download file
    2) KnightErrant's GOAT Converter thread/download file

    "If ye love wealth greater than liberty,
    the tranquility of servitude greater than
    the animating contest for freedom, go
    home from us in peace. We seek not
    your counsel, nor your arms. Crouch
    down and lick the hand that feeds you,
    and may posterity forget that ye were
    our countrymen."
    -Samuel Adams

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts