Time for action – go fast and vast

Vast terrains can render quite slowly, especially if you waste cycles calculating vertices that the player doesn't even see.

We can activate an optimization called LOD by performing the following steps:

  1. Return to your copy of TerrainSimple.java.
  2. Create a TerrainLodControl (from the com.jme3.terrain.geomipmap package) and add it to the terrain spatial.
    TerrainQuad terrain = new TerrainQuad("terrain", 65, 513, heightmap.getHeightMap());
    TerrainLodControl lodControl = new TerrainLodControl(terrain, getCamera());
    terrain.addControl(lodControl);
    terrain.setMaterial(terrainMat);
    rootNode.attachChild(terrain);

Run the code and move high up and closer again. Watch the change in the level of detail based on how far away each ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.