Hey guys I created a blender python script that exports static meshes from blender to unreal
the script exports all selected static meshes along with their collision proxies, each to a separate fbx file.
Hey, this is an update to my blender to unreal engine exporter V1.1
Updated to V1.2
updated to v1.3
-The script is now an addon, you need to enable and use it from file -> export -> UnrealEngine(.fbx).
-The addon now has an option to preserve instanced meshes, so when you have multiple objects using the same data block, only one of those objects gets exported, and the rest references this static mesh in unreal engine.
-The addon now also has an option to only serialize objects to clipboard, so when you need to copy an object for pasting in unreal, you can now do this without the need to re-export.
-Fixed rotation order and conversion to degrees.
-Now if “Preserve Instances” option is selected, you must have one of the meshes sharing the same data block named with the prefix “SM_REF”, to identify which mesh should be exported. also that object’s transform should be zeroed out (apply rotation and scale).
-Fixed bug in reference static mesh search function
-Just extract the content of this zip file to your blender/scripts/addons folder, restart blender and enable it from “User Preferences”.
-Write the path “Asset Path” to your relative unreal assets path used to save your meshes ex:“/Game/Assets/meshes/”
-Select all the objects you want to export, it doesn’t matter if you select collision objects or not, because it gets exported any ways.
-Select export from blender file menu.
-Go to unreal and import the objects as usual.
-Go to edit menu in unreal and select “paste”.
-All objects should be in it’s original location as well as rotation and scale.
also all instanced meshes in blender should be instanced meshes in unreal.
The workflow to export static meshes from blender to unreal is:
-Set your scene scale to 0.01
-Finish your model in blender and create 2 UV sets, first one will be used for texturing and the second one will be used by UnrealEngine for baking light maps.
-If you have models that shares the same data block and should be instanced in unreal select one of those meshes and prefix it’s name with “SM_REF_”
and Ctrl+A and select “Rotation & Scale” to zero out this mesh rotation and scale (this is necessary for instanced meshes to be exported correctly).
For example if you have a 3 meshes “door1”, “door2” and “door3” and the all share the same data block, select one of them, say “door 1” and rename it “SM_REF_door1” or “SM_REF_AnyName”
and hit Ctrl+A and select “Rotation & Scale” to zero out it’s rotation and scale.
-Now if you want to preserve instanced meshes in unreal create a collision meshes for this mesh only using the usual unreal collision mesh prefix for example “UCX_SM_REF_door1_01”, “UCX_SM_REF_door1_02”…etc
otherwise create a collision mesh for every model.
-From blender “Select” menu select “Select All By Type” → “Mesh”. to select all mesh objects.
-From blender “File” menu select “Export” → “UnrealEngine (.fbx)”
-In the “Assets Path” export option write the relative path to your Unreal project mesh directory, default game directory in unreal is “/Game”.
This will export a separate fbx file for each object selected. every fbx file contains one object positioned in world origin (0,0,0) with all it’s collision meshes.
If “Preserve Instances” option is checked the addon will search for an object with the prefix “SM_REF_” and export that object only so when importing to unreal all objects will reference that mesh.
-Right click in the “Content Browser” window and select “Import In <FolderName>”.
-Select all fbx files exported from blender.
-In the import dialog deselect “Merge Objects” and “Generate Lightmap UV” options. (this assumes that you have created 2 UV sets in blender)
-Click on “Import All”
-After import go to “Edit” menu and select “Paste” (This assumes that you’ve selected “Serialize To Clipboard” option when exporting from blender)
this will paste all the meshes in it’s original location as it was in blender, also all instanced meshes should be created and should reference the same static mesh
exported from blender. for example “door2” and “door3” will be created and their static mesh will be “SM_REF_door1”.
Also all objects should have their origin in the same position as it was in blender.
-If you modify some object location, rotation or scale in blender and you want to update it’s transform in unreal. select that object and export again from blender,
but this time uncheck “Export” and select “Serialize To Clipboard” this will only write the object to clipboard and not export it again to save time.
Then go to unreal and delete that object from the PERSPECTIVE VIEW NOT FROM CONTENT BROWSER and again from the “Edit” menu select “paste” to paste it again.
I wonder if you know why I’m having issues atm doing:
Export item, showing a scale in UE4 of 1181.0 on all vectors, its mountain mesh on top of a very large terrain. I’ve not been having any problems until today and Im not sure what I may have done to cause it possibly, but importing into blender has the scale at .010, which is way off and if try to make changes the scale is just too small to allow zooming very far before the mesh starts to disappear due to camera aperature problems I suspect. It was all working fine, as mesh would export out from ue4 into blender with 1.0 scale and always the same values in blender for size but no longer and I have no idea what caused it.
How do I solve this mess ?
Well anyway such as that is, I’ve just decided to go ahead and import new mesh2 and apply loc rot and scale and that worked out ok, but it’s far from ideal.
Indeed something is wrong with blender windows version not the addon, because the same addon on linux exports objects correctly and when objects are re-imported in blender they have the same scale and everything.
I did a test exporting a normal fbx from blender without the addon and tried to reimport it back. it came out very small on windows, but with the correct scale on linux.
meanwhile, you can change the scale when importing in unreal, in the import dialog to 0.01. this should fix the problem.
please tell me if this fixes the problem.
Im not currently using the addon at all, I was just wondering why this odd mismatch occurs, if its something I’m not doing quite right , or what .
Im not that worried about exporting a 'new 'mesh as the unreal doc page says to use ‘100’ for fbx settings on export, is that still valid or old information ?
The problem I have which is really nasty ( not tested with any other modeler atm) is that I export mesh from ue4, import into blender , alter mesh and then rexport as same fbx over location in unreal folder , and of course then just right click mesh In content browser windows and done. BUt its rarely right, althought it def. was for a time.
So you’re saying 2.73 has fixed issue, so is you addon still needed ?
I want to be clear on this but honeslty I*'ve lost too much time already with messd up scale, location and rotation, but thank god last night I was able to luckily work around it with some manual work , but that’s not ideal and slow as you can imagine
Thanks for taking time to fix these things
I"ll try 2.73 on a test and see if that fixes things and go from there.
Btw I’m really not sure I ‘m ready to risk my project work with a non release blender, as it does say on downpage page, ’ use at your own risk’ . That bothers me , but I guess I could try it out on test meshs yes.
One last thing and purely blender atm, why when I create a default simple cube from spacebar menu, is the cube buried half in grid and half out ? Isn’t it suppose to be exactly at 000 ?
Trouble is, how do we know if a object is coming into blender with proper scale,I mean how do we adjust for the differences between what ue4 says about ‘scale and rotation and location’, and know what we see in blender is as it should be ?
That would go a long was to ending some frustration Im sure many have.
Oh btw I tried 2.73,but its not very stable atm, as it lags horribly on the same mesh where 2.72b doesn’t but of course its a RC so no huge surprises probably.
The primary need for the addon is to put objects in unreal as it were in blender. So you save a lot of time re-arranging objects in unreal.
For one to know that object is imported in blender with proper scale, it’s easy…just re-export it back from blender and import it to unreal and compare it with the original object.
For the export from blender though, You need to set the scene scale in blender to 0.01
Also I never had any problem using a blender build from the link I gave you, these are official builds too.
Well my current problem, is what if I have to take a blender mesh into sculptriS ( I can’t get comfortable yet sculpting in blender), then back into blender to work in edit verts etc., then into UE4. Blender back into UE4 has been no issue at all, as I just used the mesh ( once I got it into position that is where I needed it to be <very complex placement for this mesh> ) as is in and back out to UE4 never any problems, but adding sculptris to the mix is again causing problems.
Its because when I import into sculptris I have to scale it up more to be able to work on it properly ( camera aperature I think ), then back into blender and scale is way too big as expected.
Would you addon allow easier workflow between sculptris <> blender and keep scale, or if not, what do I need to do to solve this hassle
Well I grabbed 2.73 from official blender download page, so if they are the same, then I guess its the combination of cpu and gpu for me, or that my GPU is amd ?
It may also be that my mesh is much larger than anything you’re currently working on, mine is at about 150K.
First, the addon has nothing to do with sculptries, If you export your mesh to sculptries and export it back to blender you should rescale it back to were it was.
Second, You need to copy the folder “io_unreal_engine_fbx” which contains 2 files “init.py” “and export_unreal_engine.py” to your blenderFolder/2.73/scripts/addons
then start blender and go to “User Preferences” click on “Add-ons” tab and from the left menu click on “Import-Export” then in the right side of the window you should see “Import-Export UnrealEngine4 FBX”
just tick the box next to it to enable the addon.
SOrry about confusion over script, I thought I was extracting a zip ( thought would contain the ‘folder’ ) file that would extract the actual folder, then I realized the zip file itself is how blender adds them ( not in a folder format), and lastly I did try to scale image taken from sculptris using settings from original mesh imported into sculptris ( from blender), and trying to do so using x y and z values makes image very stretched and unusable, and the ‘scale’ values are no longer 1.0 precisely. I scaled object inside sculptris as it was just too small to work on for my needs, so maybe that is what is causing this mess, is there a way to fix this mess Next time I’ll avoid scaling in sculptris if that was the problem.