Blender to SunBurn

I looked at Blender a few years ago & became inspired yet confused.

This year, when I fired up Blender 2.56 – I was pleasantly surprised, I felt much less confused and things seemed to make a little more sense.

For this Tutorial, I’ll be focusing on getting a basic model created in Blender, Mapping a Texture to it via UV Co-Ordinates (a small bit of painting) and then exporting the whole mesh out to an FBX file for consumption in SunBurn.

The first time you open Blender, it still is a little much but that’s thanks to the numerous options and controls that are present.

image

Editing Mode

Click on the Object Mode Selection at the bottom of the screen and change the option to Edit Mode.

image

Once the screen is in edit mode, a few things change to represent the options present in this mode. The Cube Mesh itself changes and highlights the whole object – by default the object corners are more pronounced, as the default editing mode is Vertex select mode (points).

image

The options following the Edit Mode Selection reflect the various editing and selection modes.

image

To get a quick and interesting shape, we will subdivide the current mesh; this can be done by Selecting the menu option next to the Edit Mode Selection and navigating to  Mesh>Edges>Subdivide

image

The first time the Cube Mesh is Subdivided it looks like four little cubes stacked together.

image

Repeating the same process one more time we get the following

image

Each of the subdivisions that we can see are called faces. Faces can be then manipulated as a whole. Lets chose just one face by clicking on the Face Select Mode

image

Then Right click on one of the faces on the cube.

image

This face, can now be translated as a component of the whole. As it is moved along the world transform adjoining faces, edges and vertices are correspondingly translated to accommodate the changes to the faces new positions.

For illustration purposes though, we will examine using the Extrude Region option. Click on the menu option next to the Edit Mode Selection and navigating to  Mesh>Edges>Extrude Region

image

A white guideline is the drawn on the screen, indicating the axis along which the extrude will run.

image

Dragging the mouse towards the top of the screen will extrude this face up.

image

Repeating the same step, 3 more times for the following result. A somewhat functional  (upside down) stool. If any of the for legs aren’t the same length (remember you are looking at a 3d view of the object and perspective distance changes the relative height) then you can just select one of the faces (by right licking on it) and then use the available transforms, in this case click and drag the blue arrow up / down to increase / decrease the stools leg length.

image

Press F12 and the scene will be rendered from the Cameras view point; you should see something like this. Nice, Shadowy and Grey. Press Escape to exit that view.

image

We will need two windows to work with the texture and be able to see what we are doing on the object at the same time. Move the mouse to the top right corner of the object view screen, where there is 3 little lines at an angle.

image

The mouse should turn to a Cross. Click and Hold once the mouse has changed and drag your mouse to the left – a new window will be dragged out, showing exactly the same view.

image

Adding a texture to the object needs to be done before we can paint on the object. For this we will change one of the view windows to the Image View.

Click on the icon in the lower left corner, which has a picture of a cube and change then select UV/Image Editor

image

This changes the window to show up a blank image view

image

Click the New Button and create a new Image. Name the image something informative – don’t leave it as untitled, otherwise all of your material names in sunburn will be the same and you will find yourself editing FBX files by hand to fix Smile

Also, chose a different colour by clicking on the black colour box – say a light red?

image

Then we get a big blank image all of one colour.

image

Let’s save this image out as a PNG file (it helps to do it now – you don’t have to as you could pack it to the blend file but based on a bit of frustration on my behalf I recomend you just save it out now.)

Click Image and then Save As

image

Best to place the image in a texture folder so that you can keep your textures and models in different folders, all the images in one place etc. I use the format of Models\Textures but it’s up to you. Just save it somewhere close so that you can copy the whole parent folder over (to the SunBurn Content directory) or both sets of files at the same time.

image

Good time to save your actual Model now as well. Best to rename the default ‘Cube’ name first to what your actual mesh is. Make sure the Cube is selected in Object mode and then look for the Object Icon and type over the name.

image

Press Enter and all of the references will update

image

Save the model from the file menu.

image

We need to now map the new image file we have created to the mesh. To do this, go to the texture option for the object. Make sure the Cube is selected in Object mode. It’s in the far right options window, you may need to expand the options window a bit until you can see the texture selection. It’s indicated with a Red & White hatched icon.

