1. This forum is obsolete and read-only. Feel free to contact us at support.keenswh.com

3dstudio MWM Import Export

Discussion in 'Modding Guides and Tools' started by johnwhile, Nov 15, 2014.

Thread Status:
This last post in this thread was made more than 31 days old.
  1. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    Hi all, this is my second topic and i don't know if i have authorization to post this tool because i know that files format are protected by developers, if not you can delete this post.

    The idea of this script is to access directly to MWM file and change everything with super-powerful-awesome 3dstudio max (also because is the only 3d program in my pc)

    The folder contain
    1. maxscript script
    2. mwm format (incomplete) , is a template for 010Editor, used for debug and investigations
    3. some mwm files used for testing
    https://drive.google.com/file/d/0B1DxE41r_VsiUzBsYmxlTTJhcW8/view?usp=sharing
    https://bitbucket.org/johnwhile/space-engineers-tools

    • Script rebuild internaly the BoundingVolumeHierarchy (BVH) file section
    • You can edit only Normal, the TBN matrix (Tangent and Binormal) are calculated internaly
    • In the setting.ini file there is the Content folder of game, so the script can directly access to textures path
    • I don't understand something abound animations
    • Havok Collision section will be not imported, i need to investigate more
    PS: i can do also a c# viewer (using sharpDx9) but make a 3d editor is long work... and i don't have enought free time :)


    Code:
    https://www.youtube.com/67eVBIfdUnc
     
    Last edited by a moderator: Feb 24, 2015
    • Like Like x 1
  2. Ignisum

    Ignisum Trainee Engineer

    Messages:
    5
    Hello there!
    Its definitely will be usefull, if you could include other options, like collision and materials export.
     
  3. Harag

    Harag Junior Engineer

    Messages:
    913
    If I understand the above correctly this script writes .mwm files directly.
    I have to wonder why this is better than exporting to .fbx and running the result through mwmbuilder?
    Writing your own exporter has the additional risk of being out-of-date.
    What would be the gain to the user to compensate for that risk?

    Wouldn't it be easier to script just the havok conversion and final call to mwmbuilder?
    Also, your effort is wasted on anybody not using 3DSMax.
     
  4. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    So there are something that mwmbuilder don't show or some features hidden by this tool ?
     
  5. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    Example i make a nuke missile

    [​IMG]
     
    Last edited by a moderator: Jan 4, 2015
  6. DerpTime

    DerpTime Trainee Engineer

    Messages:
    14
    i am
    im testing now
     
  7. DerpTime

    DerpTime Trainee Engineer

    Messages:
    14
    I'm a game developer in unity.
    Any thing that takes steps out of a pipeline for testing and debugging are coveted.
    many company spend thousands to take just 1 step out of a workflow. what this does is make it possible to test while editing the model on the fly.
     
  8. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    just a question, i add a billboarding rectangle in the missile geometry but i think is not possible use alpha blending for transparency because developers use the MRT technique and i don't know if there are a way to do this.

    (https://youtu.be/kWPazDo0BA4?list=UU3nB_lrVKiVvd-aQQBvdKJA)

    change particles make effect also for standard missile, and this is a thing what i don't want
     
    Last edited by a moderator: Dec 16, 2014
  9. DerpTime

    DerpTime Trainee Engineer

    Messages:
    14
    i think you can fake all alpha blended mats with the techneique they laid out for the transparent materials stuff laid out in the sbc files.
     
  10. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    in fact in the material section inside mwm file, the "technique" value is "GLASS" instead "MESH" , i will test it
     
    Last edited by a moderator: Dec 18, 2014
  11. Shadow_Flux

    Shadow_Flux Apprentice Engineer

    Messages:
    433
    I am watching this one very close! The ability to see my final object with collision; and adjust things in Max = hours of saved time.

    Down side is I really doubt compound objects like rotors, doors, pistons will ever be fully viewable / editable "on the fly".

    /saves .fbx
    /bulds .mwm
    /moves files
    /loads game
    /watches explosion
    /makes adjustments in Max
    /repeat 'til it works
     
  12. DerpTime

    DerpTime Trainee Engineer

    Messages:
    14
    sadly this doesn't work for me.
    I mean it works yes.... but opening characters and animations, just explode.
    But im about to start block building soon so this may be what i need soon.
     
  13. zeejfps

    zeejfps Trainee Engineer

    Messages:
    23
    How did you come across the way the .mwm file works ?

    As in If I wanted to make my own importer where can I find the necessary info about the .mwm file ?
     
  14. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    Sorry, i'm doing something else at this moment, about tool i have some issue with skeletons bones. In next upload iwill add also mwm file format informations if you want
     
  15. zeejfps

    zeejfps Trainee Engineer

    Messages:
    23
    Yes please provide me with the file format info, I want to write a blender importer.
     
  16. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    https://drive.google.com/file/d/0B1DxE41r_VsiUzBsYmxlTTJhcW8/view?usp=sharing


    OK, the file format is a usefull 010editor template : "mwm_format.bt", you can see the file format like screeshot:

    [​IMG]

    I "decode" about 90% of file by myself, i don't had developers suggestions so is possible some interpretations are wrong, if you find some correction please send me a message.

    1. Havok collisions not understand... i used it some years ago with 3dstudio max9 physic engine, but now the autodesk have implemented the havok internaly and i'm confused a little bit.
    2. The BoundaryVolumeHierarchy was rebuilded every time when esporting because is very stupid show these data in the 3dstudio scene, the algorithm was written in the C# library, a first test of algorithm was implemented in maxscript as debugger, now is deprecated.
    3. Just now i correctly build the skeleton and bone assignments, i will complete the export of these new data tomorrow. I don't know the blender coordinate system, so ask me if you have some issue converting transformation matrix between directx<->blender because i know is very confusing
    4. [​IMG]
     
  17. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    PS: i don't know if in blender you can directly load a library written in C#, if yes you can use my library in order that correct and implements more code, just for collaboration.
    The CommonLib was imported only because i reuse a math library written for learning purpose, are necessary only for basic vector, matrix and boundary operations, you can build your version. If you want the "spoon fed" already cooked you can find it here :p:
    https://bitbucket.org/johnwhile/directx9-with-sharpdx/src/3f9caf61a24547933cdcc676e2f982389a98f9d9/CommonLib/?at=master
     
    Last edited by a moderator: Jan 4, 2015
  18. zeejfps

    zeejfps Trainee Engineer

    Messages:
    23
    Thank you very much, I will take a look and if I have any progress I will share it with you!
     
  19. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    only an updating :
    maxscript tool with c# library binaries
    https://drive.google.com/file/d/0B1DxE41r_VsiUzBsYmxlTTJhcW8/view?usp=sharing
    the c# library source as git repository (the informatics like this :p) for a better share
    https://bitbucket.org/johnwhile/space-engineers-tools
     
    Last edited by a moderator: Jan 4, 2015
  20. zeejfps

    zeejfps Trainee Engineer

    Messages:
    23
    Hay I don't know if you realize this, or if I am doing something wrong but the Bytes are swapped....

    For example:

    A 65505 Half Float converted to hex is 7BFF or 2 bytes in binary as such:
    0111 1011 1111 1111, you can check the wiki on half floats.

    However the 101Edit will display FF7B, the two bytes are swaped.

    Just found that interesting.
     
  21. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    Yes i know, 010editor show bytes per byte in file stream order, example to deconde a int32 just select 4 bytes, ctrl+b to add a bookmark and see the result, or go to investigation menu. To decode halffloat you have to use last version of program because is a recent features. But is not very important, this program was used only for a first investigation, you have to do the conversion in your tool, example for vertex normal decode function i write a complex function in the template, but sometime i write a simple int32 value and decoded in the c# program.

    In c# library you can see many many controls every data, this because i dont know the file format and the program must exit at first wrong interpretation, example when read wrong array length, if you read a big integer the program can initialize an array = new int[4000000] ? This is bad, especialy when run as third part in blender or 3dstudio, can crash
     
    Last edited by a moderator: Jan 5, 2015
  22. zeejfps

    zeejfps Trainee Engineer

    Messages:
    23
    Ha I wrote my own half float to float converter because Python doesn't support half floats, I am now able to read in all the vertex data, so I should be able to at least import the mesh into blender, will post if I have any more profress
     
  23. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    important fix that i will implement in the c# library: to convert between different coordinate system i found a easy way, because i know that this confusing a lot when build a tool

    where ScaleFactor = 100 (get from file)


    Code:
    3DStransform = CoordSystem * D3DXtransform * (CoordSystem^-1) 
    3DStransform.traslation = 3DStransform.traslation * ScaleFactor 
    
    
    D3DXtransform = (CoordSystem^-1) * 3DStransform * CoordSystem
    D3DXtransform .traslation = D3DXtransform .traslation / ScaleFactor 
    
    
    3DSposition =  CoordSystem * D3DXposition * ScaleFactor
    D3DXposition=  (CoordSystem^-1) * 3DSposition / ScaleFactor
    where vector w component = 1.0
    
    3DSnormal =  CoordSystem * D3DXnormal
    D3DXnormal=  (CoordSystem^-1) * 3DSnormal
    where vector w component = 0.0
    all depend by CoordSystem matrix, for 3dstudio is
    Code:
    |  1  0  0  0 |
    |  0  0 -1  0 |
    |  0  1  0  0 |
    |  0  0  0  1 |
     
  24. zeejfps

    zeejfps Trainee Engineer

    Messages:
    23
    Started a Thread on a Blender (.mwm) Importer here :Link
     
    Last edited by a moderator: Jan 6, 2015
  25. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    Good news, now i complete the Skeleton part of the script, in the video i try to add a new character model (Halo soldier).
    It's just a test, i set quickly the bone assignments in the skin modifier and i don't make texture, in the video you can see that bone assignments work.

    https://youtu.be/67eVBIfdUnc

    Is a work in progress so before a tutorial i need to test more.

    Current features
    • All geometries have exactly the same size and orientation of FBX version created with original game tool, this because you can interchange the models
    • Very important : Dummies and Bones use all transformation information : Scale, Rotation , Traslation,... so if you rescale a bone with 3dstudio tool you can have a undesirable effect with animations.
    • Mwm use "only" 4 bones per vertex to blend it position, if you assign more than 4 bones the script get the most 4 relevant weights
    • Skin modifier define if a geometries is static or animatable
    • To recognize the mwm file from generic 3dstudio scene, all objects name have prefix "Mwm..."
    • All information are stored in objects name and objects properties (see dummies objects, a text is write into properties text box)
    • The script recognize the Content folder of game and try to search the texture inside it, if not found it simply write the local filename path (but you can't see any image)
     
    Last edited by a moderator: Jan 8, 2015
  26. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    Ok, i can import new characters... but i noticed assign vertex blend for 64 bones is very hard, for me if it require more than 5 minute of work i consider very hard ,
    i need urgently a tool that automates all :woot:

    halo character mod : https://drive.google.com/file/d/0B1DxE41r_Vsia2hmcklLTTJUclk/view?usp=sharing

    contain the HALO_fix.max ready to be esported.

    I make a simple auto skin tool that auto-assign the vertex to bones, but need to improve
     
    Last edited by a moderator: Jan 10, 2015
  27. Shadow_Flux

    Shadow_Flux Apprentice Engineer

    Messages:
    433
    Some of my custom mwm import fine, others are 'smooshed' in areas. Any ideas?
     
  28. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    wait, i found many new information about mwm format, i will update tomorrow
     
  29. johnwhile

    johnwhile Trainee Engineer

    Messages:
    45
    done, now i'm try to import animations.
    I make a little tool (pre-alpha) to assign automatically the bone weights for each skin modifier, can be usefull example for a first step in character edit

    Sometime you can see in game all triangles flipped, this because 3dstudio use a lot of custom mesh structure, and game want only standard x format, so is possible a wrong conversion, to resolve you can simply import the wrong mwm, flip face and re-export.
    Also when you use unwrap-uv modifier, if you break the face in the texcoord editor, 3dstudio DON'T detach them in the mesh, so some duplicated-texcood will be collapsed to one. When i finish the script i will fix all this mistakes.
     
    Last edited by a moderator: Jan 13, 2015
  30. Shadow_Flux

    Shadow_Flux Apprentice Engineer

    Messages:
    433
    After re-reading my issue I decided to expand on the description a little; I know more information would probably help :)

    I love the concept of the script, it would simplify getting models into the game; closer to correct the first time.
    So I downloaded (actual link for this is hard to find, should update OP)
    Eventually installed (no install directions, some of us are smart like rocks and need step by step)

    I imported one of my mods that was already working fine in game. open mwm
    it asked to set content folder, as a modder I do not have a content folder under mods; just folders for each modpack.
    Can we get it to let us pick ANY folder as the root, and maybe a button to change this as needed?

    The model imported under a new name (not a fan of that) most models are not in a scene and therefore do not get lost.
    The model was very small, not sure if it simply default zoomed way out or was a sizing import issue.

    The deal breaker was half of the model was crushed, smooshed, flattented...
    Like a rogue gravity helper was assigned and randomly pulled faces and vertices all together.
    This was only on the left side of the model, right side was fine; maybe slightly stretched but very close to origional.

    It even loaded up the texture maps, awesome!
    I tried a smaller 1x1x1 model and it loaded just fine.

    Anyway, I figured I would give you some feedback and bug reporting. You have put a huge amount of work into this and I love it!
    Just the ability to open a mwm and adjust dummies is a huge time saver (ability to export right back to mwm)

    Keep up the good work and let me know if you require any additional information.
     
Thread Status:
This last post in this thread was made more than 31 days old.