Problems using Blender Blender to creating models for an XNA project

Last post 05-09-2008, 9:39 PM by Debesciak. 13 replies.
Sort Posts: Previous Next
  •  05-04-2008, 7:00 AM

    Problems using Blender Blender to creating models for an XNA project

    Ok, so I've got to a point in my game engine where I actually need to think about replacing my placeholder graphics (Taken from the XNA samples) with some real graphics. So, I've had a look around on these forums and one common suggestion for a good free tool is Blender.

    So, I've installed it, watched the video tutorials and had a play around but I'm having a few problems.

    Firstly I tried creating a simple cube and exported it as an X file. In my game I replaced a placeholder graphic (Which was displaying fine) with the new cube X file, but nothing is being shown.

    Next, I thought I'd try loading one of the X files from the samples into Blender, but this doesn't work either. I just get a generic error message.

    I guess my question is, does Blender really work with X files? If so then why wont the samples load, and why don't the objects I create show up in game?

    Thanks in advance for your help.
    Ben

  •  05-04-2008, 7:42 AM

    Re: Problems using Blender Blender to creating models for an XNA project

    First off, good choice for using Blender :)

    It is actually easy to get it going, with the problem of getting the models into your samples you might find that the model is there... just very small. The default scaling of the blender models is a lot smaller then the models supplied in the xna samples.

    As for x files, I would suggest looking at the fbx importer and exporter for blender.

    Here is a link to my site which has some blender articles that relate to XNA.

    http://www.virtualrealm.com.au/content/BlenderTutorials.aspx


    Glenn "Mykre" Wilson - (XNA / DirectX MVP)
    Virtual Realm :- XNA News and Resources from Down Under
  •  05-04-2008, 9:23 PM

    Re: Problems using Blender Blender to creating models for an XNA project

    Does the fbx exporter have to be installed separately?  Where do I get it?  I've seen mention of an fbx exporter on a few websites (for Blender 2.44), but it doesn't appear in the menu with my fresh install of Blender 2.45.

  •  05-04-2008, 9:44 PM

    Re: Problems using Blender Blender to creating models for an XNA project

    Yes it is supplied with the 2.45 and 2.46 versions of Blender. If you go to file and select export, on my edition here it is the third export script down (Autodesk fbx).
    Glenn "Mykre" Wilson - (XNA / DirectX MVP)
    Virtual Realm :- XNA News and Resources from Down Under
  •  05-04-2008, 10:03 PM

    Re: Problems using Blender Blender to creating models for an XNA project

    How strange... it isn't in my menu.
  •  05-04-2008, 10:30 PM

    Re: Problems using Blender Blender to creating models for an XNA project

    The script should be located here C:\Program Files\Blender Foundation\Blender\.blender\scripts. That is off course if you installed to the default directories.

    The script is called export_fbx.py if it is not there You can re download the version of blender 2.45+, make sure you grab the zip as well. You then have the choice of a reinstall over the top, or unzip the zip file and just copy the scripts to the directory.

     


    Glenn "Mykre" Wilson - (XNA / DirectX MVP)
    Virtual Realm :- XNA News and Resources from Down Under
  •  05-04-2008, 10:48 PM

    Re: Problems using Blender Blender to creating models for an XNA project

    It wasn't there.  I downloaded the zip and replaced it.  Thanks.
  •  05-04-2008, 11:35 PM

    Re: Problems using Blender Blender to creating models for an XNA project

    Not a problem Glad to help.
    Glenn "Mykre" Wilson - (XNA / DirectX MVP)
    Virtual Realm :- XNA News and Resources from Down Under
  •  05-05-2008, 6:01 AM

    Re: Problems using Blender Blender to creating models for an XNA project

    Thanks for your reply. Yes maybe the model is there but just too small. I'll try scaling it and see what happens.

    Also thanks for the link to your tutorials.

    Regards
    Ben

  •  05-09-2008, 4:39 AM

    Re: Problems using Blender Blender to creating models for an XNA project

    I also use Blender for creating models for my game and I always export to .X format.  I use the default DirectX exporter that comes with Blender.  It took some trial and error with the settings at first, but now everything is working.

    When using Blender make sure you remove any additional vertices before exporting (in edit mode hit W, then "Remove Doubles").  Also be sure to apply any modifiers in object mode (like sub surf) before exporting - e.g. you may have added the modifier but not yet applied it.  Another thing I learned to watch out for is the origin location of your model in Blender (you will see it as a little pink dot, and it's the point that your model rotates around when you rotate it).  As you create your model you may find that the origin has moved, and when you render it in XNA it may not be where you expected it because of that origin value.  I set my origin to 0,0,0 for simplicity sake.

    Glenn mentioned checking for a really small model, also be careful of a really big model.  If your camera is "inside" your model then you may not even see it because your camera is looking through the model from the inside out.  You don't see the texture or model because the normal is facing away from you.

    If you keep working with .X files and have problems let me know as I've overcome quite a few snags (the main ones listed above).  I've written up a step by step guide on my project's wiki for exporting models from Blender to XNA (.X format), and I would like to add something similar to the XNA wiki whenever I get around to it (unless someome beats me to it!).

    Hope that helps.
  •  05-09-2008, 7:42 AM

    Re: Problems using Blender Blender to creating models for an XNA project

    I wouldn't be so sure with that removing duplication of vertices.
    For instance:
    Hard faces vs smooth faces. Generate a hemisphere that will have proper normals... The only proper way I know to do that is by duplicating vertices (edge splitter modifier actually does this). There are other -  less efficient - ways also... like adding more information per vertex.

    .X files should be considered testing/easy start format as it's formally dead. I advice getting to your own format sooner or later. The biggest mistake is to keep stuborn to old format when you really need "your" format. I am still using sometimes .X in my own simple projects. But when it comes to quality and rich graphic content I put it on shelf.

  •  05-09-2008, 3:32 PM

    Re: Problems using Blender Blender to creating models for an XNA project

    Thanks Phil for the good advise! I look forward to the wiki! :)


  •  05-09-2008, 3:34 PM

    Re: Problems using Blender Blender to creating models for an XNA project

    Debesciak:
    .X files should be considered testing/easy start format as it's formally dead. I advice getting to your own format sooner or later. The biggest mistake is to keep stuborn to old format when you really need "your" format. I am still using sometimes .X in my own simple projects. But when it comes to quality and rich graphic content I put it on shelf.


    I'm not quite sure what you mean by "your format". Do you mean I should create my own file format that matches my needs? Sure I can do that but obviously no 3D model editor is going to support my format.... unless I write and importer/exporter myself obviously.

    Thanks
    Ben
  •  05-09-2008, 9:39 PM

    Re: Problems using Blender Blender to creating models for an XNA project

    yup... that is what  I meant.

    Any graphic editor provides some scripts for creation of such formats.  Importers are usually not needed and not possible because of modifiers... hmm. Unless you would take them in account for your format (I never did that, but that could have some sense, for example mirror modifier could be succesfully implemented by two world matrices. hmm...). Usually when you create model, it would have a full stack of modifiers. Before exporting you would like to apply them all (for instance - already mentioned earlier - edge splitter). Importing such a model usually makes no further sense. It's just easier to reload project. Of course such a format is limited in use to your content pipeline (not mistake with XNA content pipeline, I mean CP in more general sense).
    Cheers.


View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback