BLENDER to J3O File does not open if I generate tangents [BUG]

But the problem is in jmp-composer i suppose.

After generating tangents and saving the model I can load it in JME with code, but i cannot open it in the SceneComposer.

i never tried use “broken” models ingame, but in jmp-composer i have the same situation.



First of all we should try fix JMP-Composer(where propably problem is).



so again i quote:


1) Downloading SDK beta from jme webpage and delete all setting folders seems to work.

2) BUT updating:

Android Support [3.0.0.8348.45 -> 3.0.0.8829.45]
Applet Support [3.0.0.8424 -> 3.0.0.8774]
AssetPack Support [3.0.0.8383 -> 3.0.0.8667]
Desktop Deployment Support [3.0.0.8117 -> 3.0.0.8774]
Font Creator [3.0.0.8093 -> 3.0.0.8774]
GLSL Editor [3.0.0.8421 -> 3.0.0.8829]
jMonkeyEngine3 External Libraries [3.0.0.8499 -> 3.0.0.8829]
jMonkeyEngine3 Library [3.0.0.8509 -> 3.0.0.8829]
Material Support [3.0.0.8119 -> 3.0.0.8829]
Model Import Tool [3.0.0.8436 -> 3.0.0.8667]
NiftyGUI Support [3.0.0.8390.2 -> 3.0.0.8774.2]
OgreXML Support [3.0.0.8384 -> 3.0.0.8667]
Project Templates [3.0.0.8408 -> 3.0.0.8829]
Project Test Data [3.0.0.8306 -> 3.0.0.8667]
SceneComposerA plugin in the jMonkeyEngine3 SDK, allows editing the content of j3o files which represent a complete scene or model. [3.0.0.8380 -> 3.0.0.8667]
SDK Core [3.0.0.8511.45 -> 3.0.0.8829.45]
SDK Engine [3.0.0.8509 -> 3.0.0.8829]
SDK Libraries [3.0.0.8499 -> 3.0.0.8829]
Terrain Editor [3.0.0.8314 -> 3.0.0.8667]
Tests Template [3.0.0.8500 -> 3.0.0.8667]
Vehicle Creator [3.0.0.8118 -> 3.0.0.8667]
Welcome Screen [3.0.0.8093 -> 3.0.0.8794]

give in SDK Composer exception i said before


this is quote from my old topic. it appear when generating tangents(on model based on .blend -> j3o) and trying to load model to composer again(after save it)

so i think somewhere here is problem:

SceneComposer [3.0.0.8380 -> 3.0.0.8667]

If it doesn’t open in the SDK something is wrong with the import process/model. Again, the exception is in cloneForAnim, if it loads in code that just means some corner case isn’t happening there. Just regard the SDK the best test environment for jme3 imports in general. If it doesn’t work there something is wrong, in this case with the blender importer which apparently creates half-done models that cannot be properly serialized.

My model consists of boxes… and it does not have animations.

and no clones too…



agreed with @oxplay2 .

Anyway, thank you @normen for answers. I hope it will be possible to fix in future.

Its cute how you try to prove me wrong but read the stack trace, thats where the exception is, period. Cloning always happens when you load models from the assetManager.

@normen , @Momoko_fan , @Kaelthas , it seems that in code the Exception appears too.

This is the blender importer + TangentBinormalGenerator + save to j3o.



All Blender models with generated tangents and saved to j3o get this Exception:



26.02.2012 1:24:56 com.jme3.app.Application handleError

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

java.lang.NullPointerException

at com.jme3.scene.Mesh.cloneForAnim(Mesh.java:277)

at com.jme3.scene.Geometry.clone(Geometry.java:491)

at com.jme3.scene.Geometry.clone(Geometry.java:60)

at com.jme3.scene.Spatial.clone(Spatial.java:1142)

at com.jme3.scene.Node.clone(Node.java:565)

at com.jme3.scene.Node.clone(Node.java:61)

at com.jme3.scene.Spatial.clone(Spatial.java:1142)

at com.jme3.scene.Node.clone(Node.java:565)

at com.jme3.scene.Node.clone(Node.java:61)

at com.jme3.scene.Spatial.clone(Spatial.java:1182)

at com.jme3.asset.ModelKey.createClonedInstance(ModelKey.java:58)

at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:300)

at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:408)

at com.forgottenspace.client.scenecomposer.SceneComposer.loadModelNow(SceneComposer.java:294)

at com.forgottenspace.client.scenecomposer.SceneComposer.startCompose(SceneComposer.java:115)

at com.forgottenspace.client.scenecomposer.SceneComposer.(SceneComposer.java:59)

at testScene.TestScene.setupScene(TestScene.java:139)

at testScene.TestScene.simpleInitApp(TestScene.java:105)

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

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)

26.02.2012 1:24:56 com.jme3.renderer.lwjgl.LwjglRenderer cleanup

INFO: Deleting objects and invalidating state

26.02.2012 1:24:56 com.jme3.input.lwjgl.LwjglMouseInput destroy

INFO: Mouse destroyed.

26.02.2012 1:24:56 com.jme3.input.lwjgl.LwjglKeyInput destroy

INFO: Keyboard destroyed.

26.02.2012 1:24:56 com.jme3.system.lwjgl.LwjglAbstractDisplay deinitInThread

INFO: Display destroyed.

dont be so angry @normen. Do you remember TCP and UDP problem in SpiderMonkey? you was so sure that it should work, but it dont.



i dont know whats going on here, even looking on source code line 277



for both: blender 2.49 and blender 2.61

ogre.mesh → j3o all work ok

.blend → j3o exception like on images



i set on show normals to see there are ok, UV map is ok too

http://i.imgur.com/0wMWK.png



convert blend → j3o

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



create tangents

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



save model

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



reload model in SceneComposer

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



should it work or not? im not core dev, so i cant answer it myself. maybe i just do somethin wrong

@oxplay2 it seems this is:

blender importer + tangents + save to j3o… My post above with the code.



Now I get the exception even in the code.

@mifth funny is that i writed about it long time when it was on other line(and only i had this problem :o):


at com.jme3.scene.Mesh.cloneForAnim(Mesh.java:284)


then @Momoko_Fan tried to fix it, so line changed now to
at com.jme3.scene.Mesh.cloneForAnim(Mesh.java:277)


but on SceneComposer 3.0.0.8380 everything worked fine! have you tried to reinstall SDK and not do updates? i tried ;)

so i will repeat again:

Android Support [3.0.0.8348.45 -> 3.0.0.8829.45]
Applet Support [3.0.0.8424 -> 3.0.0.8774]
AssetPack Support [3.0.0.8383 -> 3.0.0.8667]
Desktop Deployment Support [3.0.0.8117 -> 3.0.0.8774]
Font Creator [3.0.0.8093 -> 3.0.0.8774]
GLSL Editor [3.0.0.8421 -> 3.0.0.8829]
jMonkeyEngine3 External Libraries [3.0.0.8499 -> 3.0.0.8829]
jMonkeyEngine3 Library [3.0.0.8509 -> 3.0.0.8829]
Material Support [3.0.0.8119 -> 3.0.0.8829]
Model Import Tool [3.0.0.8436 -> 3.0.0.8667]
NiftyGUI Support [3.0.0.8390.2 -> 3.0.0.8774.2]
OgreXML Support [3.0.0.8384 -> 3.0.0.8667]
Project Templates [3.0.0.8408 -> 3.0.0.8829]
Project Test Data [3.0.0.8306 -> 3.0.0.8667]
SceneComposerA plugin in the jMonkeyEngine3 SDK, allows editing the content of j3o files which represent a complete scene or model. [3.0.0.8380 -> 3.0.0.8667]
SDK Core [3.0.0.8511.45 -> 3.0.0.8829.45]
SDK Engine [3.0.0.8509 -> 3.0.0.8829]
SDK Libraries [3.0.0.8499 -> 3.0.0.8829]
Terrain Editor [3.0.0.8314 -> 3.0.0.8667]
Tests Template [3.0.0.8500 -> 3.0.0.8667]
Vehicle Creator [3.0.0.8118 -> 3.0.0.8667]
Welcome Screen [3.0.0.8093 -> 3.0.0.8794]

before: work, after: exception

its just a.... sad truth

Can it be because Blender Models already have tangents? And when tangents generated again, so j3o gets some kind of issue?

im too tired now to check it out.



we can always use ogre mesh and leave this topic alone

@mifth said:
Can it be because Blender Models already have tangents? And when tangents generated again, so j3o gets some kind of issue?


These sorts of guesses seem so easy to test to me. If you want to eliminate the blender loader from the equation then create a JME Box, generate tangents for it twice, save it... see if it has the problem. Then you will know it's "generating tangents twice."

Otherwise, all evidence points to a bug in the blender loader... whatever that might be.

When all other formats work fine except .blend files, it's really hard to get people to think it's something other than the blender loader causing the problem.

Its already clear its the blender importer. As I said, the models it generates are somehow not complete or falsely configured so this happens.

@normen said:
Its already clear its the blender importer. As I said, the models it generates are somehow not complete or falsely configured so this happens.


Yeah, I agree... but when the random stabs in the dark at trying to accuse other things only take 30 seconds to test... then test before posting. ;)

This thread has long stopped being an attempt to solve the problem ^^

@normen forgot to say that you were right about the scenecomposer. This is blender importer’s issue.

@pspeed , actually i didn’t know how to test. But looking at getMesh method i found this:



[java]

blenderGeom.getMesh().getBuffer(VertexBuffer.Type.Tangent); // Returns Null. There are no tangents in a loaded model.

[/java]



I tried to change vertex buffers, and I god the Exception:

[java]

Geometry blenderGeom;

//…

//…

Mesh tmpMesh = blenderGeom.getMesh().cloneForAnim();

TangentBinormalGenerator.generate(tmpMesh);

// tmpMesh.getBuffer(VertexBuffer.Type.Tangent).setNormalized(true);

// tmpMesh.getBuffer(VertexBuffer.Type.Tangent).clearUpdateNeeded();

// tmpMesh.getBuffer(VertexBuffer.Type.Tangent).hasDataSizeChanged();

blenderGeom.getMesh().setBuffer(tmpMesh.getBuffer(VertexBuffer.Type.Tangent));

[/java]

Can someone create a test case that reproduces this bug without jMP? Also include any models that fail.

@Momoko_Fan said:
Can someone create a test case that reproduces this bug without jMP? Also include any models that fail.

I think the model and code are flying around somewhere in this thread.

I was not able to reproduce the issue with the given code and models

@Momoko_Fan said:
I was not able to reproduce the issue with the given code and models

..but now you found the issue, right?
http://code.google.com/p/jmonkeyengine/issues/detail?id=429#c1