Is there an exporter for 3dsmax which can actually export skinned skm file?

Discussion in 'General Modification' started by corprus, Nov 12, 2014.

Remove all ads!
  1. corprus

    corprus Member

    Joined:
    Oct 31, 2014
    Messages:
    10
    Likes Received:
    0
    Hi, everyone, i'm new here.
    recently i'm working on adding some self made weapon models to Toee.
    I searched this forum and found Leksey's toee impexp plugin. But it only works for previous version of 3dsmax such as 7 and 8. So i downloaded the source code and rebuild it to max2010. For rigid mesh like sword, axe, mace, it works fine. but exporting skinned mesh like armor, dress is still not implemented.
    So i just wondered how you guys export custom made skinned mesh into skm?
     
  2. Shiningted

    Shiningted I want my goat back Administrator

    Joined:
    Oct 23, 2004
    Messages:
    12,654
    Likes Received:
    352
    Search for threads by XVicious, I believe he made the breakthrough there.
     
  3. corprus

    corprus Member

    Joined:
    Oct 31, 2014
    Messages:
    10
    Likes Received:
    0
    I will go check XVicious' thread immediately, Thank you Shiningted.

    It looks like he already made a toolset for import/export and i will see if i can intergrate those steps into a pair of impexp plugin for max.
     
  4. corprus

    corprus Member

    Joined:
    Oct 31, 2014
    Messages:
    10
    Likes Received:
    0
    I was writing an importer plugin for skm file to 3dsmax and when read the bone assignment data( as i was trying to load the bone armor addmesh for human male), there are several 'ref' bones which i still dont know what them used for exactly. Since they are bones, i imported them into the scene just like the other 'biped' bones. But the problem is those 'ref' bones have scaling factor within their inverse-world matrix and some of them has relatively large translation value compare to the other 'real' bones. So the result is the imported ref bones are way too larger than most other biped bones, but generally they still composite the standard binding T-pose.
    Anyone encountered this before? Did i miss something in the process or is it normal and should just ignore it?
     
  5. XVicious

    XVicious Established Member

    Joined:
    Jun 21, 2013
    Messages:
    427
    Likes Received:
    8
    If you are trying to manipulate the SKM without using the template SKM theory; BTW I did not use the importer by lasky either due to that reason;

    here is what I did,

    I export the Mesh data: vertex, normals, texture coords,
    into an OBJ data type file editable by some CAD programs (anim8or, blender,Maya).

    I export the bone and material data into a seperate file, called SKB.

    I then export the Obj file from the Cad, then inject it back into the SKM with the SKB.

    So the file retains its Header and material and Bones original data, but the edited mesh Vertex data is inserted back into the original coupled with its original Bone/weights struct (from the SKB file I export from original).

    if you do it this way, never change the Vertex count only change the FACE/triangle index, because Python alots memory dynamic via info that is compared with both SKM and SKA, else if you do (never attemted) you would need to change the base pose defined in the SKA animation file. IF these files are missing anything and there sizes in memory are not the same your game will crash to desktop, because you would have tryed to access memory out of bounds, or got the access denied bad address BAD POINTER CRASH.

    crash like:
    _______________________

    int vert[10];
    printf("%d", vert[100] );
    ++++++++++++++++++++

    Hope that helps you.

    I came to the conclusion to do it this way, and not attempt to edit the Bones or animation,
    simply, because the SKA data file would also needed be imported into your 3ds file
    if you are attempting to edit a SKM with its animation inside the 3ds.

    I dont know enough about constructing the animation file structure anyway to do so.
     
    Last edited: Nov 14, 2014
  6. corprus

    corprus Member

    Joined:
    Oct 31, 2014
    Messages:
    10
    Likes Received:
    0
    Hi XVicious, thank you for your reply.

    I read your toolset post last night and saw those awsome models you made, really inspiring.:thumbsup:

    The problem previously i asked about of large value in ref bones was solved, it seems like i did create mesh object in max' scene for bones during importing, which should create bone object.

    I understand the seperate skb from skm -> edit mesh -> export mesh -> reinject procedure.

    I just want to make a more complex, realistic plate armor model for player characters, like the bone armor of the troll chieftain in the temple 3rd level which has its own torso model, not just add those tiny pair of pauldrons or simply replace the torso body texture. In order to do so, i have to make my own model and texture, which means need to export completely different vertex count, vertex position, normal, texcoord and index buffer. New model means reskinning, In 3dsmax i have to push a skin modifier upon a mesh and add all those bones imported from a existed skm file onto it and assign the bone weights vertex by vertex. when all that is done, export it back to a new skm for furthur use.


    By now, the order of the bones is the crucial point. since all armor for a certain race sharing the same ska files, so the orders in my newly exported skm must be the same as all other existed skm. But how can i ensure that when i binding those bones to my custom made model in 3dsmax? The human male/female character has 91 bones, and max skin modifier does not have bone list move-up/move-down operations. that makes the skinning work become really painful.:sadblinky
     
  7. XVicious

    XVicious Established Member

    Joined:
    Jun 21, 2013
    Messages:
    427
    Likes Received:
    8
    Yes the only way to take full control of the Model edit/ recreation, would be to have the ability to repaint the bone weights to the per-vertex model.

    if we can't repaint the bone weights, we are forced to use the existing bone/weight index per vertex.

    the face index is another story, we can re arrange that all we want just as long as the bone index and vertex count stays the same.

    so you can re-connect the dots any way you like and fill them in, just don't delete the dots, else the bone weights index gets messed.


    The reason the armors have 91 bones is because they share the same bones with the models they get attached to.

    of you notice that the PC's have the same bone counts and share the same exact bones and weights.

    By the way, re-texture mapping, and repainting the Normals, is no pain at all actually.
    _______________________________________________

    Do you have any design ideas, for the troll armor and how you would like to repaint it?

    maybe I could help you achieve what ever your trying to do with it.

    I attached the two peices exported by SKMTOOLSET 1.2

    OBJ format file
    http://en.wikipedia.org/wiki/Wavefront_.obj_file

    I appended .txt so I could upload them here without zipping em.
     

    Attached Files:

    Last edited: Nov 15, 2014
  8. corprus

    corprus Member

    Joined:
    Oct 31, 2014
    Messages:
    10
    Likes Received:
    0
    Thank you for the obj. I already exported those bone armor with your toolsets. :)
    I'd love to see those medieval plate or partial plate armors inside toee. just like total war medieval 2 or mount and blade style.
    Not quite like those too-fantasy style armor, e.g elven chain or hedrake's armor set in original toee.
     
  9. corprus

    corprus Member

    Joined:
    Oct 31, 2014
    Messages:
    10
    Likes Received:
    0
    [​IMG]

    Finally, it works!

    I added bone resorting procedure to make sure the bones' order are exactly the same as in the original skm files. Screen shots above shows an example of a modified plate armor for human male model. Based on the original FullplateII model with larger and curvier pauldrons and whatever parts that covered the upper and lower arm joint (I don't know what it's called, elbow guard?).

    Now the exporter takes an text file with same name as the one's you want to export only with a different extension name, which is .bor(bone order), as input. It contains a list of bone name which automatically generated by importer plugin when you imported the original skm file into 3dsmax. the order of those bone names are the same as the original files has. Then at the final stage of exportation, I resorted the bone list returned by max's skin modifier and the corresponding bone indices scattered in vertex streams with this bor file as reference.
    So far it works fine but I think it still need more test. I will upload the plugins later.
     
  10. XVicious

    XVicious Established Member

    Joined:
    Jun 21, 2013
    Messages:
    427
    Likes Received:
    8
    WEll dONE cORPUS,
    congrats with your success.

    I would suggest that you post your findings and new procedure Applits On the Models,animation thread, so that other people using 3dsmax have more tools to works with.
    Upload your tools there as Zipz or Rar files.

    Also I did not see the screen shot you spoke of yet, but I am sure its impressing.

    That is simulair to what I do in the SKMTOOLSet coupled with anim8or/blender.
    when I convert the SKM, it will extract the Bones and Materials seperate inside a
    file called SKB. Sounds like you made yours do Parcing/Sorting then appending the Bone Data to the mesh later? Sounds interesting.

    suedo, : Copy original -> into Modified SKM :file stream
    CopyHeader, copy materials/names ID's ,copy bones/names ID'S, (via SKM file)
    While( List->HasNext() ) //comment: if list has another object in the link
    {
    (inject->edited_Mesh, normals, texel coords (texture, UV)) (via OBJ File )
    (inject->Original_bones+material )(via SKB File)
    //comment: mesh data is coupled with Bone/weights and material ID's data
    }
    (inject->Edited or Original Face index)(via OBJ File)
    Save_File

    I used Stacks, queus, Link list to allocate these process Memory space
    Dynamically so that the application can handle any size input given the counts
    for the SKM data.



    I don't know if you mentioned Materials or not but they should also be coupled with the Mesh, bone data, and not lost in the process. For example some SKM files have more then 1 material.
     
    Last edited: Nov 19, 2014
  11. corprus

    corprus Member

    Joined:
    Oct 31, 2014
    Messages:
    10
    Likes Received:
    0
    Thanks XVicious.

    Sorry about the dead image link, I don't know where I should upload images to so that you can actually see them.

    [​IMG]


    I totally forgot about the multiple materials scenario in a skm file, since the plugin is a modified version of Leksey's impexp project and I have not touch the material part yet.
    Also I didn't figured out the structure of the material info header by now. In Leksey's
    skm header define there only a 128 bytes char array used to store the material zero ending name string. When debugging using vs, that name string only occupied the area from beginning till string length plus one while the rest of the 128 bytes remains mystery to me and I think it has triangle faces and vertices count, offset info. Did you parsed it when you extract SKB files, if so please shed some lit on me will you:p?
     
    Last edited: Nov 20, 2014
  12. corprus

    corprus Member

    Joined:
    Oct 31, 2014
    Messages:
    10
    Likes Received:
    0
    I was confused when I debugging importer plugin. As far as I know, the material info in a model file should at least contains two parts, one is the material identifier(usually the material file name) a sub mesh was assigned to and the other one is the triangle face index buffer or at least a pair of start offset and length used in addressing into the entire mesh's index buffer.
    But in SKM file, the material info only contains the .mdf path name and Nothing else there! Where are the sub mesh face ranging info? Without it you cannot determin which part of the model should be rendered as the mdf file indicated.

    [​IMG]
    Above screenshot is snapped from vc2008, shows the material info memory layout in skm from the 'PCs\PC_Human_Male\PC_Human_Male.skm' file. From the top(0x28F54730), the first sub mesh assigned with a material named 'CHEST'
    And below at the line started as 0x28F547B0 is the start of the second sub mesh named 'BOOTS'. Notice the data after these zero ending name strings, they look like random value with no actual meaning.

    Turn out its material ID was scattered across the entire triangle face buffer. Later I will improve the exporter plugin to support multi materials.
     
    Last edited: Nov 20, 2014
  13. XVicious

    XVicious Established Member

    Joined:
    Jun 21, 2013
    Messages:
    427
    Likes Received:
    8
    the Bone Tags and material references are the same size as the Models Mesh
    structure at the offset of the vertexes is where they start.

    They are there defined per vertex
    they are the same size as the mesh data structure size
    _____________________________________________

    float is SIZE 4 BYTES


    Code:
    
    typedef struct XYZ_
    {
    float x,y,z,w;
    }XYZ_;
    
    typedef struct Texture_
    {
    float x,y,z,u;
    }Normal_;
    
    typedef struct ModelData_
    {
    XYZ_ Vect;
    XYZ_ Norm;
    Texture_ Texel;
    }ModelData_;
    
    

    so 48 bytes are READ into the SKB file per VERTEX (SKB is in BINARY form)
    and 48 bytes are READ into the OBJ file per VERTEX (this is Formed for OBJ data)
     
    Last edited: Nov 20, 2014
  14. corprus

    corprus Member

    Joined:
    Oct 31, 2014
    Messages:
    10
    Likes Received:
    0
    The multi material function is finished. now the only problem is when import an exist skm to 3dsmax, the per vertex bone weights messed up with those #CylinderXX or #SphereXX bones which I believe they were used to storing physic shape parameters for cloth simulation rather than skinning the character mesh. It seems the skin modifier I created and stacked onto the imported mesh automatically activated envelope for every bone I added, even if I manually assigned bone weights per vertex later. and I don't know how to fix it. But it's ok since the exporter works and after all only that matters for modding most of the time.

    I uploaded the plugins binary here:
    http://www.co8.org/forum/showthread.php?t=11394
     
    Last edited: Nov 21, 2014
Our Host!