Jump to content

SMESH file format interpretation issues


photo

Recommended Posts

Having sucessfully written code to write a mesh file, we now require to also write into smesh format. I am currently having trouble writing a smesh file based on the Mesh File Formats documentation and it feels like trial and error now in getting the resource editor to open my files without crashing.

 

 

 

SMESH File Format

  1. Magic sequence (int "ms08" ('m' | ('s' << 8) | ('0' << 16) | ('8' << 24)))
  2. Number of bones (int)
  3. Header information for each bone:
    • Name of the bone. It is a null-terminated string that contains:

    1. The number of characters in the string including the null character (int). 1024 characters is the maximum.
    2. Bone name of the specified length (char[length])

    [*]Parent of the bone (int)

    [*]Number of frames in bone-based animation (int)

    [*]Transformation data for each bone in each frame:

  • Bone position along along X, Y, Z axes; W component stores the bone scale in all directions (float[4])
  • Bone rotation quaternion (float[4])

[*]etc...

 

The parent bone. Do all bones require a parent? What if its the root bone? If no parent then is this value -1 or the index of itself? Forgive me here, I'm not an expert on skinned meshes, maybe there is something I havn't quite grasped with bone structure.

 

 

  • Zero frame is a bind pose frame.
  • A file with no bone transformations is the skinned mesh bind pose.

  1. Transformation data for each bone in each frame:
    • Bone position along along X, Y, Z axes; W component stores the bone scale in all directions (float[4])
    • Bone rotation quaternion (float[4])

 

Does this mean for a bind pose I should have zero frames or 1 frame? By "no bone transforms" does it mean omit the data for position and rotation for zero frame or add a position (0,0,01,) and roation (0,0,0,0) for that frame for each bone?

Link to comment

As it turns out, I was missing out the "number of bones" right after the magic sequence and now my files open in the resource editor! But for the record, it would still be nice to know what I asked in my above post to ensure my bones are setup correctly as I havn't written the script yet to control the bone transforms.

Link to comment

The only bone that don't have a parent is a root bone (hips or just a dummy bone). It's parent value is -1.

Exporting with 'Bind pose' option creates single frame SMESH file. Default transforms for each bone heavily depend on your skeleton and always have some complex transformations, not just (0,0,0,1) and (0,0,0,0). I.e. if you need to create BVH file from SMESH, you'll be lacking T-pose frame that is needed by most software alike Motion Builder.

Link to comment

I'm not trying to animate it as such, I just want an extra layer of transformations for parts of a mesh. I think I'm almost there with it but I have an issue;

 

node.setBoneTransform(bone, scale(1, thickness, 1));

 

Will this scale the verts with vertex weight of 1 with the bone as its parent (with no other parent bone transforms) in the Y axis only or will it scale it uniformly as it seems to be doing the later in my case.

Link to comment

I'm getting the impression that I have taken the wrong approach to my problem. I think I'm going to have to go back to .mesh format and use dynamic mesh surfaces if this can provide easy vertex manipulation over specified parts(surfaces) of a mesh. Fortunately this will only require some small additions to my current node exporter.

Link to comment

node.setBoneTransform(bone, scale(1, thickness, 1));

Will this scale the verts with vertex weight of 1 with the bone as its parent (with no other parent bone transforms) in the Y axis only or will it scale it uniformly as it seems to be doing the later in my case.

 

Only uniform scaling is available for bones, so it should be something like:

 

node.setBoneTransform(bone, scale(thickness, thickness, thickness));

Link to comment
×
×
  • Create New...