thomthom / quadface-tools

Suite of tools for manipulating quad faces in SketchUp.
https://extensions.sketchup.com/en/content/quadface-tools
MIT License
18 stars 1 forks source link

Exporting OBJ generates duplicated faces for triangulated quads #134

Open alsomar opened 4 months ago

alsomar commented 4 months ago

I've been struggling with this issue for quite some time, but since I didn't fully understand what was happening, I couldn't provide useful feedback. Recently, however, I've been able to clearly identify the problem and even managed to resolve it using Meshlab, a free software to clean and improve 3D models.

The Issue

The OBJ files generated with the OBJ exporter from QuadFaceTools have duplicated faces in those quads that have been triangulated in SketchUp.

When you open an OBJ file created with this exporter, software like Blender automatically resolves this issue. However, other software such as Substance Painter or RizomUV may struggle to handle these duplicates correctly.

I believe this issue is the root cause of these issues:

Reproducing the Issue

I created a simple SketchUp model with just two cubes:

240622_skp_cubes

Each cube have 24 quads. The triangulated one (on the left) is a component called 'cube_t', and the other one (on the right) is also a component called 'cube_q'. I exported them separately using the OBJ exporter from QFT to identify the problem, using the following settings:

240622_skp_qft_exporter

After exporting, I obtained these two files: cube_q.obj and cube_t.obj.

Next, I used the free open-source software Meshlab to check the number of faces in each OBJ file. After opening Meshlab, navigate to File > Import Mesh and select cube_q.obj.

240622_skp_meshlab_1B

For the first mesh ('0'), you can see there are 48 faces (24 front + 24 back), as expected. However, when I added cube_t.obj using File > Import Mesh, for the second mesh ('1'), there were 96 faces, TWICE (!) the expected number for the same number of quads.

240622_skp_meshlab_1C

This issue causes Substance Painter to struggle with generating proper automated UVs, while RizomUV fails to correctly utilize OBJ files exported from QFT's OBJ exporter.

Fixing these OBJ Files using Meshlab

Until a potential solution is considered within QFT's OBJ exporter itself, here's a simple and practical solution using MeshLab:

  1. Select the problematic mesh from the Layer Dialog.

  2. Go to Filters > Cleaning and Repairing > Remove Duplicated Faces. Step 2 Screenshot

  3. After completing the previous step, verify that the number of faces in cube_t.obj is 48. If correct, proceed to File > Export Mesh and save the corrected file as new_cube_t.obj (or a similar name).

If you try to open this corrected file in RizomUV or Substance Painter (using the auto-UV features), it should work smoothly.