XNA Creators Club Online
Page 1 of 1 (13 items)
Sort Posts: Previous Next

Blender - Textures and .fbx

Last post 07-28-2008 5:45 PM by Wipeless. 12 replies.
  • 09-06-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.

  • 09-06-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
  • 09-07-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.
  • 09-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-09-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.
  • 01-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?

  • 01-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.


  • 02-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?

     

  • 03-09-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.


  • 03-18-2008 2:26 PM In reply to

    Re: Blender - Textures and .fbx

  • 03-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

  • 06-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!


  • 07-28-2008 5:45 PM In reply to