LogicalError / realtime-CSG-for-unity

Realtime-CSG, CSG level editor for Unity
https://realtimecsg.com
MIT License
761 stars 80 forks source link

Cannot export to fbx anymore with 2018.3b10 #277

Closed VergilUa closed 5 years ago

VergilUa commented 5 years ago

Exporting any model to the fbx fails with the following errors:

NullReferenceException: Object reference not set to an instance of an object InternalRealtimeCSG.GeneratedMeshInstance.OnEnable () (at Assets/Plugins/RealtimeCSG/Runtime/Scripts/Components/GeneratedMeshInstance.cs:186) UnityEngine.Object:Instantiate(GameObject, Vector3, Quaternion) InternalRealtimeCSG.MeshInstanceManager:Export(CSGModel, ExportType, Boolean) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/MeshInstanceManager.Export.cs:113) RealtimeCSG.CSGModelComponentInspectorGUI:OnInspectorGUI(Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/ComponentEditorWindows/CSGModelComponent.Inspector.GUI.cs:370) RealtimeCSG.EditModeSelectionGUI:OnInspectorGUI(Editor, Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeSelection.GUI.cs:244) EditModeToolWindowEditor:OnInspectorGUI() (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeToolWindow.Editor.cs:15) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Mesh indices of Floor_1_Diffuse (1) are out of range! UnityEditor.AssetDatabase:ImportAsset() UnityFBXExporter.FBXExporter:ExportGameObjToFBX(GameObject, String, Boolean, Boolean, Boolean) (at Assets/Plugins/RealtimeCSG/Editor/Thirdparty/UnityFBXExporter/FBXExporter.cs:78) InternalRealtimeCSG.MeshInstanceManager:Export(CSGModel, ExportType, Boolean) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/MeshInstanceManager.Export.cs:233) RealtimeCSG.CSGModelComponentInspectorGUI:OnInspectorGUI(Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/ComponentEditorWindows/CSGModelComponent.Inspector.GUI.cs:370) RealtimeCSG.EditModeSelectionGUI:OnInspectorGUI(Editor, Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeSelection.GUI.cs:244) EditModeToolWindowEditor:OnInspectorGUI() (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeToolWindow.Editor.cs:15) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

This is on 2018.3b10 & RealtimeCSG v1.540

Nothing too fancy on the model as well. It's plain cube with 20 verts. This happens to any model I try to export. Exporting produces empty fbx with 0 tris / verts.

LogicalError commented 5 years ago

Thanks for letting me know, I'll check it out

LogicalError commented 5 years ago

Fixed in 1.541! I'll close this ticket once this version is available from the asset store

VergilUa commented 5 years ago

Ummm, the error is gone, but generated mesh is still got 0 polys on it. And got this warning:

Mesh indices of Beam_02 (1) are out of range!

UnityEditor.AssetDatabase:ImportAsset() UnityFBXExporter.FBXExporter:ExportGameObjToFBX(GameObject, String, Boolean, Boolean, Boolean) (at Assets/Plugins/RealtimeCSG/Editor/Thirdparty/UnityFBXExporter/FBXExporter.cs:78) InternalRealtimeCSG.MeshInstanceManager:Export(CSGModel, ExportType, Boolean) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/MeshInstanceManager.Export.cs:233) RealtimeCSG.CSGModelComponentInspectorGUI:OnInspectorGUI(Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/ComponentEditorWindows/CSGModelComponent.Inspector.GUI.cs:370) RealtimeCSG.EditModeSelectionGUI:OnInspectorGUI(Editor, Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeSelection.GUI.cs:244) EditModeToolWindowEditor:OnInspectorGUI() (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeToolWindow.Editor.cs:15) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

This one is probably due to mesh being broken though.

LogicalError commented 5 years ago

Ok, that sounds like the fbx importing code has changed .. I'll take a look to see if it's realtime-CSG's fault .. it might be a bug in unity though

LogicalError commented 5 years ago

Can you try exporting a non broken mesh?

export_2 export_1

Everything seems to work for me in 2018.3b11 .. at least for a simple mesh?

VergilUa commented 5 years ago

By broken I meant the one that doesn't export.

I was still on b10, will download b11 and see if it works there.

LogicalError commented 5 years ago

Ok, if that doesn't work for you can you send me the model that doesn't export? Then I can figure out what's going on here ..

VergilUa commented 5 years ago

Here's prefab of it and fbx exported file Beam.zip

It's not quite as simple as cube though. It's a cyllinder with edited vertices via edit mode.
(Top scaled down)

VergilUa commented 5 years ago

Same behaviour on b11

VergilUa commented 5 years ago

This happens not only on cyllinder but on any model I have. Same applies for extremely simple ones, e.g. cubes. As well as any fresh created ones.

LogicalError commented 5 years ago

Strange .. it seems to work for me .. the only issue I'm seeing is that the export fails when a material is missing .. but I assume you have materials applied to it? Could it be prefab related? Are you seeing the same problems if you unpack the prefab before you export it?

VergilUa commented 5 years ago

I don't have it (or any other model) as a prefab, simply made it one for exporting. No idea why it fails. Yeah, materials are not an issue. Any ideas what might help?

LogicalError commented 5 years ago

Can you try this in a clean project on 2018.3b11 w/ latest realtime csg version, no prefabs? Just want to rule out something somehow interfering with realtime-CSG

VergilUa commented 5 years ago

2018.3b11 & Realtime CSG 1.541 (2018.2f1 package), same behaviour in the clean project, except different error poped up: ImportFBX Errors: Internal FBXImporter error: normal count (0) doesn't match tangent (36) or/and binormal count (0).

UnityEditor.AssetDatabase:ImportAsset() UnityFBXExporter.FBXExporter:ExportGameObjToFBX(GameObject, String, Boolean, Boolean, Boolean) (at Assets/Plugins/RealtimeCSG/Editor/Thirdparty/UnityFBXExporter/FBXExporter.cs:78) InternalRealtimeCSG.MeshInstanceManager:Export(CSGModel, ExportType, Boolean) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/MeshInstanceManager.Export.cs:233) RealtimeCSG.CSGModelComponentInspectorGUI:OnInspectorGUI(Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/ComponentEditorWindows/CSGModelComponent.Inspector.GUI.cs:370) RealtimeCSG.EditModeSelectionGUI:OnInspectorGUI(Editor, Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeSelection.GUI.cs:244) EditModeToolWindowEditor:OnInspectorGUI() (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeToolWindow.Editor.cs:15) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Mesh indices of Wall (1) are out of range!

UnityEditor.AssetDatabase:ImportAsset() UnityFBXExporter.FBXExporter:ExportGameObjToFBX(GameObject, String, Boolean, Boolean, Boolean) (at Assets/Plugins/RealtimeCSG/Editor/Thirdparty/UnityFBXExporter/FBXExporter.cs:78) InternalRealtimeCSG.MeshInstanceManager:Export(CSGModel, ExportType, Boolean) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/Control/Managers/MeshInstanceManager.Export.cs:233) RealtimeCSG.CSGModelComponentInspectorGUI:OnInspectorGUI(Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/ComponentEditorWindows/CSGModelComponent.Inspector.GUI.cs:370) RealtimeCSG.EditModeSelectionGUI:OnInspectorGUI(Editor, Object[]) (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeSelection.GUI.cs:244) EditModeToolWindowEditor:OnInspectorGUI() (at Assets/Plugins/RealtimeCSG/Editor/Scripts/View/GUI/EditModeGUI/EditModeToolWindow.Editor.cs:15) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Produces same 0 polys model.

LogicalError commented 5 years ago

export this is what I'm seeing ..

LogicalError commented 5 years ago

(that's with the invalid material fix & changing the name of the mesh so it's easier to distinguish from the material in the fbx)

LogicalError commented 5 years ago

Could you record how you're doing the export etc. so I can do the same steps exactly like you're doing? There must be something that's different that's causing your problems ...

VergilUa commented 5 years ago

The model seems to be broken into parts, but it was completely solid and joined together. Weird. Posted my test on the clean project above.

LogicalError commented 5 years ago

broken in parts, you mean in the animated gif? that's just aliasing because it was thin and far away .. the model is solid for me

VergilUa commented 5 years ago

Yeah, in gif. If it's solid then it's okay. No idea why exporting doesn't work in empty project though.

VergilUa commented 5 years ago

Second time I've tried exporting the first error is gone (this one):

ImportFBX Errors: Internal FBXImporter error: normal count (0) doesn't match tangent (36) or/and binormal count (0).

But still same result. emptyproj

LogicalError commented 5 years ago

I've found it. It's a localization issue .. these fbx files are text files and the coordinates are stored differently depending on your locale ... so in this case 0.5 would be stored as 0,5 on your computer ... now consider that coordinates are separated by , you get 0,5,0,5,0,5 instead of 0.5,0.5,0.5. One of these is 6 values, the other is 3 🙄 Easy to fix though. Just don't understand how this is possible .. either unity was automagically fixing this before, or it never actually worked in different locales?

LogicalError commented 5 years ago

I just uploaded version 1.542, can you check if this version fixes your issues? Thanks

VergilUa commented 5 years ago

Yeah, it works. Thanks! :)

LogicalError commented 5 years ago

This version is now available from the asset store so I'm closing it