1. Are you planning to upload your awesome tool to Hive? Please review the rules here.
    July 9, 2018: The rules for the Tool Section have been revised. Please be sure to read the revisions.
    Dismiss Notice
  2. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  3. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  4. Lead your forces to battle in the 15th Techtree Contest. The call is yours, commander!
    Dismiss Notice
  5. The reforging of the races is complete. Come see the 14th Techtree Contest Results.
    Dismiss Notice
  6. It's time to choose your horse in the race - the 32nd Modeling Contest Poll is up!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Model Optimizer and Converter v1.1.5

Submitted by loktar
This bundle is marked as approved. It works and satisfies the submission rules.
Model Optimizer and Converter
  • Batch processing.
    • Drop files/folders on the window
  • Reforged support
    • MDL output can't be read by Retera's Model Studio 0.4
  • Check the tooltips for more info about the options
  • Separate CMD executables
    • --help
      for info about the options
    • Drop files/folders on the executables

Big thanks to @GhostWolf and @Retera for their help, their code, and their software.
Also a big thanks to @Macadamia for his invaluable feedback.



  • Merge similar geosets (same material, selectiongroup & identical geoset animation)
  • Delete empty geosets (after delete/merge vertices)
  • Delete unused nodes/merge identical nodes
  • Delete unused keyframes
  • Delete useless keyframes
  • Delete unused geoset animations/merge multiple for the same geoset
  • Delete unused/duplicate textures
  • Delete unused materials/merge identical materials
  • Delete 0-length global sequences
  • Linearize animations
  • Sanitize
  • ...

v1.1.5
- Considering normals when merging vertices is now optional (default off)
- Added "Delete 0-length Sequences" option
- Removed "Reforged Data" checkbox (always written now)
- Changed window title to "MOP"

v1.1.4
- Fixed 0-value Tangents and SkinWeights being written to >v800 models without this data
- Improved RMS 0.4 Reforged MDL reading
- Misc fixes

v1.1.3
- Fixed a bug with writing MDX files without any FaceFX
- Miscellaneous bugfixes/crash fixes
- Added partial support for reading Reforged MDL files written by RMS 0.4
- Unknown tokens will once again cause MDL loading to fail
- Moved suffix options to Optimize and Convert Options respectively
- Magos Compatibility now only applies to v800 models
- Magos Compatibility disabled when Version 900/1000 checked
- Fixed CMD processing
- Changed the way CMD options/arguments work

v1.1.2
- Fixed a crash that could occur when merging vertices
- Merging vertices is now faster
- Merging vertices now requires identical vertex groups
- Fixed a bug with writing Color to Geoset Animations
- Fixed automatic filenaming (increment & suffix)
- Fixed ignored tokens' attributes not being skipped
- Checkboxes are now disabled when appropriate

v1.1.1
- Changed UI layout a bit
- Added radio buttons for preselection of file conflict handling
- Improved messages and added filesize difference
- It' now possible to process files when neither Optimize or Convert are checked
- Added "suffix" option for file conflicts
- Fixed a bug that would sometimes cause a crash
- Fixed Reforged model optimizing causing a crash
- Fixed Reforged data not being written to MDL files when not converting
- Unknown tokens will no longer cause parsing MDL files to fail
- Fixed layer TextureID token not being recognized
- Improved floating point rounding

If you encounter any problems or have any more ideas, let me know :)
GitLab repo
Previews
Contents

Model Optimizer and Converter (Binary)

  1. eejin

    eejin

    Tool Moderator

    Joined:
    Mar 6, 2017
    Messages:
    153
    Resources:
    1
    Tools:
    1
    Resources:
    1
    A very useful tool in theory, although I tried the linked LickKing2.mdx model and got no improvements.
    1. downloaded the Lick King
    2. Converted to .mdl with this tool
    3. Used the most aggressive settings
    upload_2020-3-13_20-34-29.png
    4. Saw a moderate reduction in .mdl filesize
    upload_2020-3-13_20-39-4.png
    Converted back to .mdx I saw the same size as the input which makes sense for the decimals since its a binary format, but not for the other parameters.
    Is this expected behaviour or am I using a wrong converter? You are citing a reduction of 98.7% (or is it a reduction of 1.3%?).
     
    Last edited: Mar 13, 2020
  2. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    1,093
    Resources:
    34
    Models:
    11
    Icons:
    16
    Packs:
    1
    Tools:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    34
    Hey, thanks for the feedback.

    It's a reduction of 1.3% (2KB), so on my end I ended up with a 159kb file. The difference is very small right now as I haven't added many options yet. Building models (at least Blizzard models and edits) will probably benefit most because they tend to have a lot duplicate vertices.

    It looks like no vertices were removed on your end, but 38 were removed here. When I disable that option I get 161kb too.

    Could you send me both the mdl files (original and optimized) so I can take a look?
    I've been using Mdlvis to convert, maybe the formatting is different somehow. Although I would expect an error to pop up if that was the case.

    Or maybe the converter you used adds some random (very small) decimals to the vertex coordinates?
    The number rounding happens only after optimization, I should change that :p
    Edit: or maybe Mdlvis cuts off some decimals, I'll download the converter you linked later and test it out.
    Edit2: they seem to handle float/double precision differently, some numbers have more decimals with one of them and some with the other. I'll do some comparing between them and Magos to see how best to handle these differences.

    edit: made the description clearer
     
    Last edited: Mar 13, 2020
  3. eejin

    eejin

    Tool Moderator

    Joined:
    Mar 6, 2017
    Messages:
    153
    Resources:
    1
    Tools:
    1
    Resources:
    1
    The reductions are indeed not big, but might grow in the future. Would be cool to at some point run this tool on the whole of the Hiveworkshop model database with safe settings. Approved!
     
  4. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    1,093
    Resources:
    34
    Models:
    11
    Icons:
    16
    Packs:
    1
    Tools:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    34
    Thanks! I found a newer version of MDLX converter in a post there, and it's possible to have my program use it to convert models. Apparently that's what Retera's model studio does too.
    So in the next version I'll add MDX support ^^
     
  5. Clanzion

    Clanzion

    Joined:
    Jul 4, 2016
    Messages:
    438
    Resources:
    0
    Resources:
    0
    a update to date model optimizer is always nice but how does this compare to the Ghostwolf's mdx squisher?
     
  6. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    1,093
    Resources:
    34
    Models:
    11
    Icons:
    16
    Packs:
    1
    Tools:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    34
    If I understand correctly, it changes the precision of some of the binary data, which almost certainly won't be added in this tool.
    The deleting of useless keyframes may be added here, and linearizing animations definitely will be. It depends on how much time I end up putting into this.

    This tool optimizes by deleting useless data and merging duplicate data (e.g. identical vertices). Both tools can be used together.
     
  7. MaximBit

    MaximBit

    Joined:
    Nov 12, 2017
    Messages:
    7
    Resources:
    0
    Resources:
    0
    Good)
     
  8. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    1,093
    Resources:
    34
    Models:
    11
    Icons:
    16
    Packs:
    1
    Tools:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    34
    Thanks! =) Working on reimplementing ghostwolf's mdlx parser, so next update will have mdx support (probably no mdl support though, because it's probably not worth the effort).
    After that updates should come faster with more options =)
     
  9. Mythic

    Mythic

    Media Manager

    Joined:
    Apr 24, 2012
    Messages:
    8,009
    Resources:
    124
    Models:
    107
    Icons:
    6
    Maps:
    3
    Spells:
    6
    Tutorials:
    2
    Resources:
    124
    [​IMG]

    Thank you for this.
     
  10. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    1,093
    Resources:
    34
    Models:
    11
    Icons:
    16
    Packs:
    1
    Tools:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    34
    Ooh, those are some nice results :D
     
  11. Unregret

    Unregret

    Joined:
    Jun 15, 2016
    Messages:
    752
    Resources:
    1
    Maps:
    1
    Resources:
    1
    This is absolutely useful for heavy data map and testing.
     
  12. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    679
    Resources:
    0
    Resources:
    0
    Wow, how did I miss that.

    Jumping on this right now as I use @Mythic 's Ember forge and other great models or model parts from the Starfall Empire !!!

    This tool is amazing. One of the model I made by combining a part of one the models from the Starfall Empire and my rolling ball model ended up making a smaller MDL than the MDX file !

    The final MDX went from 339kb to 87kb. It shows how much redundant data I had left over!!!

    This said I have encountered a problem with a reforged model I heavily edited with Retera Model Studio and NotePad++ in MDL.

    Your program threw an error :
    "
    ----------------------

    Loading Frostmourne.mdl ...

    Line 5741: Unknown Geoset property: Tangents


    ----------------------"

    Are you going to be able to add the support for them ?

    Thanks, anyways in the meantime, well deserved +rep and rating.
     
    Last edited: May 3, 2020
  13. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    1,093
    Resources:
    34
    Models:
    11
    Icons:
    16
    Packs:
    1
    Tools:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    34
    Thanks! That's a crazy difference :D
    Next version will have MDX support so any model should be able to load, including reforged models. I'm curious to see the results on reforged models.

    It will probably be ready some time this month.
     
  14. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    679
    Resources:
    0
    Resources:
    0
    Great news, I can't wait !!!

    Optimizing MDX directly seems to be for the best, even if I tend to do much of the work in MDL, just because we can so easily convert them.

    In the meantime, I will have to play around with the decimal depth, all my attempts were made with 6 decimals so far, I suppose I could use much less for models with a small scale, or where I suspect many coordinates have values very close to the nearest integer.

    By the way do you round the values or truncate them ?

    Anyways, wonderful job, really will be looking forward to your next release !!!
     
  15. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    1,093
    Resources:
    34
    Models:
    11
    Icons:
    16
    Packs:
    1
    Tools:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    34
    They should be rounded not truncated.
    Generally I would recommend 6 decimals as a safe setting, but yeah in some cases less could be fine, just be sure to keep a backup :p

    I don't think the rounding itself makes much difference (if any) in MDX filesize though, any float takes up 4 bytes afaik, but it can influence the other optimizations, more so when I add more in the future.
     
  16. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    679
    Resources:
    0
    Resources:
    0
    Yes I completely understand what you mean. But if it can influence your other optimizations, it still remains useful.

    To be honest, in tiny models, I often used to round some values for readability, like all these near null numbers like 1.123456e-07. I also suppose it can even slow (even if in a ridiculous scale) a 3D engine as I suppose it takes less time to process operations with a value of 0.0 than with such infinitesimal value, but I might also be wrong.

    Anyways it still will help me greatly when doing MDL editing as the manual rounding can take a while, even with Notepad++ pattern searches.
    This means that I might even keep using this old version (for models without tangents) when I will do MDL editing that does not require a tool like Retera Model Studio Hack or Magos Model Editor.

    EDIT :

    @loktar : it seems the precision can be altered for binaries, and has in fact an impact, like I just read there : MDX/M3 Optimizer

    Now I realize my frostmourne edited model that your optimizer refuses to load also doesn't load in Magos's Model Editor or this Optimizer I linked.

    I initially thought it was because the source was a reforged model, but for some reason the same issues appears with some older models. This is strange, errors are not verbose enough for me to trace the issue though...

    EDIT 2 :

    One of my models opens perfectly in Retera Model Studio or Magos Model Editor, but crashes your MDL Optimizer. I just attached the MDL file for you to have a quick look and try to figure out what is wrong.
     

    Attached Files:

    Last edited: May 5, 2020
  17. Macadamia

    Macadamia

    Joined:
    Jan 30, 2020
    Messages:
    679
    Resources:
    0
    Resources:
    0
    Update !

    All I wanted is give a small extra feedback :

    - the MDL optimizer seems to crash when there are no optimizations needed...
     
  18. loktar

    loktar

    Joined:
    Nov 2, 2004
    Messages:
    1,093
    Resources:
    34
    Models:
    11
    Icons:
    16
    Packs:
    1
    Tools:
    3
    Spells:
    2
    Tutorials:
    1
    Resources:
    34
    Yeah, the optimization thread doesn't tell the main thread properly that it's done when there's nothing to do. It also crashes when you close the program while the thread is still busy.
    Should be fixed with the next version, the converter doesn't have this problem :p
     
  19. iNfraNe

    iNfraNe

    Joined:
    Jun 18, 2004
    Messages:
    116
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Hello!

    I'm liking the simplicity of the tool, cheers for making it.

    The 'Merge Identical Vertices' does not seem to function properly. I have a very simple model exported from blender, which tends to give duplicate vertices. Here are the vertices:
    Code (Text):

    Vertices 34 {
            { 38.4, -38.4, 0 },           <======
            { 63.003, -37.754, -2048 },
            { 38.4, -8.636, -2048 },
            { 70.330, -66.871, -2048 },
            { 63.003, -52.636, 0 },
            { 70.330, -66.871, 0 },
            { 38.4, -8.636, -2048 },
            { -38.4, -38.400, 0 },
            { 38.4, -38.4, 0 },          <======
            { -63.003, -37.754, -2048 },
            { -38.4, -38.400, 0 },
            { -38.4, -8.636, -2048 },
            { -70.330, -66.871, -2048 },
            { -63.003, -52.635, 0 },
            { -63.003, -37.754, -2048 },
            { -38.4, -38.400, 0 },
            { -63.003, -52.635, 0 },
            { -70.330, -66.871, 0 },
            { 38.4, -38.4, 0 },           <======
            { 63.003, -52.636, 0 },
            { 63.003, -37.754, -2048 },
            { 70.330, -66.871, -2048 },
            { 63.003, -37.754, -2048 },
            { 63.003, -52.636, 0 },
            { -38.4, -8.636, -2048 },
            { -63.003, -37.754, -2048 },
            { -63.003, -52.635, 0 },
            { -38.4, -38.400, 0 },
            { -70.330, -66.871, -2048 },
            { -70.330, -66.871, 0 },
            { -63.003, -52.635, 0 },
            { 70.330, -66.871, 0 },
            { 63.003, -52.636, 0 },
            { 38.4, -38.4, 0 },    <======
        }
     
    I've shown some duplicates with <======, but there are many more (in fact, the model has 12 vertices in blender).

    I've also tried running the optimized mdl through the program again, but still didnt catch the identical vertices.
     

    Attached Files: