Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (23 posts)

Blender - Textures and .fbx

Last post 9/24/2011 5:23 PM by Z.s. 22 replies.
  • 9/6/2007 8:18 AM

    Blender - Textures and .fbx

    Hi all,

    I'm a super newbie, and am trying to display a cube with a texture loaded from a .png file I have.

    I have tryed drawing the cube in blender, and adding the texture under the links and pipeline option.  I can get the model to display in blender with the texture, but when I export it, I can't get the texture to come up.  I've tryed doing what they do in the tutorial and putting the model in the models folder and my .png file I used for the texture in the textures folder.

    Does anyone know of any good walkthroughs available for creating a .fbx (model and associated texture) file in blender.  I'm assuming I'm doing something wrong with the export process...

     

    Cheers,

     

    Mark.

  • 9/6/2007 9:56 AM In reply to

    Re: Blender - Textures and .fbx

    I had the same problem. When applying texture to your model in blender, you have to use the UV-tool in blender. If you don't use this tool i don't think you can get your texture on the model
  • 9/7/2007 3:15 AM In reply to

    Re: Blender - Textures and .fbx

    I am currently working on some walk throughs and should have them up soon.
  • 9/12/2007 1:38 PM In reply to

    Re: Blender - Textures and .fbx

    Hi,

    This is my workflow.

    Hope this helps...


    Exporting a Textured Model in the FBX Format from Blender to XNA

    Comprehensive Workflow (using Blender version 2.44)

    FIRST CREATE A SIMPLE TEXTURED CUBE MESH ...

    1. Launch Blender and start a new empty scene

    2. Create a cube: <hit space bar in top view> then Add->Mesh->Cube

    3. Select 'Object Mode'

    4. Hit the 'N' key to bring up Transform Properties and Scale X,Y,Z by a factor of 8 - then close the dialogue

    5. Select the Shading tab (hit F5) and Add New Material to the cube

    6. In the Materials Panel, select 'TexFace'

    7. In the Texture Panel, select 'Add New'

    8. In the 'Map Input' panel, select 'UV'

    9. Change to 'UV Face Select' mode

    10. Make sure all the faces of the cube are selected

    11. In another viewport, open up the UV Image Editor

    12. Select Image->Open and open a texture file - the texture should now be visible in 'UV Face Select' mode viewport

    13. Return to Object Mode and turn on the 'Textured' Draw Type - you should now see a textured cube in Object Mode

    14. Save the .blend file here

    NOW WE CAN EXPORT THE FBX FILE ...

    15. With the cube selected, choose File->Export->Autodesk FBX (.fbx)

    16. Change the output directory to your Desktop and call the file something like 'textured_cube.fbx'

    17. Hit the 'Export FBX' button

    18. Close Blender (or minimise)

    19. Using Windows Explorer, copy the texture file to the Desktop also

    20. Navigate to your XNA Project and place the model file in the directory: Content \ Models

    21. Place the texture file in the directory: Content \ Textures

    STARTING-UP XNA GAME STUDIO ...

    22. Launch Microsoft Game Studio Express

    23. Open your model viewing project

    24. In the 'Solution Explorer', right-click on 'Models' directory and select Add->Existing Item

    25. Change the 'Files of type' to 'Content Pipeline Files' and then navigate to the Content \ Models directory

    26. Select the model file you just created in Blender: 'textured_cube.fbx' and click-on the Add button

    27. In the 'Solution Explorer', right-click on 'Textures' directory and select Add->Existing Item

    28. Add the texture file to your project

    NOW WE NEED SOME CODE ...

    29. Edit the code as shown below:
     
     Model  myModel;

     protected override void LoadGraphicsContent(bool  loadAllContent)
     {
      if (loadAllContent)
      {
       myModel = content.Load<Model>("Content\\Models\\textured_cube.fbx");
      }
     }

    30. If you try and build at this point you will get an error message like this:

     "Missing asset "C:\Users\user\Documents\Visual Studio 2005\Projects\ModelViewer\Content\Models\fbx"

     This occurs because the Blender FBX Exporter doesn't know about the directory structure of your Model Viewer.
     It adds a folder called fbx, which you definitely don't want.

     To solve this, we have to edit the FBX Model file and change the Relative Path to our texture file.

    FINALLY, WE HAVE TO EDIT THE FBX (ASCII) FILE

    31. To open the code for the FBX model, left-click twice on the file in Solution Explorer. If you've followed the above steps it's called 'textured_cube.fbx' .

    32. With the model file open, select Edit->Find and Replace->Quick Find (or use CTRL + F)

    33. In the 'Find what:' field enter the following: 'RelativeFilename'

    34. Change the path to your texture. The code should look something like this:

     RelativeFilename: "..\textures\myTexture.jpg"

     Notice the use of the two dots at the start of the path. These are important because the compiler has to navigate up one level to find the Textures directory.

    35. Repeat steps 33 and 34 until all the RelativeFilename references are corrected.

    36. Click-on the 'Save All' toolbar button and build the project

    YOU SHOULD NOW SEE THE TEXTURED CUBE WITH ALL OF THE UV COORDS PRESERVED

    Note: The new Blender version 2.45 has an updated FBX exporter

     

     

     

     

     


     

  • 12/9/2007 1:47 PM In reply to

    Re: Blender - Textures and .fbx

    Very nice guide, but what if you want the texture to wrap around the whole box instead of repeating for each face ?
    I tryed to mess up with blender settings but in the end i get either no texture or again face mapping.

    Nevermind, looks like the "keep messing till it works" philosophy rewarded me this time :p
    In blender in UV face select mode, press U (unwrap) and pick the best unwrap. For me since i had a rock, sphere suited just good.
  • 1/11/2008 2:24 AM In reply to

    Re: Blender - Textures and .fbx

    Is this really only way to get textures to XNA?

    I've created nice landscape that uses tiled texture (material). Is there easy way to get it to XNA, either directly or by making it UV? With UV I've only managed to get two results. Either my texture is stretched accross whole landscape or every face has it's own texture, but no tiling.

    Could baking material to uv help this?

  • 1/11/2008 9:01 AM In reply to

    Re: Blender - Textures and .fbx

    ppl, How UV's are mapped to your mesh in blender is your choice...
    It's a normal artist job to mark seams, so result from automatic unwrapping is better.  Editing resullting uv wireframe, also.


  • 2/26/2008 12:25 AM In reply to

    Re: Blender - Textures and .fbx

    The steps listed above work fine for a cube, but for some reason not for a cylinder.

    I tried applying a texture to the rounded edge of the cylinder (by selecting all the faces around the cylinder), and opening an image in the UV/Image editor.  Then I choose UVs->Unwrap, and blender spread my texture around my cylinder.  It looks fine in blender.

    Then when I export to an fbx and load it into my game, I see the texture has been applied to one of the *ends* of the cylinder, instead of around the curved edges.

    I went back to blender, and applied a texture to one of the ends of the cylinder.  Now, when I load it into my game, no texture is applied at all!

    Any idea what's going wrong?  Can I diagnose this somehow by poking around in the .fbx file?

     

  • 3/9/2008 11:43 AM In reply to

    Re: Blender - Textures and .fbx

    Just adding a quick reply:

    The current .fbx exporter works fine for static meshes, if you want animated meshes there's a special version for the exporter available at http://www.triplebgames.com/downloads.html

    It seems XNA is a little picky about which version of .fbx files it supports.

    On another note: if you're going to use static meshes the .x exporter works fine too.


  • 3/18/2008 2:26 PM In reply to

    Re: Blender - Textures and .fbx

  • 3/18/2008 2:42 PM In reply to

    Re: Blender - Textures and .fbx

    "Missing asset "C:\Users\user\Documents\Visual Studio 2005\Projects\ModelViewer\Content\Models\fbx"

     This occurs because the Blender FBX Exporter doesn't know about the directory structure of your Model Viewer.
     It adds a folder called fbx, which you definitely don't want.


    Can I ask why you don't want this?  I've been using a fbx directory under my model directory and placing my textures there and so far, no problems.  Why should I edit the .fbx file to remove this?


    Thanks

  • 6/11/2008 12:07 PM In reply to

    Re: Blender - Textures and .fbx

    Is there an updated version of this tutorial for the newest release of Blender 2.46?

    I've noticed they have removed the 'UV Face Select Mode' and built it in to the 'Edit Mode'

    Also after exporting the model to an .fbx format I cannot find a RelativeFilename: path for a texture when editing it. I followed the example above but I haven't been able to display my model with a texture.

     

    Any help is appreciated!

     

     

    [Edit] Sorry! Forgot you need to save before exporting!


  • 7/28/2008 5:45 PM In reply to

    Re: Blender - Textures and .fbx

    Hello,

      Thanks for the great guide!  My models along with their textures are loading up now.  However, I'm noticing some problems with their bounding spheres.  I make a default cube and then scale up the entire cube (say by 8).  But when I try to run a basic interesection test, the model appears at 8x the size but the collision detection happens at a cube about 1x the size.  Any advice in how a .fbx model passes it's scale to bounding spheres?  More specifically, how it calculates the model's boundingsphere radius?

    I'm still trying to determine if this is a problem with the model or with the intersection code, but right now i'm loading up models provided by xna and their bounding spheres seem to be the same size as their models...

     Thanks

     

    Doh, wasn't applying the right matrix transforms. All good now!
  • 12/20/2008 10:06 AM In reply to

    Re: Blender - Textures and .fbx

    Great so far!!!!!!!!! but help I have no idea how to do this: 9. Change to 'UV Face Select' mode
  • 12/27/2008 11:38 PM In reply to

    Re: Blender - Textures and .fbx

    Alpha Software:
    Great so far!!!!!!!!! but help I have no idea how to do this: 9. Change to 'UV Face Select' mode


    The previous poster is referring to version 2.44.  I have version 2.46 and it is done a totally different way.  In my version of blender the UV unwrapping mode has been combined with the Edit Mode.  Check your version of blender by going to "Help" and selecting "About", and be sure that the tutorial you use refers to the version of blender you have installed.

    What works for me in blender version 2.46: 

    1. Have two windows open (spit the workspace in half by just right clicking the cursor near the bottom edge of the window).

    2. Select the model you want to unwrap and then change to "Edit Mode". 

    3. Then in the other window, change the current window type to "UV/Image editor" (click the little hash mark looking button and you should see "UV/Image editor" as one of the options). 

    4.  Press "U" to unwrap the model.  It should pop up a menu with a ton of different unwrapping options.

    I will not give further specifics because everything else depends on how exactly you want the final product to look.  At this point you should experiment with the different options on your own to find what works best for you.

    If my directions are too cryptic there are a ton of other tutorials available (just do a google search, and make sure you check your version of blender!). 
  • 12/28/2008 6:25 AM In reply to

    Re: Blender - Textures and .fbx

    A little while ago I put together a small article on Texturing a small box, that also included marking the seams so that your UV Map was easy to texture. Here is the linhk to the article... http://www.virtualrealm.com.au/articles/blender-3d/blender-3d-texturing-a-box/
  • 2/18/2009 10:28 PM In reply to

    Re: Blender - Textures and .fbx

    Trying to do this with the default cube... In Blender 2.47 I can't find the RelativeFilename anywhere in the exported .fbx file... In Map input I have UV and Face selected, and the F12 cube looks like the cube I want with my image texture selected. In Material, TexFace is selected. When I choose Draw Type as "Texture", the texture doesn't display correctly (just shows a gradient of what should be a grey stone texture) but again, the render of it is fine. Thanks in advance, this is driving me crazy.
  • 2/18/2009 10:57 PM In reply to

    Re: Blender - Textures and .fbx

    steffanp:
    I had the same problem. When applying texture to your model in blender, you have to use the UV-tool in blender. If you don't use this tool i don't think you can get your texture on the model
    This is the winning answer. It's a little strange to me that the UV is kind of independent from Blender Material/Texture thing... Any reason why? After I went the UV route I was able to find the RelativeFilename thing in my exported .fbx file. Thanks!
  • 6/13/2009 3:31 PM In reply to

    Re: Blender - Textures and .fbx

    I do know that baking textures to models in blender before exporting will work, but only in the sense that if done correctly it will give you a UV texture for your material/texture based on your rendered results.  There are plenty of good tuts on how to do this on the net.  Google it.  :)

    JF
  • 7/27/2009 12:16 PM In reply to

    Re: Blender - Textures and .fbx

    Here is tutorial that goes step by step on how to model textured cube in blender, and then export it for XNA:
  • 11/13/2009 1:58 PM In reply to

    Re: Blender - Textures and .fbx

    Ok, very much a n00b here and not an artist either. My question is: if you are planning to animate your mesh, is it ok to animate it before applying a texture or does the texture have to go on before animating? It seems to me that many of the workflows I'm reading do the texturing before the animating whereas I've always heard that texturing should be one of the last things you when the mesh is finalised.
  • 2/11/2010 6:26 PM In reply to

    Re: Blender - Textures and .fbx

    Holy crap, I want to kick myself in the butt after reading this again. I spent 2 days banging my head against the wall and actually somehow got the directions at the beginning of this post to work. Then could not reproduce it. I have version 2.49b and obviously am new to Blender.

    To make a long frustrating story short, I followed these short steps and I about died when it worked... the export and all (you see using 2.49b when the original steps did work, it caused a bug in the .fbx where I had to remove the extra reference to POSE - anyway). With this I only had to manually edit the RelativeFilename: fields and it even rendered the object - fully textured - in my code - amazing. I have once again started appreciating my choice to use Blender and can continue on with my life. LOL

    THANK YOU!

    ...and thanks to the original poster as well, it was a great step through and I learned alot. For others... check your version

    -Kurt




    moneras s:
    Alpha Software:
    Great so far!!!!!!!!! but help I have no idea how to do this: 9. Change to 'UV Face Select' mode


    The previous poster is referring to version 2.44.  I have version 2.46 and it is done a totally different way.  In my version of blender the UV unwrapping mode has been combined with the Edit Mode.  Check your version of blender by going to "Help" and selecting "About", and be sure that the tutorial you use refers to the version of blender you have installed.

    What works for me in blender version 2.46: 

    1. Have two windows open (spit the workspace in half by just right clicking the cursor near the bottom edge of the window).

    2. Select the model you want to unwrap and then change to "Edit Mode". 

    3. Then in the other window, change the current window type to "UV/Image editor" (click the little hash mark looking button and you should see "UV/Image editor" as one of the options). 

    4.  Press "U" to unwrap the model.  It should pop up a menu with a ton of different unwrapping options.

    I will not give further specifics because everything else depends on how exactly you want the final product to look.  At this point you should experiment with the different options on your own to find what works best for you.

    If my directions are too cryptic there are a ton of other tutorials available (just do a google search, and make sure you check your version of blender!). 
  • 9/24/2011 5:23 PM In reply to

    Re: Blender - Textures and .fbx

    IMPORTANT NOTE FOR ANYONE HAVING PROBLEMS WITH MODELS DRAWING AS 'GHOSTS'

    If model.draw is called while a spritebatch is active (after begin() but before end()) all models will draw as ghosts.
Page 1 of 1 (23 posts) Previous Discussion Next Discussion