image

Change the Type Selection Option to Image Or Movie. Then select Material. (As an aside, I tried it with Texture and couldn’t get it exported correctly but Material does the Job).

image

Click on the little icon of the picture to browse the available images to link. Select your previously saved image.

image

You will know when it’s worked because the preview of the material will change to the colour of the image you setup before. The source should also refer to the file location (notice that this is a relative path too)

image

By default, the material is just being rolled on to the mesh, by what ever way it deems. To be a bit more scientific about it, we should use the UV Co-Ordinates mapping approach. Scroll down to the Mapping section.

image

Change the Coordinates selection from Generated to UV

image

Now we need to make some changes s(and setup the actual UV coordinates) So that we can see how it works. Go back to the 3D model view and change it to edit mode.

image

All of the faces need to be selected in edit mode for the UV unwrap to work as expected. If your view doesn’t look like below, press A on your keyboard (select all) until it does.

image

We will use a simple unwrap technique this time (you can create seems and do some other fancy unwrapping but I’m no Ninja at it, so lets just work on an easy approach).

Select Mesh>UV Unwrap>Cube Projection

image

If you look at the other window you will see what looks to be a bit of a mess but it’s actually OK.

image

You can use your mouse wheel in the image view to zoom in and out, zoom out a bit and you can see what’s going on a bit better. A Set of UV Coordinates have been predefined for us on the image window, using the cube projection technique. It’s no where near perfect but to get some basic colour variation on to our stool and to show how to get a texture mapped material loaded in to SunBurn it’s just fine. You might notice that the UV Coordinates that have been mapped across stretch well past the available texture space. We can fix this quite easily by scaling down the UV Coordinates so that they fit the available texture space. Click in the image window and then press ‘S’ on your keyboard – which is the short cut for scale.

image

Once you have scaled the coordinates to a size that should fit you will need to move them all together to go back on the texture. Press ‘G’ on your keyboard (the shortcut for Grab) to move all of the coordinates back on to the image,

image

Like so.

image

Flick back to the 3D view, hit F12 & voilà.

image

But how do we know the UV cords are working & what about texture paint. Both good points, so lets add some colour. How about we colour the top to look like a cushion? Lets do it. Hit escape if you haven’t already and start selecting some faces in edit mode. As each face is selected, the corresponding location on the image is highlighted. if you hold down shift you can select multiple faces at once.

image

Now that we know the UV’s are mapped, lets jump in to texture painting. Select the texture paint toggle on the 3D view.

image

Texture paint brings up the object in a skinned mode and changes the left hand option pane to show all of the painting options.

image

This now works in much the same way as a normal painting program, with a few exceptions. First being that your painting in 3D but the main part is that you are restricted by how good a job of a UV unwrap you have performed. If there is no space for a face to be painted because of the way it’s been unwrapped then it will look dodgy. For this example though, the top of the stool has each face unwrapped neatly (but has overlapped!), so if we only paint there – it’s (sort of – it means that it repeats the texture painting because of the overlaps) fine (think of it like a textured piece of cloth :-). Change your colour and pen size and start painting. As you paint on the 3D model the Image window will be updated accordingly.

Important: Once you have the texture setup the way you want – go to the image view and save the image from there! Otherwise when you save everything else and hit export you will be wondering what happened to your changes.

After a bit of mucking around I ended up with this

image

Export your mesh out to an FBX file. I’m using the XNA FBX export in this example. It should be included going forward but there was a bug in 2.56 Beta so you might need to source the files and instructions from here: http://code.google.com/p/blender-to-xna/

image

Copy the FBX Model and Texture in to the SunBurn content Directory for your game.

The follow the steps from the previous tutorial to import your model.

Add the mesh to the scene and scale it so that it’s big enough to work with.

image

Put it near some lights to see the detail

 

image

The Diffuse maps texture is being used for this material to get this result. This happened for us automatically thanks to the way it was setup and exported from Blender.

image

That’s it for this tutorial. next I want to get to some actual SunBurn code.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>