I’m trying to set LoD for all objects/models at .j3o scene.
Here’s my code of building which I’m trying to set LoD. The path to node is correct but LoD doesn’t work.
[java] Node house = (Node) rootNode.getChild(“Blacksmith”);
Geometry geo = (Geometry) house.getChild(“geo”);
LodGenerator lodGenerator = new LodGenerator(geo);
lodGenerator.bakeLods(LodGenerator.TriangleReductionMethod.PROPORTIONAL, 0.10f);
geo.setLodLevel(1);[/java]
[java]
LodControl lodCtrl = new LodControl();
lodCtrl.setSpatial(geo);
lodCtrl.setEnabled(true);[/java]
Still nothing.
You didn’t add the control to the geo controls list…setSpatial is automatically called when you add it but not sufficient to make it work…your control isn’t registered in the controls to update…update(float tpf) can’t be called…
After generating the LODs for the geometry, you create and add a com.jme3.scene.control.LodControl to the geometry. Adding the LodControl activates the LOD optimizaton for this geometry.
LodControl lc = new LodControl();
myPrettyGeo.addControl(lc);
rootNode.attachChild(myPrettyGeo);