Page 1 of 2

DirectX Format Bones and Weights

Posted: Thu Jan 19, 2017 9:36 pm
by thenamename
Hello

After importing my mesh with bones and weights (exported from Blender with default DirectX exporter), all the vertices of the mesh are just randomly placed somewhere. The problem occurs
only if the option "export skin weights" is enabled, and also just for the vertices who are added to a vertex group (It works for the rest of the mesh). Had someone this Problem before and knows how to solve it?

Re: DirectX Format Bones and Weights

Posted: Fri Jan 20, 2017 12:14 am
by robmar
You might want to use another exporter, they all have quirks, or even export to FBX and use one of several converters to .x

Re: DirectX Format Bones and Weights

Posted: Fri Jan 20, 2017 12:38 pm
by CuteAlien
Can you give us some example models to test? Optimally very tiny models (the less info the better) with blender files and exported .X files. But maybe just .X already allows us to see something. And always a good idea to compare with Microsoft's DXViewer to see if the export failed or if Irrlicht handles it wrong (DXViewer is a little harder to get these days maybe, it was part of older DX SDK's... I hope it can still be downloaded somehow).

Re: DirectX Format Bones and Weights

Posted: Sat Jan 21, 2017 11:17 am
by Vectrotek
STEP 1. Use Blender 2.4.9 (which you can get from Blender.org)..

Re: DirectX Format Bones and Weights

Posted: Sat Jan 21, 2017 11:19 am
by Vectrotek
STEP 2: Save the following code as "DirectX8Exporter.py" in the your "C:\__BLENDER_2_4_9\.blender\scripts" directory..

Unzip the file: http://s000.tinyupload.com/?file_id=156 ... 9551768369

When "Export as DX" you should get something like this:
Image

This is the only one that really works..

Re: DirectX Format Bones and Weights

Posted: Sat Jan 21, 2017 8:44 pm
by thenamename
@cuteAlien Ok here' s a test file, containing a plane and Three bones (1 is parented to the two other ones). Everyone of the two subbones are parented to one vertex for every bone.

Code: Select all

xof 0303txt 0032
 
template XSkinMeshHeader {
  <3cf169ce-ff7c-44ab-93c0-f78f62d172e2>
  WORD nMaxSkinWeightsPerVertex;
  WORD nMaxSkinWeightsPerFace;
  WORD nBones;
}
 
template SkinWeights {
  <6f0d123b-bad2-4167-a0d0-80224f25fabb>
  STRING transformNodeName;
  DWORD nWeights;
  array DWORD vertexIndices[nWeights];
  array float weights[nWeights];
  Matrix4x4 matrixOffset;
}
 
Frame Root {
  FrameTransformMatrix {
     1.000000, 0.000000, 0.000000, 0.000000,
     0.000000,-0.000000, 1.000000, 0.000000,
     0.000000, 1.000000, 0.000000, 0.000000,
     0.000000, 0.000000, 0.000000, 1.000000;;
  }
  Frame Plane {
    FrameTransformMatrix {
       2.007890, 0.000000, 0.000000, 0.000000,
       0.000000, 2.007890, 0.000000, 0.000000,
       0.000000, 0.000000, 2.007890, 0.000000,
       0.000000, 0.000000,-2.411880, 1.000000;;
    }
    Mesh { // Plane mesh
      4;
      -1.000000;-1.000000; 0.000000;,
       1.000000;-1.000000; 0.000000;,
       1.000000; 1.000000; 0.000000;,
      -1.000000; 1.000000; 0.000000;;
      1;
      4;3,2,1,0;;
      MeshNormals { // Plane normals
        1;
         0.000000; 0.000000; 1.000000;;
        1;
        4;0,0,0,0;;
      } // End of Plane normals
      XSkinMeshHeader {
        1;
        3;
        3;
      }
      SkinWeights {
        "Armature_b2";
        1;
        0;
         1.000000;
         2.007890, 0.000000, 0.000000, 0.000000,
         0.000000, 0.000000,-2.007890, 0.000000,
         0.000000, 2.007890, 0.000000, 0.000000,
         0.000000,-0.950213, 1.254508, 1.000000;;
      } // End of Armature_b2 skin weights
      SkinWeights {
        "Armature_b1";
        1;
        2;
         1.000000;
         2.007890, 0.000000, 0.000000, 0.000000,
         0.000000, 0.000000,-2.007890, 0.000000,
         0.000000, 2.007890, 0.000000, 0.000000,
         0.000000,-1.936956,-1.893398, 1.000000;;
      } // End of Armature_b1 skin weights
      SkinWeights {
        "Armature_Parent";
        0;
         2.007890, 0.000000, 0.000000, 0.000000,
         0.000000, 0.000000,-2.007890, 0.000000,
         0.000000, 2.007890, 0.000000, 0.000000,
         0.000000,-2.411880, 0.000000, 1.000000;;
      } // End of Armature_Parent skin weights
    } // End of Plane mesh
  } // End of Plane
} // End of Root
 
