Page 1 of 8 12345678 LastLast
Results 1 to 20 of 153

Thread: Python strat model converter for Milkshape Users

  1. #1
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Python strat model converter for Milkshape Users

    Edit by Gigantus: this article is available with pictures here as PDF file.

    After some testing by volunteers, I've got a beta release of a Python
    strat model converter for use with Milkshape. It can be downloaded
    from here:

    http://www.twcenter.net/forums/downl...o=file&id=1797

    To run it double-click the file (after unzipping of course)
    stratmodelconverter_ver1_1.py. It will display a file chooser. Double click
    a .cas file in model_strat to convert it to .ms3d format. Then open in
    Milkshape and mod it. To back convert, run the script again and select the
    modded .ms3d file and it will convert it back to the .cas file format.

    -------------------------------------------------------------------------
    End of release statement, known deficiencies.
    -------------------------------------------------------------------------
    There are a lot of files in model_strat, this converter can't deal with some
    of them. Can't do:

    Code:
       barb_strat_map_captain
        bishop                                         - has 68 animation frames ?
        captain_drag_model
        cardinal                                        - has 68 animation frames ?
        carthage_strat_captain
    
        character_pontus
        crossed_swords
        diplomat                                         - has 68 animation frames ?
        flood_water
        general_pontus
        good_old_blue
    
        inquisitor                                - don't care about the above, this sucks.
    
        late_captain_northern_shadow   - don't know what to think about this.
    
        navy_eastern                           - old stuff, boring.
        navy_egypt
        navy_greek
        navy_roman
        navy_roman_shadow
    
        priest                                       - 68 animation frames ?
        princess                                    - ditto
    
        resource_chocolate                     - multiple meshes, multiple texture files
        resource_mine                             - same as above
    
        resource_wool                             - this file is death, will clobber your
                                                           computer, I've set a trap for it so
                                                            you can't touch it.
    
    
        symbols - anything RTW can't be converted, anything M2TW can.
    -------------------------------------------------------------------------
    End of known deficiencies, beginning of tutorial.
    -------------------------------------------------------------------------


    To illustrate its use we will follow Alletun's excellent strat models reloaded
    tutorial and try to do the same thing using only Milkshape and the converter.
    (Yes, this is what I did over the holidays, this is what
    happens during re-run season.)

    I'll use mailed_knights as the example but pick anything
    you like. We're going to make a new late_general_northern.cas file using
    mailed_knights and put it in game. I apologize if I'm giving too much detail
    in the following, but I just learned most of this over the holidays by trying to
    write up this tutorial; besides too much is better than too little.

    First step is to convert mailed_knights_lod0.mesh to .ms3d format using
    GrumpyOldMan's converter. I'll assume this is done. Now open in Milkshape.
    There are multiple bodies, arms, legs, etc. that we don't need so we need to
    get rid of these. Before proceeding I'm going to do a "save as" to another name
    so I don't destroy my original mailed_knights_lod0.ms3d. I'll call it mailed_knights_example.
    The figure below shows the model with the groups tab open showing multiple groups.




    Having done this once, I know the animations don't
    work right with the shield present (bone_Lelbow isn't rotated correctly to have
    the shield vertical so it looks stupid). The figure below shows what I mean
    when I merged my first try with the Strat_general_walk.cas animation.



    We'll remove all the shields, all multiple
    bodies, arms, etc. including the lance so only one sword is left.
    To remove them I used the groups tab and selected each
    group in turn numbered higher than _01 by select, then delete. For instance, there
    is one lance (delete it) and a bunch of secondary swords, delete all but the first
    (i.e. keep sword_secondary_26 but delete 27 to 34). Also delete all the kite shields
    for reasons explained above.
    After removing all the duplicates, you should only have seven groups (or meshes
    in 3ds Max parlance). The groups tab should look like the following:




    Now the sword is assigned to the attachments material like it should
    for a battle model but strat models only have one material so assign it to
    Figure instead of Attachments. Under the groups tab select the sword, then go to the
    materials tab, select Figure, then click the assign button. Go back to the groups
    tab and check that the sword (and every other group) is now assigned to the Figure material.

    Now we are ready to export the geometry and uv information to 3ds format.
    To export, go to the file menu item and scroll down to export --> Autodesk 3ds
    and export as "mailed_knights_example.3ds", my name choice for this tutorial.
    This is shown in the figure below:



    Now we have the geometry (and the uv's). We just need the right skeleton.


    To get the skeleton, we will use the Python converter, "stratmodelconverter.py",
    which you can download from the first link above. We will convert "late_general_northern.cas"
    from the models_strat directory of your unpacked files.
    Run the converter by double-clicking on it in explorer. You should see a file chooser
    like that shown below.




    Choose late_general_northern.cas in the file chooser by double-clicking it and you
    should produce a "late_general_northern.ms3d" file in the same directory. (I put all
    the needed files in one directory to start with, for convenience.) Open this file
    in Milkshape and you should see the following:




    Before we do anything I want to do a "save as" so I don't overwrite my original
    late_general_northern.ms3d file. I'll save as "late_general_northern_mailed_knights"
    so I can remember what this is for.

    Now we have to delete all the geometry, leaving only the bones.
    This is easy at this point because all the vertices came in selected so just hit the delete button
    on the keyboard. (If yours aren't selected, go to the model
    tab, hit the select button, then make sure the select options box at the bottom of the model
    pane is set to vertex. Now select a box around the entire model so that all the vertices are
    selected. Then hit delete.) You should be left with only the RTW style bones as shown below:




    Now we import the .3ds file we created before. Go to the file menu item and
    select Import --> Autodesk 3ds as shown below:




    Then mouse to whereever you stored your .3ds file, I called mine mailed_knights_example.3ds.
    After you select it your model should now look like the figure below:




    Let's fix up the group names (some have trailing spaces).
    On the groups tab select head_01 then select the string "head_01" in the edit
    box next to the rename button. You should notice it has a trailing space. Start typing in
    "head_01" (without the quotes) and it should overwrite the original string. Once input
    click the rename button. You should notice the entry in the listbox get smaller now that
    the trailing space is removed. I don't know if this step is necessary, but just to be sure I'll
    do it anyway. Rename the other groups to "arms_Lmail_01", "legs_01", "hands_01", "L_mail_body_01",
    "teeth", and "sword".

    Now assign vertices to bones. Following Alletun we first assign everything to
    a "check" bone. We'll use bone_cloak_bottom for this since at the end nothing should be assigned
    to this bone. Go to the joints tab and double click on bone_cloak_bottom. It should show up in
    the edit box next to the rename button showing it is selected. Then go to the models tab
    and click the select button and make sure the selection options shows the vertex button is
    pushed in. Now select all vertices by dragging a selection box around them. If you got them
    all it should look like the following:




    Then go to the joints tab and click the assign button. Now everything is assigned to
    bone_cloak_bottom. We are now going to assign them to their correct bones, if we omit any vertices
    at the end we can click on bone_cloak_bottom and see them. Let's assign the vertices around
    the waist and the scabbard to bone_pelvis. To zoom in go back to the models tab, unclick the select button,
    hold down the shift key and left click and hold the mouse button and move it upwards to zoom in.
    The front view is the most convenient for assigning. After you have a nice zoomed
    view of the middle section go to the joints tab and double click bone_pelvis so it is ready for
    assigning (it appears in the edit box next to the rename button). Now go back to the model
    tab, click the select button and then drag a box around the vertices
    to select. Then go back to the joint tab and click the assign button.
    Now select the vertices at the tip of the scabbard and click assign again. If you check the
    checkbox labeled "draw vertex weights", you can see what vertices are assigned to a bone
    by double-clicking the bone name. If you do this you should see something like the figure below:




    Now do bone_abs by double clicking it to appear in the edit box.
    We just want the line of vertices across the middle of the chest.
    The vertices I've selected and assigned to bone_abs are shown below:




    Do bone_torso by double clicking it. Then select the vertices of the upper torso.
    Don't worry if you get part of the neck and head, we'll fix that next. The vertices
    I assigned look like




    Now double click bone_head and then go to the group tab and click the group head_01 and
    then the select button. Then to the joint tab and the assign button. Now go back to the
    group tab and do teeth the same way. Keep going until you have assigned everything to
    the left and right bone_upperarm, bone_elbow, bone_hand and the leg parts to left and right
    bone_thighs, bone_lowerlegs, and bone_foot.

    At this point, two checks are done. Go to the joint tab and, making sure the check box "draw vertex weights"
    is still checked,
    then double click bone_cloak_bottom to see if any vertices are still assigned to it. If so,
    assign them to their correct bone. Another check is to click selUnassigned button just to see
    if any vertices didn't get assigned to bone_cloak_bottom to start with. It is worth
    checking all of this carefully. Another visual check is to check the check box
    "draw vertices with bone colors" (this unchecks the "draw vertex weight" checkbox.) Now
    go to the perspective viewport, right click, and select flat or smooth shaded. Go to any
    other viewport and do the same. You should see something like the figure below:




    Now let's pull in the texture for mailed_knights and do an adjustment for the sword.
    From the modeldb file we know the Figure texture is en_lmail_hmail_england.texture
    for the english faction so let's pull this is. The .texture format is CA's own so it
    needs to be converted to either a .dds file or a .tga. Use alpaca's converter to make
    a dds file (or use a hex editor to delete the first 48 bytes, up to the DDS string).
    Now go to the materials tab. You'll see FOUR materials because we dragged in two more
    during the import.

    THE FOLLOWING IS VERY IMPORTANT:

    The last two don't have the needed comments in them so we will delete them.
    Select the second Figure material and click the comment button to be sure there is no comment
    for it. If not, then delete it by clicking the delete button. Do the same for the second
    attachments material.

    AGAIN, CHECK TO MAKE SURE FIGURE AND ATTACHMENTS COMMENTS HAVE DATA IN THEM. IF NOT,
    YOU CANNOT BACK CONVERT!


    Now select the first Figure material. Then go to the top long button
    labeled <none> and click it and mouse to whereever this file or a copy of it exists. Double
    click the en_lmail_hmail_england.dds file. You'll see a circular picture of it on the
    materials tab. To see it in the viewports right-click in a given viewport and select
    textured from the context menu (you'll need to go back to the joints tab and unselect the
    "draw vertices with bone colors" checkbox to see it correctly). Doing this in all four viewports
    gives you the picture shown below:




    Now we just have to fix up the sword and scabbard uv coordinates (you can see they have
    black bits on them because their uv coordinates think they are on the attachments texture,
    not the Figure one). Go to the groups tab and select sword then call up the texture coordinates
    editor under the Window menu item. You should see something like the figure below:




    Now because I don't know Photoshop and because I'm lazy, I'm not going to try and
    make a sword and scabbard on this texture; I'm just going to move and rotate these
    two items to make them acceptable. First select the sword and move it down onto
    the mail; this makes the sword sort of metallic. Second, select the scabbard, then click
    rotate, type in 90 to rotate it 90 degrees then click the little R button, then click move
    and move it onto the red color of one of the
    body textures. When done it should look somewhat like this:



    Now click off the texture coordinate editor and your model should look like this




    Not perfect, but the sword looks metallic and the scabbard is red, so call it done.
    Also, if you've noticed the viewports have switched around it's because I'm finishing up
    at home with different defaults.


    At this point we could save the model, backconvert with stratmodelconverter, and put it in
    game but I deliberately made a mistake earlier on for pedagogical reasons. Let's animate
    the model and see how it looks in Milkshape. For this we save the model as it stands
    and then use the Python animation utilities to merge it with one of the Strat_General
    animations from Caliban's directory. The animation utilities can be
    downloaded from here:

    http://www.twcenter.net/forums/downl...o=file&id=1469


    Run animationutilities.py by double clicking on it and then clicking the animmerge button,
    the utility is shown below:




    A file chooser will be displayed with a *.ms3d filter. First select your model
    (mine at this point is late_general_northern_mailed_knights.ms3d) from the file chooser.
    Then select the Strat_General_attack.cas under the subdirectory Stratmap_General
    in the next file chooser displayed. Finally input the desired frames per second in
    the last dialog (5 is a good choice).
    This will produce the file with the very long name late_general_northern_mailed_knights_animby_Strat_General_attack.ms3d.
    Open this in another Milkshape window and then click the Anim button down at the bottom
    right corner and then click the button labeled by > to play the animation. If you catch
    the right frames you can see this ugly bit shown below (circled in red):




    Arggh! we need to assign some of those vertices to bone_torso instead of bone_head so it
    doesn't do that. At this point you can also check how the legs and arms move from frame
    to frame and see if any other adjustments are needed. It is much easier to see these things
    here than on the strategy map. So back to the model. Below we show the vertices we've selected
    to assign to bone_torso




    Repeating the steps above we merge again and check it in Milkshape. The results
    are shown below:




    Much better! Now we're ready to put in game. Save the model (not the animated one).
    Then run stratmodelconverter.py and select your model. Mine is
    late_general_northern_mailed_knights.ms3d. This should produce a .cas file
    with the same name but with _converted appended to it (to prevent overwrites of original
    files).


    Now follow Alletun's tutorial for this part. In your mod folder under the data
    subdirectory you need to copy in descr_model_strat.txt. Under data you need to make
    a folder model_strat. Under this folder make a folder textures. Copy your model
    to model_strat then rename to late_general_northern.cas.
    The game wants .tga files so open en_lmail_hmail_england.dds
    in Photoshop and do a "save as" to late_general_northern_strat.tga choosing
    the Targa .tga format to save to. Copy this .tga to textures.
    Now launch your game with your mod folder and voila! you should see
    mailed_knights as your generals:




    So it's late at night, I'm done, but you're not. This only does england, you
    have to convert all the en_lmail_hmail_factionname.textures over to .tga files
    or all the other generals that use your new model are screwed up. The steps
    are the above, it just takes some Photoshop stuff.

    Acknowledgements: Many thanks to Alletun for the strat model reloaded tutorial and
    to the testers who used my first stab at this and found so many of the bugs.

    PS: I think I'm getting the hang of this modelling stuff now.

    Edit by Gigantus: this article is available with pictures here as PDF file.
    .
    Last edited by Gigantus; November 21, 2016 at 08:07 AM. Reason: updated link for PDF file

  2. #2
    Socal_infidel's Avatar PDER Piper
    Join Date
    Jan 2007
    Location
    Brooklyn USA
    Posts
    2,563

    Default Re: Python strat model converter for Milkshape Users

    Wicked awesome, mate!

    It's late here in NY or I'd try it out right now! And just when I finished the fifth of the seven things I wanted to do today for my mod....

  3. #3

    Default Re: Python strat model converter for Milkshape Users

    Wonderful! Thank you for the hard work, KE! This is something we have needed for a long while.

    On the issue of resources_wool.cas, I think that file actually loads pretty well using GrumpyOldMan's RTW .cas to Milkshape Ascii converter. At least I'm pretty sure I got a sheep to load. Not sure if that helps at all.
    Last edited by Averroës; January 03, 2008 at 11:44 PM.

  4. #4

    Default Re: Python strat model converter for Milkshape Users

    Thats a nice tutorial

    regards muscu

    p.s. can you upload this model, please!
    Last edited by Musculus Maximus; January 04, 2008 at 08:45 AM.

  5. #5
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Python strat model converter for Milkshape Users

    Thanks guys.
    @Averroes
    I tried GrumpyOldMan's converter and it worked so
    now I have a sheep. I put in the byte strings from resource_wine
    which had the same structure as resource_wool and it converted
    back to .cas format. I'll try it in game tonight.

  6. #6

    Default Re: Python strat model converter for Milkshape Users

    Ah, that's good news, KE!

  7. #7
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Python strat model converter for Milkshape Users

    Hi Averroes,

    First off I'm going to have to find a way of doing umlauts for your user name.
    Second, you're a genius, the proposed method worked perfectly. I put
    the little sheep in game with a red stripe on them to be sure, and there
    they are:



    So an odd file, but the work-around is just fine. Makes me think the .cas
    format is a lot more robust than I thought at first. (Yes, I know, so many
    off-color jokes abound regarding sheep, we are going to take the high
    ground here.)

  8. #8

    Default Re: Python strat model converter for Milkshape Users

    Quote Originally Posted by KnightErrant View Post
    Hi Averroes,

    First off I'm going to have to find a way of doing umlauts for your user name.
    Second, you're a genius, the proposed method worked perfectly. I put
    the little sheep in game with a red stripe on them to be sure, and there
    they are:



    So an odd file, but the work-around is just fine. Makes me think the .cas
    format is a lot more robust than I thought at first. (Yes, I know, so many
    off-color jokes abound regarding sheep, we are going to take the high
    ground here.)
    The ë? Simply enough. With the numlock on, hold down the left alt key and then, while still holding it down, on the number keypad type in 0235. Alt-0235 = ë

    Anything on the character map (Start/all programs/system tools in Windows) which comes up as having an alt+#### can be done the same way. Memorizing them is a different matter.

    And I'm no genius! When it comes to graphic programs I'm an idiot savant missing the savant part. If you flail about cluelessly and stumble around long enough, eventually you'll not stub your toe on something. That's all I did.

    And here I was so looking forward to a good sheep joke! I had my velcro gloves all handy and... oops, that one just sort of slipped out.

  9. #9
    Csatádi's Avatar Senator
    Join Date
    Sep 2005
    Location
    Budapest, Hungary, EU
    Posts
    1,153

    Default Re: Python strat model converter for Milkshape Users

    Cool!
    Thanks KnightErrant!

  10. #10
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Python strat model converter for Milkshape Users

    Uploaded the example strat model here:

    http://www.twcenter.net/forums/downl...o=file&id=1803

    along with the reworked resource_wool file. You'll notice resource_wool.cas
    is much smaller than the original because all the extraneous quad bytes at
    the end have been removed.

  11. #11

    Default Re: Python strat model converter for Milkshape Users

    its a realy nice work knight

    only we have a small problem with the texture from the sword, but i am working by that

    regards muscu

  12. #12
    Lord Condormanius's Avatar Artifex
    Join Date
    Dec 2006
    Location
    Derby, CT U.S.A.
    Posts
    6,439

    Default Re: Python strat model converter for Milkshape Users

    Nice tutorial. Unfortunately, I seem to be stuck. I have been through this 3 time, from start to finish. Everything seems to be moving along well until I try to put the model into the game. I get a CTD whenever I try to start the campaign.

    I have isolated the problem to the model. By which, I mean that the game has no problems with accompanying .tga when I removed the model from the mix. Can anyone tell me what I am doing wrong here. I have spent the better part of today trying to figure this out.

    Any help would be greatly appreciated.
    "There is a difference between what is wrong and what is evil. Evil is committed when clarity is taken away from what is clearly wrong, allowing wrong to be seen as less wrong, excusable, right, or an obligatory commandment of the Lord God Almighty.

    Evil is bad sold as good, wrong sold as right, injustice sold as justice. Like the coat of a virus, a thin veil of right can disguise enormous wrong and confer an ability to infect others."
    -John G. Hartung

  13. #13
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Python strat model converter for Milkshape Users

    Hi Lord Condormanius,

    I'll PM an e-mail address to you. If you could send your .ms3d file,
    I'll do the back conversion and try to figure out what could be going
    wrong with the output .cas file that is causing the CTD.

  14. #14
    Lord Condormanius's Avatar Artifex
    Join Date
    Dec 2006
    Location
    Derby, CT U.S.A.
    Posts
    6,439

    Default Re: Python strat model converter for Milkshape Users

    very cool. I'll get that to you asap.
    "There is a difference between what is wrong and what is evil. Evil is committed when clarity is taken away from what is clearly wrong, allowing wrong to be seen as less wrong, excusable, right, or an obligatory commandment of the Lord God Almighty.

    Evil is bad sold as good, wrong sold as right, injustice sold as justice. Like the coat of a virus, a thin veil of right can disguise enormous wrong and confer an ability to infect others."
    -John G. Hartung

  15. #15
    Lord Condormanius's Avatar Artifex
    Join Date
    Dec 2006
    Location
    Derby, CT U.S.A.
    Posts
    6,439

    Default Re: Python strat model converter for Milkshape Users

    ...in order for your model to work in the game, you need to have a models_strat folder in your mod folder that has ALL of the stratmap textures (in .tga format) that are used in your mod...even if they are the same as the vanilla ones.
    "There is a difference between what is wrong and what is evil. Evil is committed when clarity is taken away from what is clearly wrong, allowing wrong to be seen as less wrong, excusable, right, or an obligatory commandment of the Lord God Almighty.

    Evil is bad sold as good, wrong sold as right, injustice sold as justice. Like the coat of a virus, a thin veil of right can disguise enormous wrong and confer an ability to infect others."
    -John G. Hartung

  16. #16
    Werebear's Avatar For Mother Russia
    Join Date
    Jan 2007
    Location
    Russia, Moscow
    Posts
    2,519

    Default Re: Python strat model converter for Milkshape Users

    Tnx for tutor
    Last edited by Werebear; April 07, 2008 at 07:03 AM.

  17. #17
    Werebear's Avatar For Mother Russia
    Join Date
    Jan 2007
    Location
    Russia, Moscow
    Posts
    2,519

    Default Re: Python strat model converter for Milkshape Users

    How can i read error log of this script?

  18. #18
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Python strat model converter for Milkshape Users

    Hi Isilindel,

    Sorry for the delay in getting to your PM.
    You can have a persistant DOS box if you go to
    Start -> Programs -> Accesories -> Command Prompt
    Here you can start Python by simply typing python and
    then "import stratmodelconverter_ver1_1.py".
    Is the problem the UVs on an attachment? Strat .cas models
    only have one texture file so you might need to move it over
    to the Figure texture and simply move the texture onto the
    right spot with the pouch texture, if you can find space for it.

  19. #19
    Werebear's Avatar For Mother Russia
    Join Date
    Jan 2007
    Location
    Russia, Moscow
    Posts
    2,519

    Default Re: Python strat model converter for Milkshape Users

    .
    Last edited by Werebear; April 11, 2008 at 07:47 AM.

  20. #20
    KnightErrant's Avatar Decanus
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    578

    Default Re: Python strat model converter for Milkshape Users

    Hi Isilendil,

    Again, sorry for the delay. I got your .cas file
    and converted it to .ms3d and got an error from Milkshape about
    invalid triangles etc. But I get this picture:



    What were your steps so I can reproduce them? Did you convert one
    of the stratmap models and then put another geometry on them and convert
    back? That's what I'd like to try and duplicate where the problem appears.

Page 1 of 8 12345678 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
  •