Search Unity

Blender 2.54 soon?

Discussion in 'Asset Importing & Exporting' started by w00dn, Sep 29, 2010.

  1. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
  2. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    I'm not sure :) It isn't very specific about which issue he is talking. IIRC, I tried 2.54 - there were improvements, but the Python scrips still didn't work correctly in the default installation (which is necessary for direct Blend import).
     
  3. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    i just compared the old (sept. 3rd) and the new (sept. 24th) export_fbx.py files. there are some changes to path stuff as far as i understand it. but the todo notes also say : # - uses bpy.path.abspath, *.relpath - replace at least relpath.

    Or is this completely unrelated to the export script and something that has to be fixed in the way python/blender handle paths?
     
  4. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    It might be related, but they just have to fix the installation - I don't expect Blender users go fiddle around with their scrips ;) I hope Blender is fixed before we release Unity 3.1, so we have some time to fix it...
     
  5. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    this sounds related, doesn't it?

    8 - Commit [32477] by: sgefant
    darwin Makefiles: copy release scripts and python modules to where blender looks for them, i.e. blender.app/Content/MacOS/$(VERSION) instead if blender.app/Content/MacOS/.blender

    http://www.graphicall.org/builds/logs_blender.php
     
  6. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    Anything sounds good to me as long as it works properly in the next build.
     
  7. Philbywhizz

    Philbywhizz

    Joined:
    Nov 20, 2009
    Posts:
    15
    I've just tested build [32628] (which should have the [32477] patch in it) and it doesn't work.

    :(
     
  8. Akta

    Akta

    Joined:
    Oct 15, 2010
    Posts:
    119
    As I sad in the other post, export the FBX manually, it's not a big deal isn't it? :)
    Blender 2.54 built-in export script works like a charm, so why don't you use it instead?
     
  9. Philbywhizz

    Philbywhizz

    Joined:
    Nov 20, 2009
    Posts:
    15
    Oh I know the FBX export works and it isn't a big deal. I'm currently keeping my 'blends' in a folder from the main project called 'Blends', along with 'Assets' and 'Library'. Its not as neat as keeping my blender assets in 'Assets' but it will have to do for now.
     
  10. Akta

    Akta

    Joined:
    Oct 15, 2010
    Posts:
    119
    Yeah I know that, but I think is the only way to do it unless you want to open the blend file in 2.49 and save it again. In this case however you will lose animation data which is handled differently in 2.5 :/
     
  11. SilentWarrior

    SilentWarrior

    Joined:
    Aug 3, 2010
    Posts:
    107
    How do u make it work? I am trying to export a simple model with an armature. Sometimes it exports the armature and not the model, sometimes it exports only the model.
     
  12. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    SilentWarrior, there are a few critical aspects at the moment. The mesh needs to be parented to the armature (or the other way? Not sure about that) or needs an armature modifier (I always use that one). Make sure you are in object mode and select the mesh. Now you can export (File -> Export -> Autodesk FBX (.fbx)). On the left hand side of the just opened window you see some more export options. Make sure you have all the needed options selected. If you have several actions, you need to enable "All Actions". That's the only one I have to select additionally.
     
  13. jeanRicK

    jeanRicK

    Joined:
    Sep 23, 2010
    Posts:
    4
    Hi guys. I'm trying to import animated meshes into Unity 3 from blender 2.54. Normal meshes work fine but when I try to export the fbx manually, I get this warning:
    Code (csharp):
    1.  
    2. ImportFBX Warnings:
    3. Mesh 'body' has 784 (out of 906) vertices with no weight and bone assigned (they will be assigned to bone #0 with weight 1). The list of vertices: 122, 123, 124, 125, 126, 127, 128, 129, 130, 131 and so on...
    4. Mesh 'gloves' has 632 (out of 676) vertices with no weight and bone assigned (they will be assigned to bone #0 with weight 1). The list of vertices: 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 and so on...
    5.  
    And running the animation, I see weird "spikes" on the animated model with the animation not playing properly. I figure that this is some mistake with how I parented and animated the mesh from back in blender, but I'm not sure what to change to make it work properly in unity. What I did was to select the bones then select the model and parent the model to the bones selecting automatic weights. I then exported the model to fbx and imported it into Unity. How do I make this work?

    (I have attached the blend file and a screenshot of unity when the game is running.)

    ------------------------
    Ok ... I applied all the modifiers except the armature one on the objects before exporting and it works now :D ... Is that the normal way of doing stuff, or should it work without pre-applying the modifiers?
     

    Attached Files:

    Last edited: Nov 4, 2010
  14. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    You made several "mistakes", meaning you are getting trouble when exporting to Unity.

    Don't scale or rotate anything in object mode. Only do that in edit mode. E.g. the hair is rotated. Correct that by selecting it in object mode. Then Object->Apply->Scale or/and Object->Apply->Rotation.

    As you said you mixed using the Armature Modifier and armature, mesh parenting. If you want to "redo" the parenting, you need to select the objects beard, ears, ..., then Object->Parent->Clear Parent (Alt P) and Clear and Keep Transformation (Alt P).
    I never never used such a lot of splitted objects and used them with an Armature Modifier. I don't even know if that is supported in Unity. If it is, you may still think about joining objects such as nose, ear and face (select them in object mode, then Object->Join (Ctrl J).

    Whatever you do with those object, joining or not, you need to add an Armature Modifier. But as I said, I am not sure if that is supported.
    If not, you may join everything into one object.

    Lot's of work ahead :)
     
  15. lo

    lo

    Joined:
    Mar 15, 2006
    Posts:
    12
    Quick note, blender 2.55 just released, with this mention in the fixed issues log :
    #[23935] Exporting to Unity3d .fbx Blender 2.5

    ; ))
     
  16. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    I like ;) will try it after Unite :)
     
  17. Philbywhizz

    Philbywhizz

    Joined:
    Nov 20, 2009
    Posts:
    15
    I tried 2.55, and it didn't work (same issue).

    :(
     
  18. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    ....Here lies the dead Blender 2.5xx/Unity connexion which was sooooooooo handly by the past.

    Blender/Unity connexion, we miss you so much.

    :'(
     
  19. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    it's still in the emergency room, don't worry.
     
  20. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
  21. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    Do someone knows the exact command line passed to Blender from unity ?
     
  22. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    Alewinn, ask me again on Monday :) I'll check it out at work :)
    I have a plan to test latest Blender one of these days to see it the python problems have been fixed.
     
  23. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    For monday :
    Personally i use the following command to simulate the export inside a command window :

    blender "D:\PathToBlende\Bridge_2_V2_5.blend" -P "C:\PathToUnity\Unity-BlenderToFBX.py"

    Seems that the problem comes from ntpath.py and export_fbx.py inside the Blender python files.
    I will try to give it a look if i have some free time next week.
     
  24. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    ok i've got fine results with this code.
    NOTE the "os.getenv" line that i hardcoded to be able to simulate the export in command line.

    Code (csharp):
    1.  
    2. #import Blender
    3. import bpy
    4. import sys
    5. import os
    6.  
    7. try:
    8.     import io_scene_fbx.export_fbx
    9. except:
    10.     print('error: export_fbx.py not found.')
    11.  
    12.     #Blender.Quit()
    13.     # This might need to be bpy.Quit()
    14.  
    15. # Find the blender output file
    16. outfile = "kannweg.fbx"
    17.  
    18. #os.getenv("UNITY_BLENDER_EXPORTER_OUTPUT_FILE")
    19.  
    20. # Do the conversion
    21. print("Starting blender to collada conversion " + outfile)
    22.  
    23. import math
    24. from mathutils import Matrix
    25. # -90 degrees
    26. mtx4_x90n = Matrix.Rotation(-math.pi / 2.0, 4, 'X')
    27.  
    28. io_scene_fbx.export_fbx.save( None,bpy.context, filepath=outfile,
    29. GLOBAL_MATRIX=mtx4_x90n,
    30. EXP_OBS_SELECTED=False,
    31. EXP_MESH=True,
    32. EXP_MESH_APPLY_MOD=True,
    33. EXP_ARMATURE=True,
    34. EXP_LAMP=False,
    35. EXP_CAMERA=False,
    36. EXP_EMPTY=True,
    37. EXP_IMAGE_COPY=False,
    38. ANIM_ENABLE=True,
    39. ANIM_OPTIMIZE=False,
    40. ANIM_OPTIMIZE_PRECISSION=6,
    41. ANIM_ACTION_ALL=True,
    42. BATCH_ENABLE=False,
    43. BATCH_GROUP=True,
    44. BATCH_FILE_PREFIX='',
    45. BATCH_OWN_DIR=False)
    46. # I don't think HQ normals are supported in the current exporter
    47.  
    48. print ("Finished blender to collada conversion " + outfile)
    49.  
    the command line which succeed :

    Code (csharp):
    1.  
    2. blender "D:\PATHTOBLENDFILEINSIDEUNITY\Bridge_2_V2_5.blend" -P "C:\PATHTOTHPYFILEFROMUNITY\Unity-BlenderToFBX.py"
    3.  
    Note that it succeed ONLY if the descriptor inside the command line is on the right drive (here its "D", so had to do a "D:" command to make it work, see http://blenderartists.org/forum/showthread.php?t=202531)

    Everything seems ok on the blender side.
     
  25. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    Pauuuuliiiuussss !!!
    It's Monday !!! :D
     
  26. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    Alewinn, I got it working when I run it without -b option (which makes it run in window mode), but it still doesn't work in background mode - I get tons of errors. Just try running
    and see for yourself.

    There are a lot of restrictions with where your scripts/output files have to be located (even capitalization of volume...).


    Regarding command line: Unity runs blender in Blender forlder, i.e. something like this:
    And it passes absolute paths in all arguments:
    I'll try to get hold of Blender developers to see what they think about these issues.
     
  27. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    For me the following sequence works perfectly without any error "-b" option included.
    The fbx file produced is ok for unity :

    Code (csharp):
    1.  
    2. cd "D:\01_Projets\Uruk_Monojoueur\trunk\CoreU3\Uruk_Monojoueur\Unity\Assets\01_Objects\Dodads\00_Swamps\Environement\Ruins\Bridge_2\"
    3. "C:\Program Files (x86)\Blender Foundation\Blender\blender.exe" -b "D:\01_Projets\Uruk_Monojoueur\trunk\CoreU3\Uruk_Monojoueur\Unity\Assets\01_Objects\Dodads\00_Swamps\Environement\Ruins\Bridge_2\Bridge_2_V2_5.blend" -P "C:\Program Files (x86)\Unity\Editor_3\Data\Tools\Unity-BlenderToFBX.py"
    4.  
    Original syntax i use :

     
    Last edited: Nov 22, 2010
  28. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    Ok. I'll try that again. Did you change anything in default Blender installation options while installing it?
     
  29. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    No no i installed Blender with default options.
    Only thing i did is install scripts inside the blender folder (second option in the blender installation) but i think it will work with any of these options.
     
  30. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    I used the first option and I changed the installation path (I didn't want it to override 2.49 installation). Anyway, I'm on it.
     
  31. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    mmm...
    If i use the default directory with second option choosed at the installation the exporter works ok, EVEN FROM UNITY !! (at less with my script version). But even in this case the fbx exporter don't work for animations (Blender crashes or the exported animation is totally screwed)

    But if i choose to use another directory for the installation the exporter don't work anymore...
     
  32. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    You should send that to Blender guys.

    It's good to know that I'm not the only one having that problem. I'll try the zipped Blender or the second installation option tomorrow.
     
  33. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
  34. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    Good news !

    The 33297-Win64 Build seems to work :
    http://www.graphicall.org/builds/builds/showbuild.php?action=show&id=1592

    As it don't include any installer i will try to install a conventional 2.55 - 64bits install and replace the files withe the ones inside this build.
    For the moment i tested only in command line and it seems to be ok.
    I will try with a whole Unity project during this morning.
     
  35. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    Blender doesn't need installer - you can just extract the program to ProgramFiles (on Win) or Applications (on Mac), associate it with .blend files and everything works.
     
  36. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    Alewinn and Paulius, this is great news!
    Really looking forward to blender 2.55.

    Now if i only could get blender 2.55 associated with blend files. Stupid windows just won't accept my file type association to blender 2.55...
     
  37. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    => That's why i'm trying to "hack" a blender install :)
    (sorry, haven't had time to validate this morning.. .trying tonight !)
     
  38. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    I can confirm it's ok (sorry for the delay !)

    For those who can't wait next Blender official version, the process i followed :
    NOTE : WAIT UNTIL NEXT BLENDER OFFICIAL RELEASE IF YOU DON'T KNOW WHAT YOU DO !

    1- Backup the project :)D)
    2- Backup "C:\Program Files (x86)\Unity\Editor\Data\Tools\Unity-BlenderToFBX.py" and replace it with the attached .py file
    3- Uninstall Blender 2.49b and all other Blender versions
    4- Install Blender 2.55 64bits with INSTALLER (i didn't tryed with a 32bit version) => Blender 2.55 64Bits installator
    5- Download Blender 2.55 64 bits R.33390 (or higher) => Blender 2.55 Trunk SVN r33321 Windows x64
    6- Unzip and replace all files from your official install (C:\Program Files\Blender Foundation\Blender) with the files inside the zip
    7- Open your project, should work.
     

    Attached Files:

    Last edited: Dec 1, 2010
  39. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    Hey Alewinn

    Cool, that worked, thanks for the tip!

    Unfortunately, my actions don't get exported correctly. Unity creates an animation for each of the actions defined in blender, but when I try to play one of those animations (throug the autoplay feature or a script), it always plays the one that was active/selected when I saved the file in blender. I was lookin at the imported animations in the Unity Animation Editor/View, and it looks like Blender or Unity somehow uses the same curves from the active/selected action in blender for all the imported actions... So when I have an animation "walk" and that was the active action when saving the file in blender, all other actions on this model in unity use the curves of the "walk" animation.... Am I doing something wrong or did you encounter this problem aswell?
     
  40. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    i can be wrong but it's normal.
    In fact i know 2 ways to work with animations with blender/unity :

    1- using the "split animation" option of the fbx importer. you have to paste all your animations inside blender in just one action, then give Unity the starting/ending frame of each animation. Your Blend file will have only one animation. don't forget to connect your armature with the action

    2- using the "@" naming. You will have to duplicate your blend file for each animation, use a "@" inside the name of the blend to tell unity which animation is inside the file.
    Example :
    You have a blend file with a guy with 3 animations : idle, walk and run.
    You will have 4 files :
    Guy.blend => The guy mesh with weightpaints and armature
    Guy@idle.blend => only the armature with the idle animation
    Guy@walk.blend => the walk
    Guy@run => the run

    normally unity import all in one mesh (sometime have to remap by hand)
     
  41. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    brrrrrr, that would be a big step back from blender 2.49 -> unity workflow...

    the way i worked the last year was like this: create one blend file with one model and one rig, put all animations in separate actions, let unity import the file and autosplit the animations from that file into perfectly working unity animations. done.

    to edit an animation, double click the blend file to get to blender. change something in one action, save in blender, switch to unity, animation is updated and ready to be used...

    i really hope i don't have to create several files or paste actions together. that would make me really sad :p
     
  42. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    woodn, that is also the way I am working with animations. So far I am using the fbx exporter manually with Blender 2.5x and I can still work like that. I just have to export it after each change.
    So I expect the script could be improved, such that it still works like that.
     
  43. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    Dantus, I'm glad to hear that! I'll just wait a little longer then ;-)
     
  44. Paulius-Liekis

    Paulius-Liekis

    Joined:
    Aug 31, 2009
    Posts:
    672
    Yes, Unity is able to import multiple actions from single fbx file (i.e. without splitting). So it should work as long as Blender exports them correctly.

    And if you have actual bugs on Blender side then please submit them to Blender, so they can fix it before the release.
     
  45. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    Dantus, what version and build of blender are you using? I just tried fbx exporting in the official build 2.55 beta and some graphicall builds (32bit and 64bit) and i still have the problem that all the exported actions share the same curves of the animation that is active when exporting from blender...
     
  46. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    That said i noticed some strange behaviors concerning animated prefabs used inside a unity scene that have been migrated from 2.49b (see the screen capture).
    I had to rebuild the prefab to get all in good position. Is there something to do inside unity to have this migrated automatically ?
     

    Attached Files:

  47. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    Garr, this drives me nuts. Could someone with a spare minute and a "working" blender 2.5x setup export the content of this blend file to fbx and check out the animations in unity? I tried about 5 different builds now and i always get the same result. Unity imports the fbx file just fine, creates 2 animations as it should but the animations (their curves) are identical...

    The file:
    http://vol-2.com/div/files/actionstest.zip
     
  48. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
    I love this job as i learn every day ! Sure this is very handly !

    yes i have the same thing with your file...
    It seems that the animations data inside the fbx file are effectively the same.
     
    Last edited: Nov 27, 2010
  49. alewinn

    alewinn

    Joined:
    Nov 8, 2009
    Posts:
    185
  50. w00dn

    w00dn

    Joined:
    Apr 28, 2010
    Posts:
    275
    Alewinn, thanks for confirming and reporting it so quickly! I'm glad it was a bug ;-)