DirectX Format Bones and Weights

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
thenamename
Posts: 6
Joined: Thu Jan 12, 2017 6:51 pm

DirectX Format Bones and Weights

Post 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?
robmar
Posts: 1125
Joined: Sun Aug 14, 2011 11:30 pm

Re: DirectX Format Bones and Weights

Post 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
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: DirectX Format Bones and Weights

Post 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).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: DirectX Format Bones and Weights

Post by Vectrotek »

STEP 1. Use Blender 2.4.9 (which you can get from Blender.org)..
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: DirectX Format Bones and Weights

Post 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..
thenamename
Posts: 6
Joined: Thu Jan 12, 2017 6:51 pm

Re: DirectX Format Bones and Weights

Post 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?
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: DirectX Format Bones and Weights

Post 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..
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: DirectX Format Bones and Weights

Post 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
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: DirectX Format Bones and Weights

Post by Vectrotek »

Greetings! O Cute Alien!!
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: DirectX Format Bones and Weights

Post 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
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: DirectX Format Bones and Weights

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
thenamename
Posts: 6
Joined: Thu Jan 12, 2017 6:51 pm

Re: DirectX Format Bones and Weights

Post by thenamename »

Thank you very much, it's working now!
thenamename
Posts: 6
Joined: Thu Jan 12, 2017 6:51 pm

Re: DirectX Format Bones and Weights

Post 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
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: DirectX Format Bones and Weights

Post by Vectrotek »

Cool!
CuteAlien
Admin
Posts: 9634
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: DirectX Format Bones and Weights

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply