Results 1 to 17 of 17

Thread: ms3d Import/Export for 3ds Max and GMax, version 1.1

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

    Default ms3d Import/Export for 3ds Max and GMax, version 1.1

    This is an update to the importer/exporter of Milkshape .ms3d files into
    3ds Max and Gmax. Monkwarrior and I have added two new buttons for
    importing and exporting geometry only parts of a model and along the
    way found and corrected three bugs (described below). You can find
    the script and some other files here:

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

    The zip file contains the MaxScript ms3dimportexport_ver1_1.ms, the original
    readme.txt file, now called readme_ver1_0.txt, a readme_ver1_1.txt file
    which contains the information from this post in a little more detail, and
    two files needed by Gmax users but not by 3ds Max users. The script can
    be placed in your scripts subdirectory or any place convenient to your
    workflow. Click the Max Script menu item, then Run Script, then mouse
    to the directory containing ms3dimportexport_ver1_1.ms and double click
    to run it. It will display a simple rollout with "import ms3d file",
    "export ms3d file", and the two new buttons, "import geometry only"
    and "export geometry only".

    The two new buttons can be used this way. Suppose one likes a shield
    on one model and wants to use it on another model or several other models.
    Import the full model using "import ms3d file" and then click
    "export geometry only". This will display a listbox containing the meshes
    in the scene. Double click an entry to select it. Your selection will be
    echoed in the listener. You are not limited to a single selection so
    double click all the meshes you wish to export; they will also be echoed
    in the listener. The script does check if you select an item twice which
    it doesn't allow. Click the "finished selecting" button when done.

    (1) If you are a 3ds Max user the script will open a file chooser for you to
    enter a name for the .ms3d file to save to. It will then write the file.

    (2) If you are a Gmax user the script exports the data to the listener just
    like exporting a full model. You then have to use the supplied MaxSLGRAB.exe
    utility to copy the data from the listener into an
    ASCII text file that you name. Then you have to run the Python
    ascii2ms3dconverter.py utility to convert it into a binary .ms3d file
    with the same name but .ms3d extension.

    You can then reset and import a desired model you want to add your
    saved shield to. Delete the shield you don't want and then click the
    "import geometry only" button and select the file you saved previously.
    The desired object should appear in the scene. If you exported a fully
    defined object, that is, one with uv coordinates and bone assignments
    and weighting, that information is preserved and a skin modifier will be
    put on the object.

    -------------------------------------------
    MORE ERROR CHECKING
    -------------------------------------------
    On export the script now checks for defined grouptypes and groupflags.
    Rather than just stopping with an error, it now prompts you to enter
    these. On exporting a full model without a bounding sphere, it tells you
    it is supplying a default one. If it finds an unassigned vertex, it will inform
    you which mesh the problem occurs in and then terminate.

    -------------------------------------------
    BUG FIXES
    -------------------------------------------
    Fix 1: Most glaring bug is that the uv maps are upside down in version 1_0.
    The correct transformation was in Vercingetorix's script, I just didn't
    see it. It is v -> 1 - v when converting from meshes and Milkshape to
    3ds Max and Gmax. This is now done for all imports and exports.

    Fix 2: A more subtle bug, again correctly done in Verc's script, is that
    texture vertices and geometry vertices have no 1-1 correspondence in
    3ds Max. You don't notice this if you just import a model and then export
    it because they do have a 1-1 correspondence in a mesh file. Here's the
    documentation on the subject.


    It is very important to note that

    A - There can be more or less texture and color vertices than there are mesh vertices

    B - There are always exactly as many mesh faces as there are texture and color faces!

    So there is no one-to-one correspondence between mesh vertices and texture and color vertices.
    You cannot take vertex number 10 from the mesh and expect that texture vertex 10 will store
    the information about its texturing or color vertex 10 would define its vertex color.

    As mentioned in B , the number of faces is always identical. Not only this, the indices of
    the mesh and texture resp. color faces have a one-to-one correspondence! If face 5 has 3 mesh
    vertices you are interested in, their corresponding texture vertices will be the 3 vertices
    referenced by the texture face number 5.

    This is the key to access to texture and color information in 3ds Max!


    Finding the corresponding vertices

    In order to find out which texture vertex corresponds to a mesh vertex, you have to do the following:

    1. Take the index of the mesh vertex.

    2. Find out which faces reference the index of the face.

    3. Note the number of the vertex (1st, 2nd or 3rd - .x, .y or .z) inside each face.

    4. For each face referencing the vertex, get the texture face with the same index.

    5. Get the index of the respective texture vertex from the face - 1st, 2nd or 3rd / .x, .y or .z

    6. The vertex you got corresonds to the mesh vertex we started with.

    7. Repeat steps 3 to 6 for all faces found.

    Same applies to color vertices.
    The release notes in the header comments of ms3dImportExport_ver1_1.ms
    have the commands you have to use to implement the above algorithm.


    Fix 3: For animated files I said I had computed the basevert_array so that
    on back conversion you obtain the basepose when you open the file in
    Milkshape. Well, that was half true, you get the basepose if you are a
    Gmax user but I forgot to implement that for the 3ds Max side. There you
    get the regular vert_array which would be whatever animation frame
    was displayed when you exported. The animation data in the bones was
    still correct, you just got a distorted mesh that would look terrible if you
    played the animation in Milkshape. Now on the 3ds Max side, it looks at a
    flag to decide if there is animation data present and stored in the root
    bone (an animheader entry). If so, it writes out the basevert_array.

  2. #2

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    Hi, I'am a noob at this so how do you use the GMaxSLGRAB?

  3. #3

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    Ok, I found out how to export but, where dose the export go?

  4. #4
    Member Member KnightErrant's Avatar
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    458

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    @Arron Swan
    Apologies, didn't check the thread Christmas Eve. The grab
    utility will send the contents of the Gmax listener to a file that
    you name. If I'm modifying a unit called xxx, I'll send it to
    xxx.txt when the grab utility puts up its file chooser. Then I
    run the Python utility ascii2ms3dconverter.py by double clicking on
    it and then choosing xxx.txt in its file chooser. This will create
    a .ms3d binary file called xxx.ms3d. Then you can use GrumpyOldMan's
    converter to make a .mesh file out of it to put in game. (Of course
    you have to follow all the battlemodels.modeldb and EDU, EDB steps for
    adding new units.)

  5. #5
    Notepad user Member Red Spot's Avatar
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    491

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    I'd like to thank you for your excellent tool KnightErrant, this may explain why;
    https://forums.totalwar.org/vb/showthread.php?t=97147

    I can now get the cool units into the good engine .. :D ;)


    G

  6. #6

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    I've installed Gmax and unzipped all of the files into the scripts folder, but every time I try to open an MS3D file the Applying Weighting progress bar reaches about 4% and I get an error message (which I've put in the next post as I can't add an URL to my first one).

    Do you have any suggestions on where I may have gone wrong please? I'm a complete beginner to this so I've probably done something really simple, any help would be greatly appreciated.

    Thanks, Jaypydy

  7. #7

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1


  8. #8

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    I have it working now - thanks KE

    I did a clean install and chose the Direct3D graphics option - not sure if this was the issue but it might help if anyone else has the same problem.

    p.s. How do you edit your posts on here?

  9. #9

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    I have a problem with this script:

    1)I have a model someone else made in 3ds Max, no bones or anything just the model.

    I imported a game model with your script (no problems) and used/tied/skinned its skeleton to with my above model.

    The exporter doesn't work!

    The following error pops up:


    In this bit of code:


    And if I comment out the the "append parentindex_array 0" line a bit above, I get the same error except "... got undefined"

    What am I doing wrong? And is there any (quick) way to rewrite the script to use the dedicated "bone" object 3ds max has for bones? (Because then I could use another exporter)

  10. #10

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    Never mind - I figured it out. I'm an idiot for not having seen sooner.

    When you select bones in 3ds Max, it shows them (in the skin modifier window) by alphabetical order - so the first bone in the list is (with index 1) "bone_abs". And according to the script, the first bone has to be the root "bone_pelvis". You can't select them all at once, you have to select one by one according to the right order

    All the bones have to pretty much follow the hierarchy you get when importing an ms3d scene, as far as I can see and with the limited testing I've done. Changing the script to account for this wouldn't be too hard, I think, but since it isn't mine in the first place...

    Here is the order if anyone needs it:
    Code:
    For bone index 1, bone name is   bone_pelvis
    For bone index 2, bone name is   bone_rthigh
    For bone index 3, bone name is   bone_rlowerleg
    For bone index 4, bone name is   bone_rfoot
    For bone index 5, bone name is   bone_abs
    For bone index 6, bone name is   bone_torso
    For bone index 7, bone name is   bone_head
    For bone index 8, bone name is   bone_jaw
    For bone index 9, bone name is   bone_eyebrow
    For bone index 10, bone name is   bone_rclavical
    For bone index 11, bone name is   bone_rupperarm
    For bone index 12, bone name is   bone_relbow
    For bone index 13, bone name is   bone_rhand
    For bone index 14, bone name is   bone_lclavical
    For bone index 15, bone name is   bone_lupperarm
    For bone index 16, bone name is   bone_lelbow
    For bone index 17, bone name is   bone_lhand
    For bone index 18, bone name is   bone_lthigh
    For bone index 19, bone name is   bone_llowerleg
    For bone index 20, bone name is   bone_lfoot
    For bone index 21, bone name is   bone_weapon01
    For bone index 22, bone name is   bone_weapon
    For bone index 23, bone name is   bone_weapon02
    For bone index 24, bone name is   bone_weapon03
    For bone index 25, bone name is   bone_shield01
    For bone index 26, bone name is   bone_shield

  11. #11
    Member Member KnightErrant's Avatar
    Join Date
    Jan 2007
    Location
    Huntsville, Alabama USA
    Posts
    458

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    Hi Tchouk,

    You've got a gift for Max Script. The bone hierarchy for human
    models is just as you've pulled it out. I'm not sure what your question
    is but if you want to accomplish something and need a fix to the script
    I can try and modify it. I'm interested in this because I'm trying to
    incorporate the siege engine animations into the converter and they
    have the .mesh bones out of order with the way the bones are done
    in the .cas file animations. This has caused no end of confusion in the
    coding but I think I've finally found one rational way of making the converter
    work for all units. Send me a PM if you need a solution to a model/animation
    problem I can look at.

    Yes, the object chooser does show bones by alphabetical order but
    thankfully when you access them in Max Script they're kept in the order
    that you make the skeleton with; if that wasn't true I'd give up and hide
    under a bedsheet.

    Cheers,

    KE

  12. #12

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    Thanks, KE, you flatter me!

    But it's the first time I've opened the damn thing and I am mostly thoroughly lost.

    For example: I get a CTD when the game loads the mesh file of my unit.

    I did the following test: mesh (a vanilla one) -> ms3d (using your python script) -> then load it into 3ds Max, export it back to ms3d (without changing anything) and back into mesh (again, your scripts)

    The game still crashes!

    And I don't think it did before, although I'm not 100% sure.

    It's driving me absolutely nuts.

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

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    Hi Tchouk,

    Tell me which vanilla mesh you did your test with. I'll try doing the same
    thing and compare the back converted mesh file to the original to see where
    it's getting bugged up.

  14. #14

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    I dont understand how to export i am trying to convert dff files and get it in milkshape but I have the dff file in gmax i use the export thing but i dont understand it comes up with an errer for every mesh had no modifiers, in paricular, it has no skin but if it has exported where would i find it i am sorry for my ban english and i am a beinginer to this kinda of work normaly I import and obj mesh in to milkshape and make it in to sims 2 car

  15. #15

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    Where can I get examples of 3d Max works? Hi, I'm a beginner and want to master 3D Max. I want to know where I can see examples of 3D images and animations done with 3D Max and the procedures of how they are made.

  16. #16

    Default Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    I'm a beginner. Very nice script file. I have successed imported the ms3d file.And I want to ask a question, how can I use (Vint CAS Tools) or (.CAS Importerexporter for 3ds_max) to import animation. I want to modify the animation. I got error after i imported the animation. So can help me? show some images or details.

  17. #17

    Thumbs down Re: ms3d Import/Export for 3ds Max and GMax, version 1.1

    Hey when i click "Export ms3d" i get these errors i recorded--

    Error 1- Mesh Line03 does not have a skin modifier, cannot export. If this mesh is not part of your model you can delete and try again
    Error 2-Mesh Line01 has no modifiers, in particular, no skin modifier.
    Error 3-Mesh Line04 has no modifiers, in particular, no skin modifier.
    Error 4-Mesh Tube01 does not have a skin modifier, cannot export. If this mesh is not part of your model you can delete and try again

    i could really use an explanation thanks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Single Sign On provided by vBSSO