TangenBinormalGenerator + blend file [BUG]

Hi!



When I import my blend scene I get such an exception:





Jan 2, 2012 6:34:49 PM com.jme3.scene.Node attachChild

INFO: Child (base6) attached to this node (base)

Jan 2, 2012 6:34:49 PM com.jme3.scene.plugins.blender.BlenderModelLoader load

INFO: base: (0.0, 0.0, -0.0)–> null

Jan 2, 2012 6:34:49 PM com.jme3.scene.Node attachChild

INFO: Child (base) attached to this node (Scenes/levels/level_01/level_01.blend)

Jan 2, 2012 6:34:49 PM com.jme3.scene.plugins.blender.objects.ObjectHelper toObject

INFO: Loading obejct: base2

Jan 2, 2012 6:34:49 PM com.jme3.scene.plugins.blender.objects.ObjectHelper toObject

INFO: Importing mesh.

Jan 2, 2012 6:34:49 PM com.jme3.scene.plugins.blender.materials.MaterialHelper toMaterial

INFO: Loading material.

Jan 2, 2012 6:34:49 PM com.jme3.scene.plugins.blender.textures.TextureHelper getTextureFromImage

INFO: Reading texture from file: //…/…/…/Textures/base_textures/base_05_metal/base_05_metal_05.png

Jan 2, 2012 6:34:49 PM com.jme3.scene.plugins.blender.materials.MaterialHelper toMaterial

INFO: Materials name: {0}

Jan 2, 2012 6:34:49 PM com.jme3.scene.plugins.blender.materials.MaterialHelper toMaterial

WARNING: Attetion! Many textures found for material: bb0505. Only the first of each supported mapping types will be used!

Jan 2, 2012 6:34:49 PM com.jme3.scene.plugins.blender.materials.MaterialHelper getNonTexturedMaterial

WARNING: The name of the texture does not contain the texture type value! null will not be removed!

Jan 2, 2012 6:34:49 PM com.jme3.scene.Node attachChild

INFO: Child (base21) attached to this node (base2)

Jan 2, 2012 6:34:49 PM com.jme3.scene.plugins.blender.BlenderModelLoader load

INFO: base2: (0.0, 0.0, -0.0)–> null

Jan 2, 2012 6:34:49 PM com.jme3.scene.Node attachChild

INFO: Child (base2) attached to this node (Scenes/levels/level_01/level_01.blend)

Jan 2, 2012 6:34:49 PM com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

at java.util.ArrayList.RangeCheck(ArrayList.java:547)

at java.util.ArrayList.get(ArrayList.java:322)

at com.jme3.util.TangentBinormalGenerator.processTriangleData(TangentBinormalGenerator.java:448)

at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:153)

at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:109)

at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:120)

at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:116)

at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:116)

at com.bigboots.testscene.TestSceneComposer.simpleInitApp(TestSceneComposer.java:81)

at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:231)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:129)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

at java.lang.Thread.run(Thread.java:662)

Jan 2, 2012 6:34:49 PM com.jme3.renderer.lwjgl.LwjglRenderer cleanup

INFO: Deleting objects and invalidating state

Jan 2, 2012 6:34:49 PM com.jme3.input.lwjgl.LwjglMouseInput destroy

INFO: Mouse destroyed.

Jan 2, 2012 6:34:49 PM com.jme3.input.lwjgl.LwjglKeyInput destroy

INFO: Keyboard destroyed.

Jan 2, 2012 6:34:49 PM com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread

INFO: Display destroyed.

BUILD SUCCESSFUL (total time: 3 seconds)






the scene loads ok without TangentBinormalGenerator.

My code:

[java]
DesktopAssetManager dsk = (DesktopAssetManager) assetManager;
ModelKey bk = new ModelKey("Scenes/levels/level_01/level_01.blend");
Node nd = (Node) dsk.loadModel(bk);
nd.setName("nd");
TangentBinormalGenerator.generate(nd);
[/java]

MY SCENE has 2 UV coordinates. It tried to remove one UV coordinates, but it did not help.

Scene can be downloaded here: https://rise-of-mutants.googlecode.com/hg/dev/trunk/TechDemo/assets/Scenes/levels/level_01/level_01.blend
And textures here: https://code.google.com/p/rise-of-mutants/source/browse/dev/trunk/TechDemo/assets/#assets%2FTextures%2Fbase_textures

I tried to generate tangents with the SceneComposer. And I’ve got such an exception… possibly it will be helpful:



java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

at java.util.ArrayList.RangeCheck(ArrayList.java:547)

at java.util.ArrayList.get(ArrayList.java:322)

at com.jme3.util.TangentBinormalGenerator.processTriangleData(TangentBinormalGenerator.java:448)

at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:153)

at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:109)

at com.jme3.gde.core.sceneexplorer.nodes.actions.impl.GenerateTangentsTool.doApplyTool(GenerateTangentsTool.java:59)

at com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction$1$1.call(AbstractToolAction.java:62)

at com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction$1$1.call(AbstractToolAction.java:59)

[catch] at com.jme3.app.AppTask.invoke(AppTask.java:142)

at com.jme3.app.Application.update(Application.java:577)

at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:266)

at com.jme3.system.awt.AwtPanelsContext.updateInThread(AwtPanelsContext.java:157)

at com.jme3.system.awt.AwtPanelsContext.access$100(AwtPanelsContext.java:13)

at com.jme3.system.awt.AwtPanelsContext$AwtPanelsListener.update(AwtPanelsContext.java:37)

at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:119)

at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:143)

at java.lang.Thread.run(Thread.java:662)

Are you sure your mesh consists of triangles?

Also check that you don’t have a lone vertex somewhere (sometime it happens when you edit the mesh)

Yeah, I also doubt a vertex array with size zero is a proper model.

I tried to convert all polygons to triangles and checked for separete vertexes and edges (did not find any). The same issue.



But model works without TangenBinormalGenerator.

Well there is a zero size buffer somewhere.

I figured out when this exception appears. When one object has many materials. JME separates object’s geometry by its material and then TangenBinormalGenerator makes such an exception.



I tried to separate one object with only one material by myself and there was no the exception.



Is it bug or not? At present, I cannot make one object with many materials and then apply TangenBinormalGenerator.

It would be cool if it’s possible to fix.



My screenshot for example of many materials in one object:

http://i.imgur.com/WKhiw.png

Its possible, its just that when you have a zero-vertex object for one material you get these issues. The objects must be separated by material because as you know an object can only have one material in jME3/OpenGL. What happens when you use OgreXML? I guess it simply drops that no-vertex object.

OgreXML has the same exception. I even tried one object(plane) with 20 plygons and 2 materials without textures.



OgreXMLException:

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

at java.util.ArrayList.RangeCheck(ArrayList.java:547)

at java.util.ArrayList.get(ArrayList.java:322)

at com.jme3.util.TangentBinormalGenerator.processTriangleData(TangentBinormalGenerator.java:448)

at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:153)

at com.jme3.util.TangentBinormalGenerator.generate(TangentBinormalGenerator.java:109)

at com.jme3.gde.core.sceneexplorer.nodes.actions.impl.GenerateTangentsTool.doApplyTool(GenerateTangentsTool.java:59)

at com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction$1$1.call(AbstractToolAction.java:62)

at com.jme3.gde.core.sceneexplorer.nodes.actions.AbstractToolAction$1$1.call(AbstractToolAction.java:59)

[catch] at com.jme3.app.AppTask.invoke(AppTask.java:142)

at com.jme3.app.Application.update(Application.java:577)

at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:266)

at com.jme3.system.awt.AwtPanelsContext.updateInThread(AwtPanelsContext.java:157)

at com.jme3.system.awt.AwtPanelsContext.access$100(AwtPanelsContext.java:13)

at com.jme3.system.awt.AwtPanelsContext$AwtPanelsListener.update(AwtPanelsContext.java:37)

at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:119)

at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:143)

at java.lang.Thread.run(Thread.java:662)

So again, its your model. Make sure there is no areas with only a few vertices having the material assigned.

I said above I tried even with simple object (plane) with 20 polygons and 2 materials(without textures) . And exception appears if object has 2 materials or more. Ogre and blend files have the same exception with TangentBinormalGenerator applied.



http://dl.dropbox.com/u/26887202/123/jme_blender/tangentBinormalGenerator_bug.zip



Object is like this:

http://i.imgur.com/geiMZ.png

Nope, models with multiple materials get imported as two objects just fine, look at the ogre for example.

did you try to generate tangents for them? have a try and you will get an exception.

I don’t know about your file, I am talking about jme3 in general. ITS YOUR FILE!

Would you please to download my file and try to generate tangents for it? http://dl.dropbox.com/u/26887202/123/jme_blender/tangentBinormalGenerator_bug.zip



I just try to tell that TangentBinormalGenerator has the bug.

Why would I, you told me it causes an error, I believe you ^^

1 Like
@normen said:
Nope, models with multiple materials get imported as two objects just fine, look at the ogre for example.


Maybe the blender loader is getting confused in this case and doing something odd.

Ogre loader does the same. I tested ogre xml and blend files. the same issue.



the problem is with objects which have multiple materials.

I’ve bookmarked this thread, which means that maybe in a month or two it will get fixed … Unless of course you want to take a look at whats happening and fix it :stuck_out_tongue: Since OgreXML is effected as well I think that finding the cause would be fairly simple

GOD BLESS CORE DEVS!!! :slight_smile: I’ll wait of course.