OBJ Import problem

my name is thecloser_ and I’m writing a tool for editing a game-scenery due the weeks.

But I have a problem when I try to Import my written OBJ File in Blender. All Vertices are saved correctly in the file, but (I hope) Blender has some Problems with drawing the faces:
Blender creates wrong faces, although all face-indices are correct:

o Object_0002
v -20480 693,742 -10240
v -20480 693,742 -9216
v -19456 693,742 -9216
v -19456 693,742 -10240
f 6 5 7
f 6 7 8

gives the shown result in the Image below (EditMode).

So what is the problem? I readed the Face-Indices from the game file 100% correctly, but I can’t help myself anymore.
Does anybody know why blender creates not 2 normal triangles?


It’s not like Blender has Minority Report:

You could instead go with

o triangles
v -20 0 -10
v -20 0 -9
v -19 0 -9
v -19 0 -10
f 1 2 3 
f 2 3 4

And what can I do to avoid the mistake while writing the OBJ File?
I mean, the face declaration up there is correct, we have 2 triangles and 4 Vertices.

Why does blender draw these triangles incorrect?
Or is there maybe a Logical error by myself? Cause the game can read those indices correct.

Btw: Your code shows the 1st object, but this Problem with the faces occurs from on the 2nd Object until the 460th object

Now idk if the error is even here.
This works just fine:

o Plane
v -1 0 1
v 1 0 1
v -1 0 -1
v 1 0 -1
v -20 0 -10
v -20 0 -9
v -19 0 -9
v -19 0 -10
f 1 2 4 3
f 6 5 7
f 6 7 8

and the vertex order for 2 tris is copy/paste from your’s.

Could you maybe paste some more from obj file besides these 2 tris?

Ok, I attached the code of the first 25 objects - this should be enough to see my problem. The full obj file has ±295MB and ~2.000.000 Triangles.
All vertices are placed correctly, only the faces have this error.
Maybe it’s neccessary to know that I have used absolute indices for faces,
if I remeber right, relative indices are not (?) supported by blender (long time ago since last check, I prefer the absolute ones :wink: )


TestOBJ.zip (136 KB)

Whatever this is it imports just fine both in Meshlab and Blender. It’s gone wild during export likely.

Thank you for re-telling my Problem, eppo :wink: You should read my Posts more carefully :slight_smile:

1st Post:

3rd Post:

Import works fine, there is no script error. My only Proble is that ugly mesh, I don’t know why it appears, cause I don’t see a Problem in the file.


The flipped triangle in your first picture shows me that you may have a problem with the creation order. Faces gets created and read in clockwise mode. When you read them counter clockwise, then the normal points into the other direction, since the writing happens in clockwise mode again.

Check if it helps to change the order of the index.

from this:

f 6 5 7
f 6 7 8

to this:

f 6 5 7
f 6 8 7

EDIT says, hmmm, no, changing the winding order would just flip the normals. I think it’s the wrong vertices that you grab here for your triangles.

Try this one:

f 5 6 7
f 5 7 8

I readed the Face-Indices from the game file 100% correctly

Yes, i did red that but it takes certain amount of deduction to realize you’ve used your own code to do that, sorry was not keen enough.
Second, there is no way to tell what is “correct” in your case - is this two overlapping triangles or should it be a quad.
Looking at obj it’s triangles:

and normals are different as it was pointed out by Tiles.
Exporting all triangle faces as individual objects is something which is not done usually looking at how Blender exports objects but i’m not sure i understand how that’s done either. Then again your game object might have separated them for some reasons, idk.

What is clear is that you get in Blender correctly what you have read from your file and that is consistent in different software - Meshlab.
So i do not believe your statement

Blender creates wrong faces, although all face-indices are correct

is correct here.

Have you tried to use this addon
to analyze indices?