A helping hand for bedroom coders throughout the land.
Blender 2.57b & XNA 4.0 Part I

Blogs

RandomChaos

Syndication

Next >>BlenderStart

I have been playing about with blender, I know Ed is a big fan of the XSI Soft Image tool, but I never really got on with it, mostly due to me not spending any quality with it. So, why Blender? Well, first off, it’s free! There are also loads of tutorials for it, loads on Youtube and the host site, Blender.org has a tonne. The latest draft of Blender, 2.57b is a great improvement on the later versions, but like all the other modeling tools I have looked at it still helps if you know the keyboard short cuts to help navigate around the UI.

With this set of short posts I am hoping to introduce you to Blender 2.57b and how you can then get those objects exported and rendered in your XNA projects.

Where can I get the goods!

Well, guess where? yep, the host site Blender.org as you will see there is a download tab and link off there main page where you can download the application. So pick the flavor you want I went with the 32 bit version even though I run a 64 bit OS, mainly because I when ever I have gone to use a 64 bit version of Blender it just didn’t play well. So I went safe and took the 32 bit version.

How do I use this crazy tool!

OK, first look at the UI and it’s quite busy, but it’s all pretty strait forward. What we have to start with are five windows, at first the windows in blender are not that easy to spot, but here are the five we get to start with.

At the very top, we have an info window, we can tell it’s and info window because it has this icon infoIcon

image

Then, off to the top right we have a Outliner window denoted by this icon image

image

Below this screen we have a Properties window, we can tell this thanks to this icon image

image

Then, at the bottom of the screen we have a Timeline window, expressed with this icon image

image

And finally, the big window in the middle will be the one we focus on for now, this is a 3D view window which has this icon image

image

OK, so we have a lot of screens, but as I say, we only need to focus on the last screen for now, we will touch on the other screens and how to create and close more, but I think you have enough on your plate with these five and with what we can do with the 3D view window. As you can see Blender gives you a cube to start with, we will use this throughout the rest of the post, we will make some simple modifications to to and export it to an FBX file then use it in an XNA 4.0 project.

3D View

So, I guess this will be the work horse screen for this post. In this window we will do the majority of our modeling, the first thing we will do is look at how we can move around and view the 3D space. So, off the bat we can change the view with a hot key, so on your number pad hit 5, this switches the view between perspective and orthographic, as you hit the 5 key you can see the view change and also the little description in the top right corner of the window.

image image

So, how do we translate and rotate our 3D view, well wheel have a mouse, so, I just use the roller to translate in the direction I am facing, but if you don’t have a mouse like that you can use the + and – keys. Again, with my mouse, to rotate around the scene I click my mouse wheel, hold it down and can rotate the scene, you can do the same with the number pad with the 8, 4, 6 and 2 keys.

Export to FBX

OK, we have this box model, how do we export it so we can use it in XNA? Well, this, for now is easy, simply click File in the Info window (remember, the one at the top) and you will get a drop down menu list like this:

imageHover over the Export option, and you will get another drop town like this:

image

And pick the Autodesk FBX (.fbx) option and you will get a screen like this:

image

Now the handy thing about this screen is you can set up book marks to remember where you want to save your stuff to, we will create one now so we can copy the model directly into the content folder of our project.

In the top of the screen type in the path of your content folder for the model, then, under the Bookmarks panel, hit the Add button

image So now, I can get to this folder each time I go to save a model. Now, under the address bar at the top, change the name of the model from untitled.fbx to cube1.fbx. Further down that left hand side of the screen are the Export FBX options, first thing we will do is scale down our cube, a blender unit is a big space, I am going to set the scale to .01. You can do this by either clicking on the arrows either side of the value or simply clicking on the value in the center and typing what you want in there.

image 

You can also see that Blender by default sets other export options, I will disable X 90, this rotates the exported mesh along the X axis 90 degrees, in blender Z is up so this can be useful if you forget to model using Y as up, but for this export it really does not matter, I am doing here as I try to model with the Y axis as up, Ill come to that later. I am also switching off the Empty, Camera, Lamp and Armature and switching off smoothing and as there is not animation, switch off Enable animation and Key frame optimization, you should have a Export FBX panel like this:

image

And now we hit the Export FBX button up at the top next to the address bar. After a second or two, we should now have a Cube1.fbx file in the model folder of our content project. In our XNA project we can now just add the existing item:

image

So we can now render this mesh in XNA, just like we can any other FBX mesh.

image

Now, this is all pretty simple stuff I know, but this is just a start. In the next post I will show you how to UV map and texture your cube, and here is what I hope to cover in future posts:

  • Creation of normal maps.
  • Creation of specula maps.
  • Creation of dual textures.
  • Skinned animation.

All the above and how you can then use them in your XNA 4.0 projects. Any questions on this post, then please add a comment and I’ll do my best to answer you.

Next >>


Posted Mon, May 23 2011 11:50 PM by Charles Humphrey
Filed under:

Comments

Simon Jackson XNAUK Admin wrote re: Blender 2.57b & XNA 4.0 Part I
on Tue, May 24 2011 11:58 AM

You missed out the plug-ins section in Blender.

File -> User Preferences -> Addons

In there the XNA FBX plugin was brought across from the old Blender to here.

So you can Export an XNA specific FBX format file for use in XNA with all the goodness that was there before.

There are also a host of other plug-ins already for Blender 2.57 and it's increasing growing.

Personally I want to see the Discombobulator plugin come across.

LintfordPickle wrote re: Blender 2.57b & XNA 4.0 Part I
on Tue, May 24 2011 1:26 PM

Great article Charles, I too have been enjoying myself with Blender in the last few weeks.

Just had a qestion to Simon here though, about what is an 'XNA specific' fbx format?  Honestly, since 2.57 I've been exporting quite detailed models + UVs without even opening the FBX options and its been fine in XNA, just wondering if I'm missing something here (like animation options maybe)?

Charles Humphrey wrote re: Blender 2.57b & XNA 4.0 Part I
on Tue, May 24 2011 8:13 PM

I knew about the old script as I use to use it. But didn't know the same plug in was in the latest version, how cool is that!

At the moment I have not found a need to use it, what does the plug in give you that the native FBX exporter does not?

I am having an issue with armatures at the moment, might try it with the plug in and see if that helps. For the next few posts though, I probably will stick to the native FBX exporter.

John C Brown wrote re: Blender 2.57b & XNA 4.0 Part I
on Wed, May 25 2011 9:52 PM

Nice article.  I like Blender so I am keen when anyone publicises it but I understand how daunting it is.  I spent two weeks solid one holiday to teach myself the basics.  I get lost in the XSI Mod Tool so it's each to their own.

I wrote the modified FBX exporter for Blender while it was still in Beta 2.54 then 2.55.  2.56 broke it and I fixed again for the release version 2.57.  I kept detailed notes which I passed on to the lead developer, Cambel Barton, so it is possible the main FBX Exporter has been made more compatible with XNA.

I have not tried the standard one since I created the modified one so the standard one may work now.

When I wrote the XNA version animations did not work at all using the standard FBX exporter.  I tried to simplify the export options in my versions so they are one click.

My versions can also export one animation per file or just the model with the armature.

Use whichever exporter works for you.  I'm not precious about it, I created mine because my project needed it at the time.

A few tips for using Blender.

I find it much easier to work Z up in Blender and rotate the model to Y up in the XNA Content pipeline.  Watch out for animations though the standard skinning processor needs modifying to rotate animations.

I avoid scaling at all in the export import process.  I have had too many problems.  I suggest creating the model the right scale to start with.  Just use Edit mode and S to scale as required.

Never scale in Object mode, make sure that always has a scale of 1 or at least all objects have the same sclae.  XNA appears to ignore the scale so if objects in the same FBX file have different scales XNA messes up the result when imported.

Looking forward to the next article.

Charles Humphrey wrote re: Blender 2.57b & XNA 4.0 Part I
on Wed, May 25 2011 10:44 PM

Hi John,

Thanks for the tips, I am a Blender fan boy too lol. Took a look at your site, and I am no where near your standard, I do, do good Cubes though lol

I am having issues with my Skinned stuff, so will probably use your exporter if it remedies my issues.

Thanks for dropping by, and if you are in the UK, pop into one of our XNA meets, I am sure you would give a better blender talk than me :D

John C Brown wrote re: Blender 2.57b & XNA 4.0 Part I
on Wed, May 25 2011 11:07 PM

I'd like to come to the meets but they are a bit far away.  I live in Essex and work in London.

I'm still learning Blender.  I've been using it a lot lately but I'm no artist.

Charles Humphrey wrote re: Blender 2.57b & XNA 4.0 Part I
on Thu, May 26 2011 12:01 AM

Well, if you ever get the time and train fair, I am sure one of us can put you up for the night :)

You never know, maybe we will hold one out side of the Midlands one day...

RandomChaos wrote Blender 2.57b & XNA 4.0 Part II
on Thu, May 26 2011 12:10 AM

<< Pev | Next >> In the previous post I covered how and where to get Blender, briefly described

Ben P wrote re: Blender 2.57b & XNA 4.0 Part I
on Thu, May 26 2011 10:33 AM

John - what are your working hours like? My co-coder Paul has to come from London - he gets the train to Milton Keynes and I pick him up from there, might be able to sort you a lift if you can get there for the same sort of time.

John C Brown wrote re: Blender 2.57b & XNA 4.0 Part I
on Thu, May 26 2011 8:43 PM

Ben

Thanks for the offer.  My struggle is more the total time away from other stuff rather than a transport problem.

Regards