[SOLVED] setLODlevel doesn't seem to apply

Hello,

I’m trying to generate and set a LOD on a mesh but when I’m testing with different LOD parameters, it seems the triangle count on screen is still the same. I compared to the TestLodStress and TestLodGeneration examples and I can’t figure out what I’m doing wrong. Any clue?

This is my code

public void simpleInitApp() {

    flyCam.setMoveSpeed(250);     
            
    /** A white, directional light source */ 
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.5f)).normalizeLocal());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun); 
    
    Geometry mesh = (Geometry)assetManager.loadModel("Models/simpleOak/simpleOak.j3o");
    
    LodGenerator lodGenerator = new LodGenerator(mesh);          
    lodGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL,  .9f);
    
    mesh.setLodLevel(1);
    rootNode.attachChild(mesh);
}

The mesh was created from a .obj file generated in blender that had no LOD

I tried with different parameters instead of the .9f, or tried the constant mode

I’m using jMonkeyEngine SDK 3.1.0-stable-FINAL

The algorithm can fail on some geometries and not generate lods…
could you post a screenshot of your model with the wireframe visible, please?
For example it doesn’t work on the Elephant in the test repo.

Here it is
https://ibb.co/g785cQ

https://ibb.co/bCcbj5

If related to the mesh, what would be the recommended way to create and export these LOD in blender? I was reading in some older topics that the best way is ogreXML exporter, is it still the case?

Now I tried with the ogreXML extension but when I run the advanced export (right click on the xml) it crashes (even when unchecking the generate tangents). Also, now when i simply import the ogre model, I’m able to use the scene composer and right click / tools / generate level of details, but when I do this, I get an error on the triangles similar to another post

Any chance I could simply generate my own LOD meshes in blender, import them (one by one and separately) and tell jme to switch between the different models?

Are you using the ogre script installed from the SDK?

If so, remove that script and install 0.6.0 as linked to from here.
https://jmonkeyengine.github.io/wiki/jme3/advanced/ogrecompatibility.html

2 Likes

Solved with your suggestion! I imported the mesh and in jME I did right click / advanced / generate LOD. The LODs appear in the mesh editor from jME and I could test them in the scene

Thanks a lot!

1 Like