Problem calculating tangents (no triangles in every index)

Hi,

I have a problem calculating tangents (no triangles in every index)… In my models I have indices that are not used in every LOD level. The extra indices are utilized potentially by some other LOD level (typically 16 LOD levels). I hope I got the terms right, I’m not good at speaking 3D.

So the tangent generator crashes on this line. There are no triangles at a particular index at this LOD level. Is this a problem in my models, or how I generate them? The models itself are generally working. Just this tangent generation fails.

TangentBinormalGenerator.processTriangleData:717:
TriangleData firstTriangle = vertices.get(vertexInfo.indices.get(0)).triangles.get(0);

Stack before somebody asks it :slight_smile:

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.ArrayList.rangeCheck(ArrayList.java:653)
    at java.util.ArrayList.get(ArrayList.java:429)
    at com.jme3.util.TangentBinormalGenerator.processTriangleData(TangentBinormalGenerator.java:717)
    at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:226)
    at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:131)
    at toniarts.openkeeper.tools.convert.KmfModelLoader.createGeometry(KmfModelLoader.java:598)
    at toniarts.openkeeper.tools.convert.KmfModelLoader.handleMesh(KmfModelLoader.java:271)
    at toniarts.openkeeper.tools.convert.KmfModelLoader.load(KmfModelLoader.java:162)
    at toniarts.openkeeper.tools.convert.AssetsConverter.convertModel(AssetsConverter.java:393)
    at toniarts.openkeeper.tools.convert.AssetsConverter.convertModels(AssetsConverter.java:340)
    at toniarts.openkeeper.tools.convert.AssetsConverter.convertAssets(AssetsConverter.java:206)
    at toniarts.openkeeper.setup.DKConverter$Converter.run(DKConverter.java:251)

I forked the TangentBinormalGenerator to skip these. And it works, seemingly the normal maps now work (also specular added to the last one)


This would be an easy fix, if you agree with me that this is a bug? Again, I’m not an expert and my explanation might not be perfectly understandable, but please ask for more details in that case.

Forked here: