Cannot generate Level of Detail

Hello everyone,

I was following the tutorial for generating Level of Detail Models from a base model in the scene explorer.
However I encountered the following exception:

[java]
java.lang.IllegalArgumentException: Vertex 814 : (…here comes the vertex position…) is not part of triangle Triangle{… here come the vertices of the triangle …}
at jme3tools.optimize.LodGenerator$Triangle.getVertexIndex(LodGenerator.java:225)
at …
[/java]

I thought it might be an issue because of quads in the object. Therefore I went to blender and triangulated everything, but the issue remains.
I took a look at the coordinates in the exception and it looks like this:

The Exception says that Vertex X is not part of the triangle ABC, which… is perfectly fine.

Any ideas or suggestions on the issue?
If you need the model or further information, just ask!
Thanks!

1 Like

And another thing:
Of course I consulted the forums; the only thing I found is that @nehon might be the most informed on this.

ABC does not really look like a triangle on this mesh. That’s weird that the generator think it is.
You should check that there is no face in blender for those vertices.

Does the model renders properly in JME (without lod ofc)?
Also there seem to be overlapping faces in your model from the picture…Idk for sure but this could be an issue for the lod generator.

I’d like to see the model yes.
Did you import it with ogre or with the Blender loader?

Also very nice investigation, it might have been hell to narrow down the issue to those vertices from the stack trace.

1 Like
@nehon said: You should check that there is no face in blender for those vertices.
I don't know if there is a way to check this directly, but I disassembled the mesh face by face and couldn't find it.
@nehon said: Does the model renders properly in JME (without lod ofc)?
In jME and ingame the model renders fine as far as I can tell.
@nehon said: Also there seem to be overlapping faces in your model from the picture...Idk for sure but this could be an issue for the lod generator.
There are overlapping faces, yes. We put some objects into each other.
@nehon said: Did you import it with ogre or with the Blender loader?
The latter. I converted it to .j3o in the SDK.
@nehon said: I'd like to see the model yes.

Here it is.

If you search for the faulty vertex it is here (-0.03515, 0.18498, -3.03375)
However when I searched for the vertex in blender I needed to swap numbers and negate one:
(-0.03515, 3.03375, 0.18498)

@nehon said: Also very nice investigation, it might have been hell to narrow down the issue to those vertices from the stack trace.
Thanks. I hope the fix can be done just as nicely as the investigation. ;-)

Ok so I exported the model with ogre and I can generate Lod no problem. You can do this as a work around.
Might be a Blender loader issue, I’ll investigate further.

i do have a similiar issue… I just wondered why the hell all models that i found do not have any lod. After checking what is said in this thread i tryed to just convert a model that i have in blender to .obj and directly to .j3o… The .obj can generate lod and .j3o not :frowning:

Edit: instead of displaying the levels the lod generators says 3 times higher triangle count in editor.

It’s been quite some time and I’m wondering what’s up with the issue at the moment.

@nehon, have you found anything?

@nehon said: Might be a Blender loader issue,

Could be, maybe we should bring @Kaelthas on board, too.

Hey @m41q

I will check this out today or tomorrow.
Could you as well post me a piece of code that demonstrates the issue ?
It will save me lots of time :wink:

1 Like

@Kaelthas

Thanks, that was a fast response.
However, I cannot give you code, but rather a

Short Summary:

  • Link for problematic model is here
  • I convert the model to .j3o and try to create the LOD for the geometries.
  • However there is a failure in the LOD generator “Vertex 814 :(…) is not part of triangle Triangle(…)”

Now either there is a bug in the LOD generator or the .j3o somehow contains information that a vertex is part of a triangle that he is not actually a part of…
I looked at the coordinates of the problematic vertices, picture is in first post.

So no code, just conversion to .j3o --> Lod-generation --> error

Hey @m41q

It is quite difficult for me to say what might cause the problem, as I do not know the LOD generation system and the model is quite large to be able to easily analyze it.

But I have made some reserach. The problem is somehow connected with the UV coordinates.
When I remove them the LOD generates fine and the model appears on the scene.
Also the point that did not fit with the triangle is located exactly on the seam of your model.

I guess that the LOD algorithm tries to reduce the amount of triangles. Maybe it tries to join severalt triangles into one and the vertex that causes problems is not on the larger triangle plane.
But that is just a guess.

I will try to prepare a more simple model to see what is happening there. I will let you know if I find anything.

1 Like
@Kaelthas said: I will try to prepare a more simple model to see what is happening there. I will let you know if I find anything.

Much appreciated!

@m41q

Unfortunately I did not manage to create a simple mesh that would reproduce the issue. And it is difficult for me to say what does the LOD generator acutally do.
But I can tell more about the model that is being loaded.

I think that the problem lies somewhere in sharing vertices between faces.
Blender loaded tries to use as few vertices as possible for the model.

So if the mesh is smooth then verts will be referenced by their indexes and this way - shared between the faces of the model.
The issue gets more complicated when you assign UV coordinates. And even more complicated when you use seams to split the UV map.
This way you create a situation that one vertex can have multiple UV coords. And in such case we need to use two different vertices in the model.

But as I said before - blender importer tries to use as few vertices as possible. So when you assign UV coordinates to the vertex (even in several different UV groups) and the UV coords are not split then this vertex will be referenced by the index for the mesh and not copied.

I have noticed that when I removed the piece of code and made such verts to be copied (I commented the lines: 244 to 256 in com.jme3.scene.plugins.blender.meshes.builders.FaceMeshBuilder ) - then the LOD generated fine.

I am still not sure if the problem lies in LOD generator or blender importer.
@nehon if you have a piece of time - could you take a look at it ?? :slight_smile:

The most simple way to make blender importer to copy verts for each face is to use ‘solid’ model instead of ‘smooth’.

Nevertheless I’ll try to investigate further and I’ll let you know if I find anything.

@Kaelthas

First of all thanks for your efforts!
After all you’ve investigated it looks like the LodGenerator does not treat indexed vertices right. Maybe they get removed when they should not?

@nehon… maybe you can find something with the investigation results of Kaelthas?

Not sure what you imply by “smooth” and “solid”.

@Kaelthas said: But as I said before - blender importer tries to use as few vertices as possible. So when you assign UV coordinates to the vertex (even in several different UV groups) and the UV coords are not split then this vertex will be referenced by the index for the mesh and not copied.
Not sure neither what you mean by that, but vertices should definitely be split if they have at least one different attribute (position, uv, normal, color, and so on). Now in the Op's investigation I can't see how X and C could be shared as they're not at the same position.

@nehon

smooth
smooth

flat ( this is what I called ‘solid’)
flat

When the mesh is in flat mode then the vertices are always split because each one will need different normal for applying light to its face.

@nehon said: Not sure neither what you mean by that, but vertices should definitely be split if they have at least one different attribute (position, uv, normal, color, and so on).

In other words I ment a situation when attributes of the vertex are identical no matter what face references it :slight_smile: