Why is the Obj file displayed incorrectly?

The object file exported from Cinema4D is displayed correctly in MeshLab. But if I load it in bablon via ImportMeshAsync or ImportMesh it is displayed incorrectly in several places: https://i.imgur.com/Nd0t4fm.png

Here is the obj-file:

Does anyone have a solution for that?

Thank you.

Pinging @brianzinn to see if he have some cycles to check

You can try this too

I’ve requested access. I will check on MeshLab and compare after you approve my dropbox request. Cheers.

OPTIMIZE_WITH_UV did not work. This doesn’t seem to be a problem for babylon. In SketchUp I had the same phenomenon. Only when I converted the object to the COLLADA (dae) format everything was fine. Unfortunately Babylon does not (yet) support this format.

Case closed.

1 Like

I have also confirmed that the UV optimization option did not work and that it is loading correctly in MeshLab (and not in BabylonJS). The normals and faces are quite a bit off in the sandbox/PG. MeshLab is more forgiving for different exporters - I’ll have a better look at your file. It would be helpful if you could make a smaller reproduction with just a few faces, but I will try with what you have provided. I am super busy currently, but will try to make some time soon. Cheers.

edit: I don’t need a smaller repro. i can use your 2nd number part of mesh.

I’ll still give it a try as I enjoy working on these importer/exporter things :slight_smile:

That was kind of fun. I did manage to track down the issue. It is exported in a way that is parsed incorrectly.

If you look at line 2901 of your file, you will see the faces defined as:
f 289/1/289 283/1/283 284/1/284 285/4/285 286/5/286 287/1/287 288/1/288

So, 289 is a point in every triangle and it will take 2 triangles from each following set of vertices.
eg: {289,283,284}, {289,284,285}, {289,285,286}, {289,287,288}. Note that 289 is the first point in all triangles and I have drawn the “fan tesselation” in the attachment.

If you look at line 2903, to work in BabylonJS and many other programs (even Paint3D) to match then it should be:
f 296/1/296 290/1/290 291/1/291 292/1/292 293/1/293 294/6/294 295/2/295

But it is:
f 291/1/291 290/1/290 296/1/296 295/2/295 294/6/294 293/1/293 292/1/292

What the OBJ file loader is doing is taking the first position 291 and joining to 293, which is what is giving you those weird faces. So, the current algorithm works on the first group of faces, but not on the second. It would work on the 2nd group if it was done backwards or if the tessellation looked more intelligently for choosing a pivot point with no overlap (if possible). You have already marked as solved, so assuming there is nothing to do here.

1 Like

It’s a pleasure to be here. Thank you very much for the insights into the structures of a world that are still unknown to me.

We do e-learning with Adobe Captivate and Animate, and as an old hand in programming, development with these tools is slowing me down. I started looking for an alternative. What remained were Processing.js, Three.js, Pixi.js and Bablyon.js. The decision was made after careful consideration on Babylon.js - a wonderful library, very good documentation, a forum with enthusiastic capable players and a playground with many examples - who likes to read the documentation :wink:


Translated with www.DeepL.com/Translator