Getting Geometry or Terrain from scene.j3o

Hello

I wanna create LoD for my map and models. I’m using scene in .j3o format. I found code:
[java]LodGenerator lodGenerator = new LodGenerator(geometry); lodGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL, 0.1f,0.5f);

LodGenerator lodGenerator = new LodGenerator(geometry);
lodGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL, 0.1f,0.5f);[/java]

but i dont have idea how to get geometry of terrain from my scene

You don’t need the actual geometry, just the TerrainQuad object.
If you know the name of the spatial you can look it up from the root node:
n.getChild(“myScene-terrain”)

For the terrain you want to create a TerrainLodControl, if you are using JME terrain. If you are loading a terrain model, then don’t use it.

[java]LodGenerator lodGenerator = new LodGenerator(geometry);[/java]

It require [java]geometry[/java] type. I cannot use node. So how should i done it with .j3o scene? Maybe i can somehow convert that for node?

You need to use the LodGenerator on the individual geometries. You can do this in the scene composer itself.
But if you want to execute the lodGenerator when the level is loading, you will have to recursively crawl through the entire scene and find the geometries and run it on them:

// get root scene node
// for each node, get all the children
// if the child is the node, get its children and call this method again
// if the child is a geometry, then use the LodGenerator on it

You need to use the LodGenerator on the individual geometries. You can do this in the scene composer itself.

But it doesn’t work in game, when i set LoD in scene Composer…