What I am missing (BoundingVolume problem ?)?

Hi to all,



I’ve been using jMe1 then 2 for various project and I finnaly switched to jMe3 a few weeks ago. I’m using jMonkeyPlateform now.



Something is getting me crazy for some days nows. It seems that something weird is happening when I’m loading the same model in a loop and attach them to the rootNode.

I want to create several instances of the same model, so I use the same .j3o file (made from an ogre xml blender export) like this, in the initApp :

[java]

for (int i = 0; i < 5; i++) {

Spatial m = assetManager.loadModel(“Models/tank/tank.mesh.j3o”);

m.setLocalTranslation(i*10, 0,-10);

rootNode.attachChild(m);

}

[/java]

This small test case is showing my problem : all my models disapear when the last Spatial is not in my cam frustrum. So I launch the app, I see nothing, if i turn to the right, I finally can see all the models, if I play with the cam direction and make the last model be out of the cam, everything disappear.

It looks like the boundingVolume of the last loaded spatial is the only one present in the scene and all models are depending on it. This “bug” remembers me when I forgot to set a boundingBox to a Box in jMe2. Then I tried to set a boundingVolume to the loaded model and to update it… but nothing to do, always the same problem.

Also, I checked with non-loaded model (Box with Material) and the same code works well!



Does anyone have an idea to solve this ?



Thanks

Hm, there seems to be a slight bug in BoundingVolume updates since we added “local updates”. Since you’re coming from jME2, generally calling updateXXX should not be necessary in jME3. Also, if you have to call updateGeometricState for some reason, always call it on the rootNode, never call it on some spatial that has a parent. Did you try just cloning or deepCloning (also copies textures, meshes etc) the loaded model? We’ll investigate :slight_smile:



Cheers,

Normen

Thanks for the (super) quick answer.

Yes, I tried both clone and deepClone, nothing changed. I tried many things.

But the worst is the fact that this code still give me this bug :

[java]

Spatial m = assetManager.loadModel(“Models/tank/tank.mesh.j3o”);

rootNode.attachChild(m);



Spatial m2 = assetManager.loadModel(“Models/tank/tank.mesh.j3o”);

m2.setLocalTranslation(10, 0, 0);

rootNode.attachChild(m2);

[/java]

I’m out of ideas about it now…

Thanks

Hi,



Is there anything that came up about this boundingVolume problem on loaded models ? Or any kind of workaround to avoid inattended objects invisibility due to this bug ?



Thanks !

I think I found it. The bug is in BoundingVolume.clone(), it doesn’t clone the center variable but just stores it as-is, so it is set to the center of the last bounding updated, means that when you cant see the last model you cant see any of them.



EDIT: Should be fixed in SVN

Thanks for your investigation.

I updated the jMe SDK (with the nightly svn) but the problem persists. I tried my previous test case and :



[java]

Spatial m = assetManager.loadModel(“Models/tank/tank.mesh.j3o”);

rootNode.attachChild(m);



Spatial m2 = m.deepClone();

m2.setLocalTranslation(10, 0, 0);

rootNode.attachChild(m2);

[/java]



…but I still have the problem… At start I can’t see m beacause m2 is not in the camera field.



Am I doing something wrong for the update ?



EDIT : But… with this the problem seems to be solved :



[java]

Spatial m = assetManager.loadModel(“Models/tank/tank.mesh.j3o”);

rootNode.attachChild(m);



Spatial m2 = m.deepClone();

m2.setModelBound(new BoundingBox());

m2.updateModelBound();

m2.setLocalTranslation(10, 0, 0);

rootNode.attachChild(m2);

[/java]



It’s seems that what you made changed something in good anyway because even this code wasn’t operating well when I first reported this bug.



So, for now I’ll go with it,



Thank you.

This change is not in nightly yet, I only commited it to SVN. The nightly build will be updated from SVN in a day.

I just want to confirm that you repaired it. This problem doesn’t occur anymore now, with the last update.



Thanks again!