[Solved in Code] After editing a .j3o model in scene composer and saving it I get null error the next time i open it

Hi

After converting my .blend model to .j3o in SDK it opens correctly in scene composer but after changing it in scene composer (like moving ,scaling, deleting or editing material or any other changes ) and saving , the next time i open it get null error.
It also happens when load that model in code .

  java.lang.NullPointerException
    at com.jme3.shader.Uniform.setValue(Uniform.java:185)
    at com.jme3.material.Technique.updateUniformParam(Technique.java:149)
    at com.jme3.material.MatParam.apply(MatParam.java:133)
    at com.jme3.material.Material.preload(Material.java:1059)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:613)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:604)
    at com.jme3.animation.SkeletonControl.testHardwareSupported(SkeletonControl.java:162)
    at com.jme3.animation.SkeletonControl.controlRender(SkeletonControl.java:276)
    at com.jme3.scene.control.AbstractControl.render(AbstractControl.java:119)
    at com.jme3.scene.Spatial.runControlRender(Spatial.java:681)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:667)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:656)
    at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1029)
    at com.jme3.renderer.RenderManager.render(RenderManager.java:1088)
    at com.jme3.app.SimpleApplication.update(SimpleApplication.java:260)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
    at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:192)
    at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
    at java.lang.Thread.run(Thread.java:745)

Thanks

Edit: I am using JME SDK 3.1 alpha 2
also my model has rig on it

Edit 2 : When loading the model for first time (I mean before editing and saving in scene composer ) it loads OK in code and i also can move, rotate,scale, generate tangents ,… unless i want to save it as .j3o

Edit 3: Uploaded .j3o model to Dropbox - kang.zip - Simplify your life
without texture.

Edit 4 :
and here is the log i get when converting my .blend file to .j3o file

   File D:\Java\jME_NB-PW-11-6-2015\The Night Watchman Test\assets\Models\Kang\cadnav.com_model\Kang.j3o@a7cca284:6667cf0b[invalid] deleted, remove!
Remove file change listener for D:\Java\jME_NB-PW-11-6-2015\The Night Watchman Test\assets\Models\Kang\cadnav.com_model\Kang.blend@29d4ceb1:65fb09b2
Loading animations that will be later applied to scene features.
Found animation: guitar_playing.
Found animation: running_inPlace_2.
Cannot locate resource: C:/Users/ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped)
Cannot locate resource: Users/ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped)
Cannot locate resource: ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped)
Cannot locate resource: Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped)
Cannot locate resource: Kang/cadnav.com_model/hokutex0.tga (Flipped)
Cannot locate resource: cadnav.com_model/hokutex0.tga (Flipped)
Cannot locate resource: hokutex0.tga (Flipped)
Loading model's textures.
The texture Map #7 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Loading model's textures.
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Loading model's textures.
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #7 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #7 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #7 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #7 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #7 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #6 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Loading model's textures.
Cannot locate resource: C:/Users/ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: Users/ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: hokutex0.tga (Flipped) (Mipmapped)
The texture Map #4 has linear color space, but the material parameter DiffuseMap specifies no color space requirement, this may lead to unexpected behavior.
Check if the image was not set to another material parameter with a linear color space, or that you did not set the ColorSpace to Linear using texture.getImage.setColorSpace().
Cannot locate resource: C:/Users/ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: Users/ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: Desktop/Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: Kang/cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: cadnav.com_model/hokutex0.tga (Flipped) (Mipmapped)
Cannot locate resource: hokutex0.tga (Flipped) (Mipmapped)
Loaded asset Kang
File Kang.blend saved successfully
Notified about change in AssetData properties for Kang
Kang listening for external changes on D:\Java\jME_NB-PW-11-6-2015\The Night Watchman Test\assets\Models\Kang\cadnav.com_model\Kang.blend@29d4ceb1:65fb09b2
Set original path for Kang to Models/Kang/cadnav.com_model/Kang.blend
Removing asset Models/Kang/cadnav.com_model/Kang.blend, from cache via main asset Kang.
Removing asset Models/Kang/cadnav.com_model/Character_A1016A466/hokutex010.tga, from cache via main asset Kang.
Removing asset Models/Kang/cadnav.com_model/Character_A1016A466/hokutex013.tga, from cache via main asset Kang.
Removing asset Models/Kang/cadnav.com_model/Character_A1016A466/hokutex003.tga, from cache via main asset Kang.
Removing asset Models/Kang/cadnav.com_model/Character_A1016A466/hokutex007.tga, from cache via main asset Kang.
Removing asset Models/Kang/cadnav.com_model/Character_A1016A466/hokutex011.tga, from cache via main asset Kang.
Removing asset Models/Kang/cadnav.com_model/Character_A1016A466/hokutex006.tga, from cache via main asset Kang.
Removing asset Common/MatDefs/Light/Lighting.j3md, from cache via main asset Kang.

Can be because of missing that “hokutex0.tga” texture ?

Oops it is locating to somewhere out of my asset folder!!!

Cannot locate resource: C:/Users/ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga

it is locating to my other PC. :sweat_smile:

1 Like

But the Main Problem still exists?
I mean without the texture it should actually just ignore the texture.

It seems to be an engine issue though, since the render manager should actually take a “texture not found” texture.

Yes it is exist. I find missing texture and replaced . now it does not give that

Cannot locate resource: C:/Users/ALI/Desktop/Kang/cadnav.com_model/hokutex0.tga

anymore. but main problem is exist yet.

here is my model when converting from .blend to .j3o without changing in scene composer :

I re simulated the problem on a simpler model.
First workflow which ends with failing :
I have a model in blender format which has animation on it. (.blend)
I covert it to .j3o by right clicking on it then hit “converting to j3o binary”.
I open it in scene composer then move it a bit then save it and close scene composer.
I open it again in scene composer.
I get this error :

java.lang.NullPointerException
    at com.jme3.shader.Uniform.setValue(Uniform.java:185)
    at com.jme3.material.Technique.updateUniformParam(Technique.java:149)
    at com.jme3.material.MatParam.apply(MatParam.java:133)
    at com.jme3.material.Material.preload(Material.java:1059)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:613)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:604)
    at com.jme3.animation.SkeletonControl.testHardwareSupported(SkeletonControl.java:162)
    at com.jme3.animation.SkeletonControl.controlRender(SkeletonControl.java:276)
    at com.jme3.scene.control.AbstractControl.render(AbstractControl.java:119)
    at com.jme3.scene.Spatial.runControlRender(Spatial.java:681)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:667)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:656)
    at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1029)
    at com.jme3.renderer.RenderManager.render(RenderManager.java:1088)
    at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:321)
    at com.jme3.system.awt.AwtPanelsContext.updateInThread(AwtPanelsContext.java:194)
    at com.jme3.system.awt.AwtPanelsContext.access$100(AwtPanelsContext.java:44)
    at com.jme3.system.awt.AwtPanelsContext$AwtPanelsListener.update(AwtPanelsContext.java:68)
    at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:125)
    at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:156)
    at java.lang.Thread.run(Thread.java:745)

Second workflow which ends with success :

I have a model in blender format which has animation on it. (.blend)
I covert it to .j3o by right clicking on it then hit “converting to j3o binary”.
I open it in scene composer
then select mesh and create material:

then move model a bit then save it and close scene composer.
I open it again in scene composer. and every thing is OK and no error happens.


And this happens when your model is rigged. for non skeleton models there is no problem.

How can I generate j3m material like image above, inside code?

Sorry to bring up my post. :sweat_smile:

Bug : The problem seems to be related to Save Option in SDK Scene Composer.

Scenario 1 : Edit Model Inside Code (It solves my problem and every thing seems to work OK)

Load .j3o model in code (converted from .blend to .j3o in SDK). [The model has animation]
Edit Model : Scale,Move,…
Save it.
The next time I open the model it Works fine without null exception occur.

Using the code below :

public class ModelLoader extends SimpleApplication {

    private Spatial spatial;
    private File out;

    @Override
    public void simpleInitApp() {

        spatial = assetManager.loadModel("Models/Kang/cadnav.com_model/Kang.j3o");
        spatial.scale(0.01f);
        spatial.setLocalTranslation(0, 5, 0);
        TangentBinormalGenerator.generate(spatial);      
        rootNode.attachChild(spatial);
        
        out = new File("D:/Java/jME_NB-PW-11-6-2015/The Night Watchman Test/assets/Models/Kang/cadnav.com_model/Kang.j3o");
        
        BinaryExporter exporter = BinaryExporter.getInstance();
        try (FileOutputStream outStream = new FileOutputStream(out)) {
            out.createNewFile();
            exporter.save(spatial, outStream);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException ex) {
           
            ex.printStackTrace();
        }
    }

    /* This is called when the user quits the app. */
    @Override
    public void stop() {
       
        super.stop(); // continue quitting the game
    }

    public static void main(String[] args) {
        ModelLoader app = new ModelLoader();

        app.start();
       // app.stop();
    }
}

Scenario 2 : Edit j3o Model in Scene Composer and Save it using SDK save button.
The next time you open the model you get NullPointerException . (The exception is same with Scenario 3)

Scenario 3: Edit Model Inside Code but this time I save it in Stop() method
and it gives NullException the next time I open the model.

public class ModelLoader extends SimpleApplication {

    private Spatial spatial;
    private File out;

    @Override
    public void simpleInitApp() {

        spatial = assetManager.loadModel("Models/Kang/cadnav.com_model/Kang.j3o");
        spatial.scale(0.01f);
        spatial.setLocalTranslation(0, 5, 0);
        TangentBinormalGenerator.generate(spatial);      
        rootNode.attachChild(spatial);
        
        out = new File("D:/Java/jME_NB-PW-11-6-2015/The Night Watchman Test/assets/Models/Kang/cadnav.com_model/Kang.j3o");
        
       
    }

    /* This is called when the user quits the app. */
    @Override
    public void stop() {
       
         BinaryExporter exporter = BinaryExporter.getInstance();
        try (FileOutputStream outStream = new FileOutputStream(out)) {
            out.createNewFile();
            exporter.save(spatial, outStream);

        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException ex) {
           
            ex.printStackTrace();
        }
        
        super.stop(); // continue quitting the game
    }

    public static void main(String[] args) {
        ModelLoader app = new ModelLoader();

        app.start();
       // app.stop();
    }
}

Both Scenario 2 and 3 give THE SAME Exception :

java.lang.NullPointerException
    at com.jme3.shader.Uniform.setValue(Uniform.java:185)
    at com.jme3.material.Technique.updateUniformParam(Technique.java:149)
    at com.jme3.material.MatParam.apply(MatParam.java:133)
    at com.jme3.material.Material.preload(Material.java:1059)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:613)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:604)
    at com.jme3.animation.SkeletonControl.testHardwareSupported(SkeletonControl.java:162)
    at com.jme3.animation.SkeletonControl.controlRender(SkeletonControl.java:276)
    at com.jme3.scene.control.AbstractControl.render(AbstractControl.java:119)
    at com.jme3.scene.Spatial.runControlRender(Spatial.java:681)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:667)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:677)
    at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:656)
    at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1029)
    at com.jme3.renderer.RenderManager.render(RenderManager.java:1088)
    at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:321)
    at com.jme3.system.awt.AwtPanelsContext.updateInThread(AwtPanelsContext.java:194)
    at com.jme3.system.awt.AwtPanelsContext.access$100(AwtPanelsContext.java:44)
    at com.jme3.system.awt.AwtPanelsContext$AwtPanelsListener.update(AwtPanelsContext.java:68)
    at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:125)
    at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:156)
    at java.lang.Thread.run(Thread.java:745)

Does it help to solve the bug ?

Hey,
The problem is I didn’t have the time to look into this yet aswell as I actually I have no clue on the interna happening there (Why does that NPE happen? If it’s a faulty Material then there’s at least a broken validity check)

That stop() thing shouldn’t crash either, it’s really wierd.

Anyway judging by a null pointer exception actually means there is something not properly serialized.
Try this:

a) Using the XMLExporter instead of the BinaryExporter. Try to see differences
b) Try the newish MaterialExporter:
I know you’ve asked for that, and it is possible with the latest alpha but don’t ask me on how to do that exactly.

Either using some Material method or by using a “J3MExporter”, but then only call it on the Material or worst things will happen.
The best thing for this is to just look into the latest commits to find out what exactly was added.

Good luck and thanks for investigating on your own :slight_smile:

1 Like

As you remember this problem was solved inside code but not in SDK Scene Composer yet.
When I switched to Xbuf importer the problem is exist yet :stuck_out_tongue:
but this time getting a different error :

java.lang.IllegalArgumentException: for uniform m_BoneMatrices: value cannot be null
    at com.jme3.shader.Uniform.setValue(Uniform.java:210)
    at com.jme3.material.Material.updateShaderMaterialParameters(Material.java:804)
    at com.jme3.material.Material.preload(Material.java:844)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:665)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:656)
    at com.jme3.renderer.RenderManager.preloadScene(RenderManager.java:656)
    at com.jme3.animation.SkeletonControl.testHardwareSupported(SkeletonControl.java:164)
    at com.jme3.animation.SkeletonControl.controlRender(SkeletonControl.java:281)
    at com.jme3.scene.control.AbstractControl.render(AbstractControl.java:135)
    at com.jme3.scene.Spatial.runControlRender(Spatial.java:756)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:723)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:733)
    at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:733)
    at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:712)
    at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1086)
    at com.jme3.renderer.RenderManager.render(RenderManager.java:1145)
    at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:321)
    at com.jme3.system.awt.AwtPanelsContext.updateInThread(AwtPanelsContext.java:194)
    at com.jme3.system.awt.AwtPanelsContext.access$100(AwtPanelsContext.java:44)
    at com.jme3.system.awt.AwtPanelsContext$AwtPanelsListener.update(AwtPanelsContext.java:68)
    at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:125)
    at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:156)
    at java.lang.Thread.run(Thread.java:745)

thought this may help a bit.

I have exactly the same error just by opening an old j3o Model and resaving it.
I can finally reproduce it a bit. Seems like our cloning/deserialization is broken a bit.

But in your code it works, only not in the SDK?
Which is really strange tbh

Edit: HA! Engine Guys? @nehon, @kirill, @pspeed (Sorry for tagging :P)
Can you Imagine ANY case where controlUpdate() or something kills the Material? So any recent change like the MPOs (or are they 3.2? That’s why I ask you guys).

Because Ali’s Investigations clearly show: When he saves the file BEFORE the Engine ever completely ran (before the update is triggered), everything works. If he saves it in stop(), so the update ran, which also applies to the SDK, the model is broken on deserialization?

Maybe some optimization nulled the bone matrices or something?

Edit2:
Okay it’s hard to diff it, I should use a smaller model probably, but what I got is:

+                  <MapEntry key='BoneMatrices'>
+                     <Savable class='com.jme3.material.MatParam' name='BoneMatrices' savable_versions='0' varType='Matrix4Array' />
+                   </MapEntry>

and

+                   <MapEntry key='NumberOfBones'>
+                     <Savable class='com.jme3.material.MatParam' name='NumberOfBones' savable_versions='0' value_int='80' varType='Int' />
+                   </MapEntry>

Other than that it’s just the order of the bones inside of the lists.
It does NOT set an actual Matrix though, so this might be the problem?
That it usually generates the matrix when not in the file? (But should it even be serialized? Not that I know off?)

Edit:
I tried debugging this for quite a while now and what I found out is when I simply don’t set that uniform then I get this:

     [exec] SEVERE [com.jme3.gde.core.scene.SceneApplication]: Material instances cannot be shared when hardware skinning is used. Ensure all models use unique material instances.
     [exec] java.lang.UnsupportedOperationException: Material instances cannot be shared when hardware skinning is used. Ensure all models use unique material instances.
     [exec]     at com.jme3.animation.SkeletonControl.controlRenderHardware(SkeletonControl.java:258)
     [exec]     at com.jme3.animation.SkeletonControl.controlRender(SkeletonControl.java:299)
     [exec]     at com.jme3.scene.control.AbstractControl.render(AbstractControl.java:135)
     [exec]     at com.jme3.scene.Spatial.runControlRender(Spatial.java:756)
     [exec]     at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:723)
     [exec]     at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:733)
     [exec]     at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:733)
     [exec]     at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:733)
     [exec]     at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:712)
     [exec]     at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1086)
     [exec]     at com.jme3.renderer.RenderManager.render(RenderManager.java:1145)
     [exec] [catch] at com.jme3.gde.core.scene.SceneApplication.update(SceneApplication.java:321)

I FINALLY FIXED IT!
It used to be multiple bugs/missing things in the core.
This however means it might still take some time until it’s officially fixed along with some design decisions yet to be made.

Then the updates server is offline which means we can’t build the sdk with the new engine version, so we have to wait for beta2 and the servers :confused:

1 Like

well, don’t keep us all in suspense, what was causing the issues.

Man you did great. Big Thanks. :hugging:

Okay so two things were the Problem:

Actually three things, the first one being that no one complains when the sdk is doing something wrong, they just start using different software :stuck_out_tongue:
Since the Bug was related to saving .j3o files with animation on there are rare usecases, mainly the sdk. The bug might even be there since we support animation but since hardware skinning was no default and could only be set in code it was never used in the sdk.

The first thing is: We couldn’t serialize Material Parameters which come in Arrays (Matrix4f[] in our case).
The Bone Matrices are actually recomputed each frame but since we tried to export them, they were defined as MatParam but their value was “null” (aka I am too stupid to (de)serialize) :stuck_out_tongue:

When we fixed this, we had the problem that the Animation uses a sanity check to see if multiple models use the same material. For this it simply checks if all materials’ matrices are equal or if they’ve changed.
Having the Bone Matrices serialized led to unequal Materials leading to that Exception.

Another thing is: You can’t even use Software Skinning to bypass this issue since we forgot to serialize this param

2 Likes

It is not serialized on purpose… as nehon already said in chat.

If you want software skinning on a model you just loaded then you set software skinning on the model you just loaded.

1 Like