[SOLVED] Cannot export mesh in blender for MeshComponent

I’m using defold_mesh.py exporter in blender, but getting this message:

  File "C:\Users\despe\AppData\Roaming\Blender Foundation\Blender\2.92\scripts\addons\defold_mesh.py", line 137, in execute
    export_to_file(f, indent=self.indent)
  File "C:\Users\despe\AppData\Roaming\Blender Foundation\Blender\2.92\scripts\addons\defold_mesh.py", line 106, in export_to_file
    streams = export_mesh(mesh)
  File "C:\Users\despe\AppData\Roaming\Blender Foundation\Blender\2.92\scripts\addons\defold_mesh.py", line 40, in export_mesh
    mesh.calc_tangents()
RuntimeError: Error: Tangent space can only be computed for tris/quads, aborting


location: <unknown location>:-1

is something wrong with my project/model?

here is project file https://filebin.net/mxtfmvav4w80bkqa/mockup-car.blend

Not sure what that defold_mesh.py exporter is for? In Blender you should be able to export your mesh as Collada ( .dea ) format and use it in your defold project.

It is for mesh component

2 Likes

What type of mesh do you have?
The error message you posted suggests that your mesh doesn’t consist of neither triangles nor quads?

I’m not savvy in regards of meshes tbh, so you question is quite unexpected to me.

In my understanding, it’s completely regular mesh with positions, indicies, attributes etc. Here is snapshot from blender project:

1 Like

Apologies for my misunderstanding. I did not know about mesh component in defold. So this is perfect time for me to learn :slight_smile: . I took a look at your blend file and converted all quads to tris but as @Mathias_Westerdahl said that should not be the problem. I did find the issue. It was 14 unused duplicate vertices , so I removed them and was able to export your car model without error.

Mesh Component.zip (305.9 KB)

4 Likes

Wow, thanks @MasterMind

I would like to understand methodics of how you identified the problem at all. Can you share it

2 Likes

Sure thing , taking a second look I notice it was more than just doubles and I did not explain!

RuntimeError: Error: Tangent space can only be computed for tris/quads, aborting

This error is telling us that there is geometry that can’t be computed because it is not tri/quad edges, So I would think it may be that it is either N-gons or loose vertices (vertices without connections) . In blender we can select all with shortcut key (A) then tab into edit mode and 1 key for vertice select mode, then we can use ( Menu: Select/SeletecAllByTrait-Faces by sides ) to check for (tri/quad/n-gon) easily by adjusting “Number of Vertices” - property. Doing this I found that you had no n-gons. So move on to check for loose vertices. For this we use ( Menu: Select/SeletecAllByTrait-Loose Geometry ) this revealed 59 vertices in your model with no connections this is why you were getting the error on export. We can remove those.

From experience a very common issue can be doubles. Duplicate vertices that have the same or very near vector positions and they are hard to catch going unnoticed by the modeler. Some times it may be intentional and other times we might need to clean these up. In blender you can remove doubles by right clicking ( Merge_Vertices/By_Distance ) or alternatively (Menu: Mesh/Clean_Up/Merge By Distance) using small values we can merge vertices within radius/range of each other. So I selected all vertices in your mesh and merged doubles, removing 14 vertices .

Also I took a close look around your model and have found lots of small geometry that doesn’t seem to useful which I would clean up here’s an image of all loose vertices and odd geometry.

Loose_vertices

Overall, Defold_export.py error was very useful. Maybe we make a mistake during modeling or we get a model from elsewhere and we need to clean up the geometry . It’s also very good practice to review by eye and optimize when you can of-course. Hopefully this helps you!

8 Likes

What an extensive explanation, just what I needed, thanks a bunch man. Im just started tinkering with blender recently and become confused often. :heart:

5 Likes