Page 1 of 2 12 LastLast
Results 1 to 20 of 38

Thread: 3ds Max CAS Importer patch for ALX

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    RedFox's Avatar When it's done.™
    Join Date
    Nov 2006
    Location
    Estonia
    Posts
    3,027

    Default 3ds Max CAS Importer patch for ALX

    Hey guys.

    A friend of mine contacted me because he had some problems with importing .CAS files from ALX patch. So I took a very long day off and started by cracking the .CAS file format itself. After I had achieved full decoding of the format in C++, I ported the necessary changes to the original CAS_IE script.

    There may be bugs in the script, but for now, importing Alexander expansion CAS models works.

    I know that RTW modding is mostly dead with Rome 2 around the corner, so it might be funny to release this, since it's 6 years too late..


    UPDATE:

    *) CAS Import/Export Tool v0.86b
    -) Redesigned CAS import into an event-based loop. Import a lot more stable.
    -) Fixed "skinnedGeom" not getting Material[0] applied to it.
    -) Material is now properly shown in the viewport with alpha enabled.
    -) BoneAnim fix to handle BonePositions. This fixes the "float" error.
    -) Tested all failed ALX models (thanks to Medusa0 for providing the list).
    -) Redesigned the C++ testing platform. It's no longer a simple port and has better/stable parsing capability.
    -) Made the MaxScript readable. The original code style was horrible and impossible to read due to bad formatting.

    *) TODO:
    -) Fix siege animations import/export (will need to do this on a different day)
    -) Debug/test animations import/export (can someone help with this?)
    -) Debug/test Items import (can someone help with this?)

    Below attached you can download the 3ds Max script (CAS_IE_b86.zip) and also the source C++ files used to decode the CAS file format (CASImporterCpp_b86.zip):
    Here are the files:
    CAS_IE_b86.zip
    CASImporterCpp_b86.zip


    License: You can modify anything and everything. It's all free to use.
    Attached Files Attached Files
    Last edited by RedFox; July 19, 2013 at 10:55 AM.

  2. #2

    Default Re: 3ds Max CAS Importer patch for ALX

    Great job!

    What's different between RTW and ALX .cas files?

  3. #3
    Halie Satanus's Avatar Emperor of ice cream
    Join Date
    Nov 2005
    Location
    London
    Posts
    19,971
    Blog Entries
    1

    Default Re: 3ds Max CAS Importer patch for ALX

    Better late than never..

  4. #4

    Default Re: 3ds Max CAS Importer patch for ALX

    Bravo! +rep for this
    American, French, Israeli and British government's ILLEGAL aggression against the Syrian people, without any proof for chemical attacks in Douma, and without waiting for OPCW to conduct their investigation..
    Sons of *******, leave that poor, war torn country in peace.
    If you are a citizen of one of these countries, then DO NOT ask any help from me on these forums, since, in protest against this aggression by your governments, I do not provide assistance/help anymore.
    Let Syria be finally in peace.

    A video of false chemical attack in Douma, Syria, which led to Western illegal attacks.

  5. #5

    Default Re: 3ds Max CAS Importer patch for ALX

    I don't think RTW modding will die, thanks for this!

  6. #6
    Gen.jamesWolfe's Avatar Vicarius
    Join Date
    Jan 2008
    Location
    in my house.
    Posts
    2,610

    Default Re: 3ds Max CAS Importer patch for ALX

    awesome!

    just one thing: will this also be able to import siege engine animations? if not, I think the source code will be of great assistance.
    I haz a culler!! (really, who gives a darn? its totally meaningless, and it doesn't really accurately reflect who I am)


  7. #7
    RedFox's Avatar When it's done.™
    Join Date
    Nov 2006
    Location
    Estonia
    Posts
    3,027

    Default Re: 3ds Max CAS Importer patch for ALX

    Quote Originally Posted by Gen.jamesWolfe View Post
    just one thing: will this also be able to import siege engine animations? if not, I think the source code will be of great assistance.
    I did not test with any siege animation files. They fail to import?

  8. #8
    Raritу's Avatar Glück auf!
    Artifex

    Join Date
    Aug 2010
    Location
    Veltins Arena
    Posts
    2,464

    Default Re: 3ds Max CAS Importer patch for ALX

    Gorgeous work. Just gorgeous.
    Thought I had lost hope that the importer could be rework by some genius around to be compatible with Alex models.

    Great thanks RedFox, you're the man.

    Quote Originally Posted by RedFox View Post
    I did not test with any siege animation files. They fail to import?
    Yes, though iirc some old modellers were able to import them, so we're guessing it's a newer 3ds max version compatibility issue.

    I'll be using it around, and being sure to tell you if I find any other problems. For now it's working like a charm. Thank you again.

  9. #9
    RedFox's Avatar When it's done.™
    Join Date
    Nov 2006
    Location
    Estonia
    Posts
    3,027

    Default Re: 3ds Max CAS Importer patch for ALX

    Quote Originally Posted by Raritу View Post
    Gorgeous work. Just gorgeous.
    Yes, though iirc some old modellers were able to import them, so we're guessing it's a newer 3ds max version compatibility issue.
    Cool. I don't have much time to work on this myself, but fixing animation import shouldn't be difficult, since animation files only contain 1 CAS Chunk - the 'bone' chunk.

    However the MAXscript importer doesn't reuse the fixed part of the code, so siege should still be broken.


    EDIT: I just discovered one reason why exporting siege engine would crash the game. Some siege engine info files appear to use a few different constants in the model header. Before vercingetorix and I just assumed that data was constant, but obviously it provides some necessary "type of model" information to the game... I'll have to look into this more.

    However you could help me by providing a list of cases where CAS import/export fails.
    Last edited by RedFox; July 17, 2013 at 05:40 AM.

  10. #10

    Default Re: 3ds Max CAS Importer patch for ALX

    Great work, Redfox! Now i can open baktrian peltast and heavy cavalry models.
    But i still cant import armoured horse model A lot of units using this mount (greek cataphracts, median cavalry, scythian nobles, sarmatians etc).
    http://rghost.ru/47482759 Problem model.
    You are my only hope
    Last edited by unDa; July 17, 2013 at 07:13 AM.

  11. #11
    Raritу's Avatar Glück auf!
    Artifex

    Join Date
    Aug 2010
    Location
    Veltins Arena
    Posts
    2,464

    Default Re: 3ds Max CAS Importer patch for ALX

    Hi again,
    I've been experience the following issue,
    Quote Originally Posted by Rarity View Post
    Quote Originally Posted by Thangaror View Post
    I'm sorry Rarity, but the mule makes my game CTD without error message shortly after starting a custom battle.
    I suspect that the *.cas file is corrupted somehow. I re-saved the *.dds to make sure the error is not caused by wrong compression or missing mipmaps, but that didn't help.

    If you don't know how to implement a new mount, you could simply replace the model and textures of any horse in descr_model_battle.txt with the mule-files.
    I think it's most probably an issue with a new version of .cas exporter (b85). I've been testing last couple of hours, it seems the new models I made recently causes CTD, though they look fine in 3ds max, even when I re-import them.

    So I rolled back to .cas import/exporter b79, now the models work in game for me.
    So basically, the exported models by the new version of import/exporter causes CTD when they're used, even though they look perfectly fine in 3ds max.
    Hopefully you can get time to fix this.

    Regards

  12. #12

    Default Re: 3ds Max CAS Importer patch for ALX

    Quote Originally Posted by Raritу View Post
    Hi again,
    I've been experience the following issue,

    So basically, the exported models by the new version of import/exporter causes CTD when they're used, even though they look perfectly fine in 3ds max.
    Hopefully you can get time to fix this.

    Regards
    Same here. Exporting with the old version of the script works ok, tho.
    A difference i've seen is that now i have to assign the texture to the body of the unit (only the body), before it shows up (in the old script that was done automatically). Don't know if it does have something to do with the CTD. Also, some units just don't import, and other give strange errors (can't convert "float" or something). I'm attaching some of the models, that give me problems
    Attached Files Attached Files
    Last edited by hameleona; July 18, 2013 at 06:25 AM.

  13. #13
    RedFox's Avatar When it's done.™
    Join Date
    Nov 2006
    Location
    Estonia
    Posts
    3,027

    Default Re: 3ds Max CAS Importer patch for ALX

    Managed to do some data mining across all the *.CAS files in Vanilla RTW. In order to understand the mined data, we also need the CASHEADER structure itself. The first 3 variables don't really concern us, since we know what they are for. The most interesting values are unk2, unk5 and unk8 - the rest are constants.

    Code:
    struct CASHEADER
    {
        float filever;   // 0    file version
        int chunkSize;   // 4    cas chunk size (38)
        int chunkType;   // 8    cas chunk type (9)
    // ---------------
        int unk1;        // 12   always 0
        float unk2;      // 16   varies 0.05, 1.3, 3.33
        int unk3;        // 20   always 1
        int unk4;        // 24   always 0
        uint unk5;       // 28   
        ushort unk6;     // 32   always 0
        int unk7;        // 34   always 0
        uint unk8;       // 38
    };


    I don't know why a lot of those variables are constant though. Perhaps it's used as a file sanity check - it's beyond me, really.

    Notably though unk5 and unk8 are integers that keep changing across a large range of models. If we lay the integer out as bytes, it starts to look like a byte array - an RGBA color byte array to be precise.
    Code:
    [ 94  94  94 1] ; R G B A ?

    But it doesn't make much sense with the '1', which should be 255 for full opaque alpha channel. It might be that I'm reading the struct wrong and that I'm making all the wrong assumptions. For all we care unk5-unk8 could be laid out like this instead:
    Code:
    // [ 94  94  94 1]    [0 190 190 190]
    struct 
    {
        byte unk5 [3]; // 94 94 94
        byte unk54;    // 1       (const) bool?
        uint unk6;     // 0       (const) note: overwrite this and you crash in RTW
        byte unk7 [3]; // 0 0 0   (const)
        byte unk8 [3]; // 190 190 190
    };


    It would make a bit more sense if it looked like that, but I'm not really sure.

    Below is the data I mined across all Vanilla RTW 1.5 *.CAS model files. Perhaps others have more luck decoding it.
    Spoiler Alert, click show to read: 
    Code:
    <refcount>  <filever>  <unk2>  <unk5>                     <unk8>
    #### C:/Games/RTW/data/models_building ####
    8           3.18       3.33    1000000:[  0   0   0 1]    16161600:[0  22  22  22]
    3           3.18       3.33    1fffad7:[215 250 255 1]    14111200:[0  18  17  20]
    1           3.18       3.33    1b9b19a:[154 177 185 1]    2f2f2f00:[0  47  47  47]
    
    #### C:/Games/RTW/data/models_effects ####
    9           3.18       3.33    1abb0af:[175 176 171 1]    6b6b6b00:[0 107 107 107]
    4           3.18       3.33    1858e8b:[139 142 133 1]    6b6b6b00:[0 107 107 107]
    3           3.18       3.67    1020300:[  0   3   2 1]    6b6b6b00:[0 107 107 107]
    2           3.18       3.33    1a19785:[133 151 161 1]    6b6b6b00:[0 107 107 107]
    2           3.18       3.33    1a19785:[133 151 161 1]           0:[0   0   0   0]
    
    #### C:/Games/RTW/data/models_engine ####
    13          2.22       3.33    1000000:[  0   0   0 1]           0:[0   0   0   0]
    11          3.02       0.05    19f9f9f:[159 159 159 1]    14111200:[0  18  17  20]
    9           3.02       0.03    1d2c8ed:[237 200 210 1]           0:[0   0   0   0]
    9           2.22       5.00    1000000:[  0   0   0 1]           0:[0   0   0   0]
    9           3.20       0.05    1f9d3e2:[226 211 249 1]    16161600:[0  22  22  22]
    8           3.16      10.00    1000000:[  0   0   0 1]    21212100:[0  33  33  33]
    7           3.12       3.33    17e7e7e:[126 126 126 1]           0:[0   0   0   0]
    6           3.05       0.05    1b0a8af:[175 168 176 1]    16161600:[0  22  22  22]
    5           3.02       0.05    18b8b8b:[139 139 139 1]           0:[0   0   0   0]
    5           3.20       0.10    1ababab:[171 171 171 1]           0:[0   0   0   0]
    4           2.22       2.00    1074900:[  0  73   7 1]    16161600:[0  22  22  22]
    4           3.02       0.05    17c7c7c:[124 124 124 1]           0:[0   0   0   0]
    4           3.20       1.30    1f9d3e2:[226 211 249 1]    16161600:[0  22  22  22]
    4           3.20       5.00    1ababab:[171 171 171 1]           0:[0   0   0   0]
    3           3.18       0.05    1ababab:[171 171 171 1]           0:[0   0   0   0]
    3           2.22       0.03    1074900:[  0  73   7 1]    16161600:[0  22  22  22]
    3           3.02       0.05    1777777:[119 119 119 1]           0:[0   0   0   0]
    2           2.22       3.33    17a7a7a:[122 122 122 1]           0:[0   0   0   0]
    2           3.20       2.20    18b8b8b:[139 139 139 1]           0:[0   0   0   0]
    2           3.20       0.05    1ababab:[171 171 171 1]    6a6a6a00:[0 106 106 106]
    2           3.02       0.05    17e7e7e:[126 126 126 1]           0:[0   0   0   0]
    2           3.02       0.05    1074900:[  0  73   7 1]    16161600:[0  22  22  22]
    1           3.02       0.04    1929292:[146 146 146 1]           0:[0   0   0   0]
    1           3.02       0.05    1929292:[146 146 146 1]           0:[0   0   0   0]
    1           3.12       1.00    17e7e7e:[126 126 126 1]           0:[0   0   0   0]
    1           3.11       3.33    1fffad7:[215 250 255 1]    14111200:[0  18  17  20]
    1           3.02       1.45    19e9e9e:[158 158 158 1]           0:[0   0   0   0]
    1           3.02       0.05    19e9e9e:[158 158 158 1]           0:[0   0   0   0]
    1           3.02       1.10    16f6f6f:[111 111 111 1]           0:[0   0   0   0]
    1           3.05       1.10    1b0a8af:[175 168 176 1]    16161600:[0  22  22  22]
    1           3.02       1.33    16f6f6f:[111 111 111 1]           0:[0   0   0   0]
    1           3.02       1.50    1074900:[  0  73   7 1]    16161600:[0  22  22  22]
    1           3.02       0.07    1000000:[  0   0   0 1]           0:[0   0   0   0]
    1           3.05       4.90    19f9f9f:[159 159 159 1]    14111200:[0  18  17  20]
    1           2.22       2.50    1929292:[146 146 146 1]           0:[0   0   0   0]
    1           2.22       5.00    18b8b8b:[139 139 139 1]           0:[0   0   0   0]
    1           3.02       0.05    16f6f6f:[111 111 111 1]           0:[0   0   0   0]
    1           3.12       0.10    19f9f9f:[159 159 159 1]    14111200:[0  18  17  20]
    
    #### C:/Games/RTW/data/models_landscape ####
    30          3.02       3.33    1ffffff:[255 255 255 1]           0:[0   0   0   0]
    24          3.12       3.33    1b4c4c5:[197 196 180 1]           0:[0   0   0   0]
    15          3.02       3.33    1a8a8a8:[168 168 168 1]           0:[0   0   0   0]
    14          3.02       3.33    1000000:[  0   0   0 1]           0:[0   0   0   0]
    7           3.16       3.33    1b9b9b9:[185 185 185 1]           0:[0   0   0   0]
    6           3.02       3.33    192a6b3:[179 166 146 1]           0:[0   0   0   0]
    6           3.02       3.33    1c4c8cb:[203 200 196 1]    28282800:[0  40  40  40]
    3           3.02       3.33    1a6a6a6:[166 166 166 1]           0:[0   0   0   0]
    3           3.18       3.33    1959595:[149 149 149 1]           0:[0   0   0   0]
    3           3.02       3.33    199c2bd:[189 194 153 1]           0:[0   0   0   0]
    3           3.18       3.33    10000e6:[230   0   0 1]           0:[0   0   0   0]
    3           3.16       3.33    1276e6b:[107 110  39 1]           0:[0   0   0   0]
    2           3.02       3.33    1bcbcbc:[188 188 188 1]           0:[0   0   0   0]
    2           3.16       3.33    1608f86:[134 143  96 1]           0:[0   0   0   0]
    1           3.02       3.33    1bebebe:[190 190 190 1]           0:[0   0   0   0]
    
    #### C:/Games/RTW/data/models_missile ####
    7           3.02       0.03    1d2c8ed:[237 200 210 1]           0:[0   0   0   0]
    7           3.16       3.33    1000000:[  0   0   0 1]           0:[0   0   0   0]
    4           3.12       3.33    15e5e5e:[ 94  94  94 1]           0:[0   0   0   0]
    3           3.18       3.33    1575757:[ 87  87  87 1]           0:[0   0   0   0]
    1           3.11       3.33    1fffad7:[215 250 255 1]    14111200:[0  18  17  20]
    1           3.07       1.25    1000000:[  0   0   0 1]           0:[0   0   0   0]
    
    #### C:/Games/RTW/data/models_off_map ####
    1           3.18       3.33    1000000:[  0   0   0 1]    21212100:[0  33  33  33]
    
    #### C:/Games/RTW/data/models_strat ####
    49          2.19       3.33    1000000:[  0   0   0 1]     a0a0a00:[0  10  10  10]
    27          3.07       3.33    1b5a600:[  0 166 181 1]     a0a0a00:[0  10  10  10]
    24          3.02       0.65    1666666:[102 102 102 1]           0:[0   0   0   0]
    21          2.19       3.33    1000000:[  0   0   0 1]    63636300:[0  99  99  99]
    17          3.18       3.33    1000000:[  0   0   0 1]    31313100:[0  49  49  49]
    15          3.16       3.33    15e5e5e:[ 94  94  94 1]           0:[0   0   0   0]
    6           3.02       0.05    1135200:[  0  82  19 1]           0:[0   0   0   0]
    5           3.18       3.33    15e5e5e:[ 94  94  94 1]    81818100:[0 129 129 129]
    4           3.02       0.90    14b4b4b:[ 75  75  75 1]           0:[0   0   0   0]
    4           3.01       3.33    1000000:[  0   0   0 1]    14111200:[0  18  17  20]
    4           3.02       0.05    1000000:[  0   0   0 1]     a0a0a00:[0  10  10  10]
    3           3.01       0.05    1646464:[100 100 100 1]           0:[0   0   0   0]
    3           3.02       0.30    1666666:[102 102 102 1]           0:[0   0   0   0]
    2           3.02       0.05    1666666:[102 102 102 1]           0:[0   0   0   0]
    2           2.20       2.00    1074900:[  0  73   7 1]    16161600:[0  22  22  22]
    2           3.02       3.33    1fffad7:[215 250 255 1]    14111200:[0  18  17  20]
    2           3.18       3.33    1000000:[  0   0   0 1]           0:[0   0   0   0]
    2           2.17       3.33    1000000:[  0   0   0 1]     a0a0a00:[0  10  10  10]
    2           3.02       1.60    18b8b8b:[139 139 139 1]           0:[0   0   0   0]
    1           2.23       0.95    1000000:[  0   0   0 1]           0:[0   0   0   0]
    1           3.02       0.20    1666666:[102 102 102 1]           0:[0   0   0   0]
    1           3.01       0.03    1074900:[  0  73   7 1]    16161600:[0  22  22  22]
    1           2.19       3.33    1fffad7:[215 250 255 1]    5a5a5a00:[0  90  90  90]
    1           3.18       5.00    1000000:[  0   0   0 1]           0:[0   0   0   0]
    1           3.18       3.33    1eef3d5:[213 243 238 1]    31303000:[0  48  48  49]
    1           2.17       0.03    1000000:[  0   0   0 1]           0:[0   0   0   0]
    1           3.00       3.33    1000000:[  0   0   0 1]    38383800:[0  56  56  56]
    1           3.16       3.33    1575757:[ 87  87  87 1]           0:[0   0   0   0]
    1           3.18       3.33    15e5e5e:[ 94  94  94 1]    aeaeae00:[0 174 174 174]
    1           3.01       7.00    1000000:[  0   0   0 1]     a1c2100:[0  33  28  10]
    1           3.12       3.33    169cb00:[  0 203 105 1]           0:[0   0   0   0]
    1           2.23       3.33    1000000:[  0   0   0 1]    28282800:[0  40  40  40]
    1           3.02       3.33    1000000:[  0   0   0 1]    16161600:[0  22  22  22]
    1           3.18       1.05    1007d47:[ 71 125   0 1]     b0b0b00:[0  11  11  11]
    
    #### C:/Games/RTW/data/models_unit ####
    410         3.18       3.33    15e5e5e:[ 94  94  94 1]           0:[0   0   0   0]
    79          3.18       3.33    15e5e5e:[ 94  94  94 1]    81818100:[0 129 129 129]
    78          3.02       3.33    1575757:[ 87  87  87 1]           0:[0   0   0   0]
    41          3.12       3.33    1000000:[  0   0   0 1]    1d1d1d00:[0  29  29  29]
    30          3.02       0.05    1666666:[102 102 102 1]           0:[0   0   0   0]
    28          3.02       0.65    1666666:[102 102 102 1]           0:[0   0   0   0]
    23          3.18       3.33    1686868:[104 104 104 1]           0:[0   0   0   0]
    20          2.22       0.65    16b6b6b:[107 107 107 1]           0:[0   0   0   0]
    11          3.12       3.33    1000000:[  0   0   0 1]           0:[0   0   0   0]
    9           3.18       0.05    1000000:[  0   0   0 1]     a0a0a00:[0  10  10  10]
    8           3.18       1.00    1000000:[  0   0   0 1]     a0a0a00:[0  10  10  10]
    7           3.12       3.33    15d8089:[137 128  93 1]    71717100:[0 113 113 113]
    7           3.16       3.33    15e5e5e:[ 94  94  94 1]    85858500:[0 133 133 133]
    6           3.12       3.33    1000000:[  0   0   0 1]    21212100:[0  33  33  33]
    5           3.02       0.90    14b4b4b:[ 75  75  75 1]           0:[0   0   0   0]
    5           3.02       0.05    1646464:[100 100 100 1]           0:[0   0   0   0]
    4           3.16       3.33    1000000:[  0   0   0 1]    2d2d2d00:[0  45  45  45]
    4           3.20       3.33    1000000:[  0   0   0 1]    3f3f3f00:[0  63  63  63]
    4           3.02       0.05    13b3b3b:[ 59  59  59 1]           0:[0   0   0   0]
    4           3.18       1.50    1ffffff:[255 255 255 1]     3030300:[0   3   3   3]
    3           3.18       3.33    16f6f6f:[111 111 111 1]           0:[0   0   0   0]
    3           3.05       0.05    1595959:[ 89  89  89 1]     a0a0a00:[0  10  10  10]
    3           3.18       3.33    15e5e5e:[ 94  94  94 1]    aeaeae00:[0 174 174 174]
    3           3.05       3.33    12f2f2f:[ 47  47  47 1]           0:[0   0   0   0]
    2           3.16       1.00    1595959:[ 89  89  89 1]     a0a0a00:[0  10  10  10]
    2           3.18       3.33    15e5e5e:[ 94  94  94 1]    ababab00:[0 171 171 171]
    2           3.18       3.33    15e5e5e:[ 94  94  94 1]    c3c3c300:[0 195 195 195]
    2           3.18       3.33    15e5e5e:[ 94  94  94 1]    cecece00:[0 206 206 206]
    1           3.12       3.33    16f6f6f:[111 111 111 1]    1d1d1d00:[0  29  29  29]
    1           3.02       0.25    13b3b3b:[ 59  59  59 1]           0:[0   0   0   0]
    1           3.18       3.33    15e5e5e:[ 94  94  94 1]    92929200:[0 146 146 146]
    1           3.18       3.33    15e5e5e:[ 94  94  94 1]    9e9e9e00:[0 158 158 158]
    1           3.18       3.33    15e5e5e:[ 94  94  94 1]    dfdfdf00:[0 223 223 223]
    1           3.18       3.33    15e5e5e:[ 94  94  94 1]    bebebe00:[0 190 190 190]
    1           3.07       0.05    1ffffff:[255 255 255 1]     3030300:[0   3   3   3]
    1           2.22       0.05    1135200:[  0  82  19 1]           0:[0   0   0   0]
    
    #### C:/Games/RTW/data/models_vegetation ####
    29          3.18       3.33    1000000:[  0   0   0 1]           0:[0   0   0   0]
    14          3.18       2.67    1c6bb9c:[156 187 198 1]           0:[0   0   0   0]
    1           3.18       3.33    1000000:[  0   0   0 1]    7e7e7e00:[0 126 126 126]


  14. #14
    RedFox's Avatar When it's done.™
    Join Date
    Nov 2006
    Location
    Estonia
    Posts
    3,027

    Default Re: 3ds Max CAS Importer patch for ALX

    Thanks a lot for finding these bugs. I now have enough material to spend some debugging time on (y).

    The crash is probably because of a buggy CAS model header. I'll see what I can do to get the models working.

    EDIT: Good news, fixed the model export crash (at least it works for me). I had a bug in the C++ code, which caused me to write a CAS model header constant twice - apparently RTW indeed does use the header data for something...

    I'm working on version 0.86b right now, but if you want a quick fix, replace the MAXScript CASHEADER Write function at line 113 with this:
    Code:
        fn Write fp =
        (
            WriteFloat fp 3.18        -- filever
            WriteLong fp 38            -- cas chunkSize
            WriteLong fp 9            -- cas chunkType (9 == cas model header)
            WriteLong fp 0            -- ?
            WriteFloat fp 3.3333    -- ?
            WriteLong fp 1            -- ?
            WriteLong fp 0            -- ?
            
            WriteByte fp 104        -- ?
            WriteByte fp 104        -- ?
            WriteByte fp 104        -- ?
            WriteByte fp 1            -- ?
            
            WriteShort fp 0            -- ?
            WriteLong fp 0            -- ?
            WriteLong fp 0            -- ?
            --// 42 bytes written
        )
    I have no idea what those 4 bytes represent, but it seems to vary from model type to model type. Perhaps it's an internal ID of what the model is used for. Newer ALEX models use 94, 94, 94, 1 (hex 5E 5E 5E 01 and little endian int hex 015e5e5e).

    I know that spot FX and INFO files have different data there. I guess our best bet would run the C++ program on a huge number of .CAS files and do some data-mining. Perhaps we can categorize models by it...

    I'll make a new post later if I have a breakthrough. Right now I'm working on hameleona's models.
    Last edited by RedFox; July 18, 2013 at 09:21 AM.

  15. #15
    Medusa0's Avatar Artifex
    Join Date
    Apr 2009
    Location
    Nowhere
    Posts
    379

    Default Re: 3ds Max CAS Importer patch for ALX

    Ok, just tested the script in the OP with most of the vanilla Alexander models, and here are my finds using Max 2010 (this is assuming that if one lod imports fine, the others lod also, that goes for non-importing stuff too):

    Spoiler Alert, click show to read: 
    Working models:
    ALEX_agrian_javelin_skirmishers_lod_1
    ALEX_Alexander_lod_1
    ALEX_ALexander_strat
    ALEX_aux_thracian_cavalry_lod_1
    ALEX_bactrian_cavalry_lod_1
    ALEX_barbarian_sickleman_lod_1
    ALEX_cretan_archer_lod_1
    ALEX_Dahae_Mounted_Archer_lod_1
    ALEX_darius_chariot_lod1 (Model is bunched up as per vanilla chariots)
    ALEX_Darius_III_lod_1
    ALEX_hypaspist_lod_1
    ALEX_indian_chariot_crew_lod1
    ALEX_indian_chariot_lod1 (Same as the Darius chariot)
    ALEX_indian_elephant_crew_lod1
    ALEX_indian_female_archer_lod_1
    ALEX_indian_javelinman_lod1
    ALEX_indian_levy_archer_lod_1
    ALEX_indian_light_cavalry_lod1
    ALEX_indian_longbowman_lod_1
    ALEX_indian_medium_cavalry_lod1
    ALEX_indian_mercenary_spearman_lod1
    ALEX_indian_Porus_lod1
    ALEX_indian_spearman_lod1
    ALEX_indian_standard_lod1 (Very blocky model, actually have spear instead of sword, use ALEX_indian_standard_lod2 as the smoother alternative)
    ALEX_kardakes_lod1
    ALEX_Mardian_Archer_lod_1
    ALEX_persian_chariot_crew_lod_1
    ALEX_persian_general_lod_1
    ALEX_persian_infantry_lod_1 (Has to assign materials manually)
    ALEX_persian_Memnon_leader_lod_1
    ALEX_Persian_Peltast_lod_1 (Low poly secondary weapon)
    ALEX_persian_standard_lod_1
    ALEX_phrygian_hvy_infantry_lod_1 (Head is turned towards the left)
    ALEX_prodromoi_scouts_lod_1
    ALEX_Scythian_Mounted_Archer_lod_1
    ALEX_thracian_mercenary_lod1 (Finally some boots!)
    greek_hoplite_ALEX_lod1
    unit_barbarian_swordsmen_lod1
    officer_indian_general_high (Unused model with different quality, these Indian units can also be imported with older scripts, I used CAS_IE_b79)
    unit_indian_archer_high
    unit_indian_cavalry_high
    unit_indian_noble_archer_high
    unit_indian_spearman_high

    Non-working unit models, unless explicitly stated, the unit cannot be imported and yielded a MAXScript Rollout Handler Exception --Unable to convert: undefined to type: Float error:
    ALEX_allied_cavalry_lod_1 (Can import, but the model is stretched, attempting to rotate or zoom in turns the camera "blank", only solution for me is to reboot 3dsmax)
    ALEX_barcanian_horsemen_lod_1
    ALEX_companion_cavalry_lod_1 (Can import, model is distorted but does not blank out camera)
    ALEX_greek_mercenary_infantry_lod_1
    ALEX_hyrcanian_cavalry_lod_1
    ALEX_Immortals_lod_1
    ALEX_indian_minor_general_lod1
    ALEX_indian_slinger_lod1 (Can import but balled up model)
    ALEX_macedon_general_lod_1 (See Allied cavalry)
    ALEX_mount_indian_elephant_lod1 (See Indian slinger)
    ALEX_persian_Memnon_troops_lod_1
    ALEX_persian_peasant_lod_1
    ALEX_persian_slinger_lod_1 (See Indian slinger)
    ALEX_phalangist_lod_1 (Imports blank model, otherwise the same issue as the Allied cavalry)
    ALEX_phalangist_standard_lod_1 (See Allied cavalry)
    ALEX_rhodian_slinger_lod_1 (See Indian slinger)
    ALEX_Thessalian_cavalry_lod_1 (See companion cavalry)

    Luckily most of the models import without issues. (Sorry about the mess, TWC is too screwed up for me to type properly )

  16. #16
    RedFox's Avatar When it's done.™
    Join Date
    Nov 2006
    Location
    Estonia
    Posts
    3,027

    Default Re: 3ds Max CAS Importer patch for ALX

    Quote Originally Posted by Medusa0 View Post
    Ok, just tested the script in the OP with most of the vanilla Alexander models, and here are my finds using Max 2010 (this is assuming that if one lod imports fine, the others lod also, that goes for non-importing stuff too):
    Thanks for the data, it's a huge help The stretched model is pretty much the same error as the float read error - it's obviously reading data from an incorrect location and getting freakishly big float values.

  17. #17
    Gen.jamesWolfe's Avatar Vicarius
    Join Date
    Jan 2008
    Location
    in my house.
    Posts
    2,610

    Default Re: 3ds Max CAS Importer patch for ALX

    Ok, so I went ahead and attempted what you proposed: gather all the ones the importer/exporter can't handle. However, the number is too large to put in a zip and upload it--at least with my current connection.

    one set of files you can easily round up however are the siege engine animations and models, which are in data/animation/engines. Not even static models there (if even static: fails to be imported either way) do not load, with the error message mentioning a problem with the "float".
    I haz a culler!! (really, who gives a darn? its totally meaningless, and it doesn't really accurately reflect who I am)


  18. #18
    RedFox's Avatar When it's done.™
    Join Date
    Nov 2006
    Location
    Estonia
    Posts
    3,027

    Default Re: 3ds Max CAS Importer patch for ALX

    Man, I think the BONE-ANIMS chunks it the most annoying chunk ever. It's quite hard to parse actually, since so much data doesn't follow any common rule-set. Sometimes there's a huge ZERO-bytes blocks, sometimes there's not - there is no reliable way to check for that. Even worse, that size varies.

    Here's the layout of the BONEANIMS Chunk (for whoever cares):
    Spoiler Alert, click show to read: 


    Code:
    [CAS CHUNK]
        [chunkSize (varies]
        [chunkType = 0]
    [BONEANIMS]
        [numBones]                          // number of bones (usually 20)
        [boneHierary][numBones - 1]         // bone relations
    
        [numFrames]                         // animation frames (don't know why anim in a model..)
        [frameTimes][numFrames]             // frame timings
        
        [bones][numBones]                   // bones data
        [boneAnims][numBones-1 * numFrames] // animation stuff in model.. weird.
        [rootAnim][numFrames]               // scene root position anim
        
        [unknown][numFrames * 216 or * ???] // really weird ZERO-byte block
    
        [bonePositions][numBones]           // bone positions

    You can see that the model import failed because there was no certain way to skip that unknown section. Its size could vary randomly. I just solved it by seeking to the end of the Chunk and then jumping back by [numBones] to get the bonePositions.



    Alright, I guess it's time for v0.86 patch.
    *) CAS Import/Export Tool v0.86b
    -) Redesigned CAS import into an event-based loop. Import a lot more stable.
    -) Fixed "skinnedGeom" not getting Material[0] applied to it.
    -) Material is now properly shown in the viewport with alpha enabled.
    -) BoneAnim fix to handle BonePositions. This fixes the "float" error.
    -) Tested all failed ALX models (thanks to Medusa0 for providing the list).
    -) Redesigned the C++ testing platform. It's no longer a simple port and has better/stable parsing capability.
    -) Made the MaxScript readable. The original code style was horrible and impossible to read due to bad formatting.

    *) TODO:
    -) Fix siege animations import/export (will need to do this on a different day)
    -) Debug/test animations import/export (can someone help with this?)
    -) Debug/test Items import (can someone help with this?)

    Here are the files:
    CAS_IE_b86.zip
    CASImporterCpp_b86.zip


    Again, thanks a lot to you guys for helping me out so far - I would never had the time to find all those buggy files by myself.
    Last edited by RedFox; July 19, 2013 at 10:55 AM.

  19. #19
    Gen.jamesWolfe's Avatar Vicarius
    Join Date
    Jan 2008
    Location
    in my house.
    Posts
    2,610

    Default Re: 3ds Max CAS Importer patch for ALX

    Any news regarding the maxscript version of the siege engine friendly importer script? the C++ is proving most difficult at this time.

    till then, keep up the great work!
    I haz a culler!! (really, who gives a darn? its totally meaningless, and it doesn't really accurately reflect who I am)


  20. #20

    Default Re: 3ds Max CAS Importer patch for ALX

    Played around with the script.

    Imports and exports units correctly, haven't had problems, but i admit, i tested just some random models.
    Tested sample animation for all infantry and cavalry units i had (signifierone's pack) - works.
    Don't know how to work with animatons, so i didn't export any
    Haven't tested items.

    When importing some models from vanilla (those with a number on their name like: officer_roman_standard_400) there are 4 things i have encountered till now:

    1. It warns about an older model and imports correctly (example: officer_roman_standard_400.cas).
    2. It does not warn and imports correctly (example: unit_greek_pike_phalanx_400.cas)
    3. It gives warning and imports, but stuff is missing (example: unit_greek_royal_cavalry_400.cas) Looks like the face of the body-model attached to the shoulders is missing. Even crazier - some of those moddels are used in the game and don't have missing parts (the example above is the model for the companion cavalry).
    3. As above, but also with a old type of texture by default so it looks really bad. But they still miss the shoulder stuff. Example: unit_greek_archer_400.cas

    don't have the time to go trough them all and separate the different cases, but i was wondering why do they miss their shoulders? Attaching the units as before. units.rar

Page 1 of 2 12 LastLast

Posting Permissions

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