@vectotrek
Thank you but how should I get the modell from Blender (I'm currently using 2.77) to 2.49?

Re: DirectX Format Bones and Weights

Posted: Sat Jan 21, 2017 9:20 pm
by Vectrotek
@thenamename: From Blender (later version), you export the armature and its animations to "*.BVH" Biovision motion capture format..
Then also from this later version Blender you "Save" the file with "LEGACY FORMAT" option ON..

Then in Blender 2.49 you open this Legacy File which has ALL WEIGHTS still intact..
You'll see that the bones remained but NO ANIMATION..

Delete the Armature and Import the "*.bvh" (correct scale etc)..

Parent the Armature to the Mesh..

You'll see that bone names and weights (vert groups) remain correct..

Now Export the "*.x" file from Blender 2.49..

I can tell you now that this is the only way you're going to get a working X file from any Blender..
None of the other versions work..
Let me know how you progress because I also like Character Animation..

Re: DirectX Format Bones and Weights

Posted: Sat Jan 21, 2017 9:33 pm
by Vectrotek
Here is a proper X file I made this way, (also finalizing in Deep Exploration)..

Image

http://s000.tinyupload.com/?file_id=502 ... 6663274863

Re: DirectX Format Bones and Weights

Posted: Sat Jan 21, 2017 9:38 pm
by Vectrotek
Greetings! O Cute Alien!!

Re: DirectX Format Bones and Weights

Posted: Sat Jan 21, 2017 10:48 pm
by Vectrotek
"Realtime Graphics Rant"
Here is a zipped pdf I wrote about some Character Animation stuff (old post re-uploaded)
that might be usefull..

Image

Download:
http://s000.tinyupload.com/?file_id=074 ... 5977085304

Re: DirectX Format Bones and Weights

Posted: Sun Jan 22, 2017 11:32 pm
by CuteAlien
@ thenamename: Thanks, didn't get to it this weekend (next also probably not yet as I already have planned to work on another bugfix there). But I'll test it soon.

Re: DirectX Format Bones and Weights

Posted: Mon Jan 23, 2017 5:13 pm
by thenamename
Thank you very much, it's working now!

Re: DirectX Format Bones and Weights

Posted: Mon Jan 23, 2017 5:16 pm
by thenamename
One thing I forgot - Blender 2.49 does already include the DirectXExporter you mentioned above, so in case of feature visitors, you can just use the default exporter
in Blender 2.49

Re: DirectX Format Bones and Weights

Posted: Mon Jan 23, 2017 5:42 pm
by Vectrotek
Cool!

Re: DirectX Format Bones and Weights

Posted: Fri Jan 27, 2017 4:32 pm
by CuteAlien
I would guess on a problem with newer Blender exporter. I tried your example above and also can't get it to show up with the Microsoft dxviewer.