Results 1 to 16 of 16
  1. #1
    Member hoxolotl's Avatar
    Join Date
    May 2002
    Location
    Netherlands
    Posts
    811

    XNA .fbx Exporter(s)

    Just the heads up for people using blender to get their models into XNA:

    If you use a static mesh: use the directx exporter, it worked fine (so far) for me.

    If you want to use an animated mesh the XNA .fbx export mod python script can be found here:

    http://wiki.blender.org/index.php/Sc...export_xna_mod

    the following is probably not correct ((see Ideasman42's post as to why):
    it's the best way to go untill the .fbx exporter that comes with blender is updated to the 2006-11 .fbx sdk compliance. Currently the .fbx exporter version that comes with blender is 2006-10-01, while XNA is using 2006-11, thus creating a few hiccups.
    We'll have to ask Robotron how and why he changed the script.



    FAQ:

    Errors: -bone weight error
    When you export your animation, make sure every single vertex in your mesh has been weight painted, leaving it to the default value (dark blue color) 0 will result in errors.

    -SkinnedModelPipeline "Input Skeleton not found"

    the armatures need to be joined using [ctrl+j]

    The skeleton root, "Spine", has been pulled out of the scene hierarchy and made into a child of the root node. One of the skeleton root's old parents, "Armature", has an animation named "Move" which will not be reflected on the skeleton root. Fragment identifier "Armature". Animtest.fbx SkinningSampleWindows
    Remade the armature, changed the code in XNA ( AnimationClip clip = skinningData.AnimationClips["Move"]; ) to reflect the action name in the .blend, ignored all errors and it shows up in the skinningsamplewindows.


    other:
    -mesh no showing up correctly, or showing up as a flattened pan-cake.

    you probably used the .fbx exporter that comes with blender, use the above mentioned exporter instead.

    -my question isn't in this faq:
    feel free to post your problem or a solution you have found in this thread.


    Test tools:
    to make sure we all use the same test tools (it might be your code messing things up, and not the xna importer):
    USe the skinned model sample to test animations:
    http://creators.xna.com/Headlines/de...el-Sample.aspx

    The Xna exporter can be found here:
    http://www.triplebgames.com/downloads.html


    Pipeline:
    (taken from Terloon's post here http://xna-uk.net/forums/p/596/1635.aspx#1635)

    So far my methods are pretty simple. Steps I should be able to describe to a 3d artist some time down the road of my project. Here goes:
    1. Create model to animate.
    2. Add armatures. So far my armatures have been pretty basic. Enough to make a few blocks wave.
    3. Set weight values by weight painting.
    4. Create animations in the Action Editor.
    5. Name this armature.
    6. Add an armature modifier to the mesh object and make sure it references the armature I named.
    7. Use the FBX exporter made by RobotronHer which can be found here. www.triplebgames.com
    8. In the SimpleSkinned XNA application, add an existing content item and select that exported FBX file.
    9. Select the imported fbx file properties and make sure it uses the SkinnedModelProcessor for the Content Processor property.
    10. In the SkinnedSample code, make sure you on the line:
    AnimationClip clip = skinningData.AnimationClips["Walk"];
    That "Walk" was an animation action in blender that you made.
    11. Compile and run.
    All this have been by memory, but that should be the general steps I've been doing. The model loads, renders, and animates, but, as always, I've met another snag. The orientation of the model is incorrect. In Blender, I have the top of the model going towards Z+, but when it renders in SkinnedSample, the top of the model renders towards Y-.

    Tutorials:
    http://www.stromcode.com/category/xna/


    Edit1
    Added test tools and pipelines.
    edit2
    feedback from Ideasman42 added
    edit3
    added Stormcode's tutorial site
    edit4
    SkinnedModelPipeline "Input Skeleton not found"
    edit5
    The skeleton root, "Spine", has been pulled out
    Last edited by hoxolotl; 23-Apr-08 at 03:15. Reason: The skeleton root, "Spine", has been pulled out
    "If the greatest view is seen from the edge of a cliff, it's best to know which way you're facing before thinking two steps ahead."



  2. #2
    Member ideasman42's Avatar
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    5,338
    it's the best way to go untill the .fbx exporter that comes with blender is updated to the 2006-11 .fbx sdk compliance. Currently the .fbx exporter version that comes with blender is 2006-10-01, while XNA is using 2006-11, thus creating a few hiccups.
    Almost certain this is incorrect, I wrote the exporter after 2006-11 using the latest SDK from autodesks site as a reference. This date may be the build date.... Autodesk would be pretty stupid to break their format within 1 month of releases. and even if they did. the FBX sdk should deal wih the loading of old FBX versions for you.

    I you think there is a problem with the exporter, import and export it (with motionbuilder for instance) and compare the original and new files.

    That aside, thanks for providing info as to how to get blender working with XNA
    Last edited by ideasman42; 18-Mar-08 at 05:41.
    Podcast * dotfiles * My Wiki * Blender/Stackexchange
    ideasman42<at>gmail.com



  3. #3
    How and why did I change the script?

    How - painful printf debugging of a simple animation going through to XNA, looking at the produced matrixes and fiddling with things until I got out what I wanted through to my game. I stripped a lot of the options for global transformations etc out so that it was simpler for me to see what was going on tracing through the script. I think iirc that there were two significant changes from Ideasman's script - one change was to the object_tx() function & then I changed the line elif TX_CHAN=='R': context_bone_anim_vecs = [mtx[1].toEuler() for mtx in context_bone_anim_mats] to use mtx[0] not mtx[1].

    Sorry I don't understand enough about the fbx file format or the XNA model processor to truly understand the significance of these changes. I had a narrow focus on getting my animations out of blender and into my game, and I've managed to get a pipeline working that does what I need it to and hopefully help a few other people out.

    Hope that helps a bit.

    Fritz



  4. #4
    Member ideasman42's Avatar
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    5,338
    RobotHero, can you submit a diff from the script in 2.45?
    Podcast * dotfiles * My Wiki * Blender/Stackexchange
    ideasman42<at>gmail.com



  5. #5
    I've e-mailed you a diff



  6. #6

    Question on Binding Pose

    Looking at the transfroms for the binding pose in the debugger there seems to be one for the bottom end of each bone (where the parent is) but not the tip. Shouldn't the bone's bind pose tranfsform give you the postion of the tip relative to the bottom (which is the tip of it's parent) ?
    Animation in the Skinning Sample looks almost alright, but there is a distortion at the end of limbs.



  7. #7
    Member hoxolotl's Avatar
    Join Date
    May 2002
    Location
    Netherlands
    Posts
    811
    InezDias have you encountered the
    "The skeleton root, "Spine", has been pulled out of the scene hierarchy" problem yet? if you found a solution please tell us, because we're still blocked on it.
    "If the greatest view is seen from the edge of a cliff, it's best to know which way you're facing before thinking two steps ahead."



  8. #8
    I ran into the same problems. I've done some tinkering and finally managed to compile the animation without warnings. That being said, I've yet to see the animation working in the example I'm using. Moreover the "solution" is completely manual and fairly useless as far as the exported is concerned but may give some hints about the nature of the problem .

    Anyway ... as for getting rid of the warning, I compared it to the example that came with XNA (dude.fbx) and it seems that the blender exporter, exports a little bit too much - the scene root and the actual armature. If you (manually) remove these from the fbx files and setup the "Object connections". You can continue without the warning.

    ---

    Small update; did some more hacking and there's a bunch of extra steps required to actually see something. After removing the seemingly redundant bones and manually fixing the object relations, I also had to add all the meshes to the scene in said object relations. Finally the animation showed up... sort of. The meshes were basically all over the place except in the correct positions or missing completely (but that may be because I forgot to add them in the first place).

    As a side note: the fbx export, imports flawlessly (for as far as I can tell) in the maya personal edition...

    ---

    Another update: after much much more trials and errors, I found that I got the best results with this script (http://www.triplebgames.com/downloads.html). It still results in the warning and the animations are upside down, but at least they are correct otherwise.
    Last edited by TheSoepkip; 17-Apr-08 at 02:42.



  9. #9
    Member hoxolotl's Avatar
    Join Date
    May 2002
    Location
    Netherlands
    Posts
    811
    For the SkinningSampleWindows error:

    The skeleton root, "Spine", has been pulled out of the scene hierarchy and made into a child of the root node. One of the skeleton root's old parents, "Armature", has an animation named "Move" which will not be reflected on the skeleton root. Fragment identifier "Armature". Animtest.fbx SkinningSampleWindows


    Changed the code from "default take" in XNA to

    AnimationClip clip = skinningData.AnimationClips["Move"];

    And just ignored the bone errors, and I get to see my animation, or even multiple animations now when using different names for animations in the action editor.

    So it seems somehow Robotron's exporter works
    "If the greatest view is seen from the edge of a cliff, it's best to know which way you're facing before thinking two steps ahead."



  10. #10
    I'm using this script and I'm having problems when drawing it in XNA and have a couple of questions.

    When exporting to .fbx, do I choose Selected Objects or Scene Objects?

    When I draw it in XNA, it ends up rotated. I know when exporting to .x, there is an option to choose which axis is up, but not with .fbx exporter. Is there a way to fix this? Or do I have to hard code it in XNA to rotate all objects?

    Thanks in advance.



  11. #11
    Since XNA 3 came out, this script has started to fail on a lot of meshes.

    In particular I am finding you have negative indices in the mesh which I think is tied into this line of code.

    fi[-1] = -(fi[-1]+1)

    in write_mesh.

    What is it supposed to be doing ?



  12. #12
    Wow! This script worked for me when the bundled .fbx script failed (by exporting the default armature pose as a tangled snarl). This is one of the few animated format exporters I've found which actually works for me, along with der_ton's .md5 script and a specialized script to export Ultimate 3D format models.

    I'm having some odd problems with the weighting results, however. I'm trying to export a figure which I've been using in .md5 and .u3d formats successfully. In those cases, what I see in Blender is exactly what I get from the export. With this, however, some vertices seem over- or under-weighted and the mesh gets ugly when certain bones are posed.

    Can someone familiar with the .fbx format or this export script help me figure out what's happening? Is there a limit to the number of weight influences in .fbx, and the script randomly selects some influences and drops others? So far, that's my only guess, but the file format is complex and baffling and so far I haven't made much sense of the script itself.

    I hope I'm not spamming the thread. Should this be a separate thread? Hmm.

    EDIT: Okay, I've solved my problem. A script to smooth bone weights on a mesh had been over-applied, adding unnecessary, very low weight listings for all of the bones affecting the mesh. When the export normalized these, it ended up under-valuing desired weights and making a mess. A weight cleanup script was able to help me get rid of the junk listings, and all is well.

    Sorry to have kicked the thread for reasons that really weren't on topic. :blush:
    Last edited by Basil_Fawlty; 18-Mar-09 at 20:01.



  13. #13
    Member
    Join Date
    Apr 2005
    Location
    London
    Posts
    29
    I just spent some time figuring out the differences between the tripleb script and the bundled one. It boils down to 2 things (both are necessary):

    The default unit size is set to 100 and should be 1.

    The armature matrix needs to be returned from object_tx (don't really understand the details there).

    Ayhow, apply the patch below and it will work with XNA (don't know how it breaks other stuff though).

    Ian

    Code:
    *** C:/Users/ian/AppData/Roaming/Blender Foundation/Blender/.blender/scripts/export_fbx.py    Thu May 21 14:14:36 2009
    --- C:/Users/ian/AppData/Roaming/Blender Foundation/Blender/.blender/scripts/export_fbx2.py    Fri Jul 03 15:12:15 2009
    ***************
    *** 580,585 ****
    --- 580,588 ----
                  scale =            tuple(matrix.scalePart())
                  rot =            tuple(matrix_rot.toEuler())
                  
    +             #ijb
    +             matrix =  mtx4_z90 * ob.matrix['ARMATURESPACE'] 
    +             
              else:
                  # This is bad because we need the parent relative matrix from the fbx parent (if we have one), dont use anymore
                  #if ob and not matrix: matrix = ob.matrixWorld * GLOBAL_MATRIX
    ***************
    *** 2262,2268 ****
                  Property: "FrontAxisSign", "int", "",1
                  Property: "CoordAxis", "int", "",0
                  Property: "CoordAxisSign", "int", "",1
    !             Property: "UnitScaleFactor", "double", "",100
              }
          }
      ''')    
    --- 2265,2271 ----
                  Property: "FrontAxisSign", "int", "",1
                  Property: "CoordAxis", "int", "",0
                  Property: "CoordAxisSign", "int", "",1
    !             Property: "UnitScaleFactor", "double", "",1
              }
          }
      ''')



  14. #14
    Problem with specular info

    I'm using Blender 2.49b. I've been trying to import my model in XNA 3.1 using both the default exporter and the TripleB one, both with undesired results.

    The default exporter generates some values for specular color and power, but they aren't importing in XNA. I've debuged the content pipeline in XNA and saw that those values are being ignored, resulting in the model being rendered with a default difuse and specular settings, regardles of the settings I chose.

    The TripleB seems to be ignoring difuse data as well, resulting in a pancaque like model.

    I've been able to produce a working model using the Collada exporter, then using Autodesk FBXConverter to convert the model from Collada to FBX.

    Here is a zip file containing the three FBX files, each generated by one of those methods.
    http://www.sendspace.com/file/lwd1ox

    Bellow is a piece of the FBX files generated by each method. The default and tripleb I think are identical, indicating that the difference I explained above is somewhere else in the code. But the Collada -> FBXConverter method generate a quite different material setting.

    Default exporter
    Code:
    Material: "Material::arca_corpo", "" {
            Version: 102
            ShadingModel: "lambert"
            MultiLayer: 0
            Properties60:  {
                Property: "ShadingModel", "KString", "", "Lambert"
                Property: "MultiLayer", "bool", "",0
                Property: "EmissiveColor", "ColorRGB", "",0.7622,0.0000,0.0000
                Property: "EmissiveFactor", "double", "",0.0000
                Property: "AmbientColor", "ColorRGB", "",0.0000,0.0000,0.0000
                Property: "AmbientFactor", "double", "",0.5000
                Property: "DiffuseColor", "ColorRGB", "",0.7622,0.0000,0.0000
                Property: "DiffuseFactor", "double", "",0.8000
                Property: "Bump", "Vector3D", "",0,0,0
                Property: "TransparentColor", "ColorRGB", "",1,1,1
                Property: "TransparencyFactor", "double", "",0.0000
                Property: "SpecularColor", "ColorRGB", "",1.0000,1.0000,1.0000
                Property: "SpecularFactor", "double", "",0.4280
                Property: "ShininessExponent", "double", "",80.0
                Property: "ReflectionColor", "ColorRGB", "",0,0,0
                Property: "ReflectionFactor", "double", "",1
                Property: "Emissive", "ColorRGB", "",0,0,0
                Property: "Ambient", "ColorRGB", "",0.0,0.0,0.0
                Property: "Diffuse", "ColorRGB", "",0.8,0.0,0.0
                Property: "Specular", "ColorRGB", "",1.0,1.0,1.0
                Property: "Shininess", "double", "",11.2
                Property: "Opacity", "double", "",1.0
                Property: "Reflectivity", "double", "",0
            }
        }
    TripleB exporter
    Code:
    Material: "Material::arca_corpo", "" {
            Version: 102
            ShadingModel: "lambert"
            MultiLayer: 0
            Properties60:  {
                Property: "ShadingModel", "KString", "", "Lambert"
                Property: "MultiLayer", "bool", "",0
                Property: "EmissiveColor", "ColorRGB", "",0.7622,0.0000,0.0000
                Property: "EmissiveFactor", "double", "",0.8000
                Property: "AmbientColor", "ColorRGB", "",0.0000,0.0000,0.0000
                Property: "AmbientFactor", "double", "",0.5000
                Property: "DiffuseColor", "ColorRGB", "",0.7622,0.0000,0.0000
                Property: "DiffuseFactor", "double", "",0.0000
                Property: "Bump", "Vector3D", "",0,0,0
                Property: "TransparentColor", "ColorRGB", "",1,1,1
                Property: "TransparencyFactor", "double", "",0.0000
                Property: "SpecularColor", "ColorRGB", "",1.0000,1.0000,1.0000
                Property: "SpecularFactor", "double", "",0.4280
                Property: "ShininessExponent", "double", "",80.0
                Property: "ReflectionColor", "ColorRGB", "",0,0,0
                Property: "ReflectionFactor", "double", "",1
                Property: "Emissive", "ColorRGB", "",0,0,0
                Property: "Ambient", "ColorRGB", "",0.0,0.0,0.0
                Property: "Diffuse", "ColorRGB", "",0.8,0.0,0.0
                Property: "Specular", "ColorRGB", "",1.0,1.0,1.0
                Property: "Shininess", "double", "",11.2
                Property: "Opacity", "double", "",1.0
                Property: "Reflectivity", "double", "",0
            }
        }
    Collada and FBXConverter method
    Code:
    Material: "Material::arca_corpo", "" {
            Version: 102
            ShadingModel: "phong"
            MultiLayer: 0
            Properties60:  {
                Property: "ShadingModel", "KString", "", "Phong"
                Property: "MultiLayer", "bool", "",0
                Property: "EmissiveColor", "ColorRGB", "",0,0,0
                Property: "EmissiveFactor", "double", "",1
                Property: "AmbientColor", "ColorRGB", "",0.381110012531281,0,0
                Property: "AmbientFactor", "double", "",1
                Property: "DiffuseColor", "ColorRGB", "",0.762220025062561,0,0
                Property: "DiffuseFactor", "double", "",1
                Property: "Bump", "Vector3D", "",0,0,0
                Property: "NormalMap", "Vector3D", "",0,0,0
                Property: "BumpFactor", "double", "",1
                Property: "TransparentColor", "ColorRGB", "",0,0,0
                Property: "TransparencyFactor", "double", "",0
                Property: "DisplacementColor", "ColorRGB", "",0,0,0
                Property: "DisplacementFactor", "double", "",1
                Property: "SpecularColor", "ColorRGB", "",0.85605001449585,0.85605001449585,0.85605001449585
                Property: "SpecularFactor", "double", "",1
                Property: "ShininessExponent", "double", "",14.5
                Property: "ReflectionColor", "ColorRGB", "",1,1,1
                Property: "ReflectionFactor", "double", "",0
                Property: "Emissive", "Vector3D", "",0,0,0
                Property: "Ambient", "Vector3D", "",0.381110012531281,0,0
                Property: "Diffuse", "Vector3D", "",0.762220025062561,0,0
                Property: "Specular", "Vector3D", "",0.85605001449585,0.85605001449585,0.85605001449585
                Property: "Shininess", "double", "",14.5
                Property: "Opacity", "double", "",1
                Property: "Reflectivity", "double", "",0
            }
        }
    Last edited by dcviana; 09-Nov-09 at 07:31. Reason: Fixed some typos.



  15. #15

    rotation problems

    I'm trying to make a human character, but the model's rotation in xna seems to be based off the armature's rotation in blender. The problem is this is causing the model to appear as if it were laying down. Anyone know how I could get this right?



  16. #16
    you think there is a problem with the exporter, import and export it (with motionbuilder for instance) and compare the original and new files.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •