Problem with LOD and exporter/importer


I am having issue with LOD and exporter.

I have tried the embeded ogre exporter in jme but it does not seems to save lod details and I keep getting

java.lang.IllegalStateException: LOD levels are not set on this mesh

even if I have lod in the xml.

If I load from XML all is fine.

If I save and relaod right after boom

here is log that shows that we are loosing loddetail. (probably because I am doing something wrong but cannot figure what)

5-Feb-2011 9:35:09 AM simpleInitApp

SEVERE: AFTER XML LOAD num of lod : 7

5-Feb-2011 9:35:09 AM simpleInitApp

SEVERE: AFTER RELOAD num of lod : 0

5-Feb-2011 9:35:09 AM com.jme3.scene.Node attachChild

INFO: Child (Sign Post-ogremesh) attached to this node (Root Node)

5-Feb-2011 9:35:10 AM handleError

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

java.lang.IllegalStateException: LOD levels are not set on this mesh

here is the code to reproduce the boom

[java]import com.jme3.animation.AnimChannel;

import com.jme3.animation.AnimControl;


import com.jme3.export.binary.BinaryExporter;

import com.jme3.export.binary.BinaryImporter;

import com.jme3.light.DirectionalLight;

import com.jme3.math.ColorRGBA;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.Node;

import com.jme3.scene.control.LodControl;




import java.util.logging.Logger;

public class TestOgreConvert extends SimpleApplication {

public static void main(String[] args){

TestOgreConvert app = new TestOgreConvert();




public void simpleInitApp() {

Node ogreModel = (Node)assetManager.loadModel(“Models/Decoration/Sign Post/Sign Post.mesh.xml”);

Geometry geo = (Geometry)ogreModel.getChild(0);

Logger.getLogger(“test”).severe("AFTER XML LOAD num of lod : " + geo.getMesh().getNumLodLevels());

geo.addControl(new LodControl());

DirectionalLight dl = new DirectionalLight();


dl.setDirection(new Vector3f(0,-1,-1).normalizeLocal());


try {

ByteArrayOutputStream baos = new ByteArrayOutputStream();

BinaryExporter exp = new BinaryExporter();, baos);

ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

BinaryImporter imp = new BinaryImporter();


Node ogreModelReloaded = (Node) imp.load(bais, null, null);

geo = (Geometry)ogreModelReloaded.getChild(0);

Logger.getLogger(“test”).severe("AFTER RELOAD num of lod : " + geo.getMesh().getNumLodLevels());

// fis.close();


} catch (IOException ex){





here is the ogrexml

with mesh



I looked into Mesh class

and noticed that

the member

private VertexBuffer[] lodLevels;

is not saved nor restored, which could explain the loose of the lod when we save export it.

is it on purpose? or am I doing something wrong?

All sample of LOD are provided with xml, not j3o format therefore I am not sure if what I try to do is correct.


No, I think you just hinted at a bug and delivered the solution on a silver plate :slight_smile: Tanks very much, 1up for you :smiley:

Very Welcome :slight_smile: always happy to help.

Thanks! Its fixed now